Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / notifications / message_center_settings_controller.h
index 6001815..7f2bc19 100644 (file)
@@ -11,6 +11,7 @@
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
 #include "chrome/browser/extensions/app_icon_loader.h"
 #include "chrome/common/content_settings.h"
 #include "content/public/browser/notification_source.h"
 #include "ui/message_center/notifier_settings.h"
 
-class CancelableTaskTracker;
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/user_manager.h"
+#endif
+
 class Profile;
 class ProfileInfoCache;
 
+namespace base {
+class CancelableTaskTracker;
+}
+
 namespace chrome {
 struct FaviconImageResult;
 }
@@ -37,6 +45,9 @@ class ProfileNotifierGroup;
 class MessageCenterSettingsController
     : public message_center::NotifierSettingsProvider,
       public content::NotificationObserver,
+#if defined(OS_CHROMEOS)
+      public chromeos::UserManager::UserSessionStateObserver,
+#endif
       public extensions::AppIconLoader::Delegate {
  public:
   explicit MessageCenterSettingsController(
@@ -66,6 +77,11 @@ class MessageCenterSettingsController
       const message_center::NotifierId& notifier_id,
       const std::string* notification_id) OVERRIDE;
 
+#if defined(OS_CHROMEOS)
+  // Overridden from chromeos::UserManager::UserSessionStateObserver.
+  virtual void ActiveUserChanged(const chromeos::User* active_user) OVERRIDE;
+#endif
+
   // Overridden from extensions::AppIconLoader::Delegate.
   virtual void SetAppImage(const std::string& id,
                            const gfx::ImageSkia& image) OVERRIDE;
@@ -79,7 +95,13 @@ class MessageCenterSettingsController
   void OnFaviconLoaded(const GURL& url,
                        const chrome::FaviconImageResult& favicon_result);
 
-  Profile* GetCurrentProfile() const;
+#if defined(OS_CHROMEOS)
+  // Sets up the notifier group for the guest session. This needs to be
+  // separated from RebuildNotifierGroup() and called asynchronously to avoid
+  // the infinite loop of creating profile. See more the comment of
+  // RebuildNotifierGroups().
+  void CreateNotifierGroupForGuestLogin();
+#endif
 
   void RebuildNotifierGroups();
 
@@ -87,11 +109,11 @@ class MessageCenterSettingsController
   ObserverList<message_center::NotifierSettingsObserver> observers_;
 
   // The task tracker for loading favicons.
-  scoped_ptr<CancelableTaskTracker> favicon_tracker_;
+  scoped_ptr<base::CancelableTaskTracker> favicon_tracker_;
 
   scoped_ptr<extensions::AppIconLoader> app_icon_loader_;
 
-  std::map<string16, ContentSettingsPattern> patterns_;
+  std::map<base::string16, ContentSettingsPattern> patterns_;
 
   // The list of all configurable notifier groups. This is each profile that is
   // loaded (and in the ProfileInfoCache - so no incognito profiles go here).
@@ -102,6 +124,8 @@ class MessageCenterSettingsController
 
   ProfileInfoCache* profile_info_cache_;
 
+  base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_;
+
   DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController);
 };