Index: chrome/browser/jumplist_win.h |
diff --git a/chrome/browser/jumplist_win.h b/chrome/browser/jumplist_win.h |
index 30739d68fbd23aa37394e2e7f1ecd0647839fae6..41b12a939285b2555e617f208d2b022610defd44 100644 |
--- a/chrome/browser/jumplist_win.h |
+++ b/chrome/browser/jumplist_win.h |
@@ -17,6 +17,7 @@ |
#include "chrome/browser/history/history_service.h" |
#include "chrome/browser/history/history_types.h" |
#include "chrome/browser/jumplist_updater_win.h" |
+#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/sessions/tab_restore_service.h" |
#include "chrome/browser/sessions/tab_restore_service_observer.h" |
#include "content/public/browser/browser_thread.h" |
@@ -29,20 +30,20 @@ namespace content { |
class NotificationRegistrar; |
} |
-class Profile; |
class PageUsageData; |
+class PrefChangeRegistrar; |
+class Profile; |
// A class which implements an application JumpList. |
// This class encapsulates operations required for updating an application |
// JumpList: |
// * Retrieving "Most Visited" pages from HistoryService; |
// * Retrieving strings from the application resource; |
-// * Creatng COM objects used by JumpList from PageUsageData objects; |
+// * Creating COM objects used by JumpList from PageUsageData objects; |
// * Adding COM objects to JumpList, etc. |
// |
-// This class also implements TabRestoreServiceObserver. So, once we call |
-// AddObserver() and register this class as an observer, it automatically |
-// updates a JumpList when a tab is added or removed. |
+// This class observes the tabs and policies of the given Profile and updates |
+// the JumpList whenever a change is detected. |
// |
// Updating a JumpList requires some file operations and it is not good to |
// update it in a UI thread. To solve this problem, this class posts to a |
@@ -55,19 +56,13 @@ class JumpList : public TabRestoreServiceObserver, |
public base::RefCountedThreadSafe< |
JumpList, content::BrowserThread::DeleteOnUIThread> { |
public: |
- JumpList(); |
+ explicit JumpList(Profile* profile); |
// NotificationObserver implementation. |
virtual void Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details); |
- // Registers (or unregisters) this object as an observer. |
- // When the TabRestoreService object notifies the tab status is changed, this |
- // class automatically updates an application JumpList. |
- bool AddObserver(Profile* profile); |
- void RemoveObserver(); |
- |
// Observer callback for TabRestoreService::Observer to notify when a tab is |
// added or removed. |
virtual void TabRestoreServiceChanged(TabRestoreService* service); |
@@ -79,16 +74,21 @@ class JumpList : public TabRestoreServiceObserver, |
// Cancel a pending jumplist update. |
void CancelPendingUpdate(); |
- // Terminate the jumplist: cancel any pending updates and remove observer |
- // from TabRestoreService. This must be called before the profile provided |
- // in the AddObserver method is destroyed. |
+ // Terminate the jumplist: cancel any pending updates and stop observing |
+ // the Profile and its services. This must be called before the |profile_| |
+ // is destroyed. |
void Terminate(); |
// Returns true if the custom JumpList is enabled. |
// The custom jumplist works only on Windows 7 and above. |
static bool Enabled(); |
- protected: |
+ private: |
+ friend struct content::BrowserThread::DeleteOnThread< |
+ content::BrowserThread::UI>; |
+ friend class base::DeleteHelper<JumpList>; |
+ virtual ~JumpList(); |
+ |
// Creates a ShellLinkItem object from a tab (or a window) and add it to the |
// given list. |
// These functions are copied from the RecentlyClosedTabsHandler class for |
@@ -120,20 +120,20 @@ class JumpList : public TabRestoreServiceObserver, |
void OnMostVisitedURLsAvailable( |
const history::MostVisitedURLList& data); |
+ // Callback for changes to the incognito mode availability pref. |
+ void OnIncognitoAvailabilityChanged(); |
+ |
+ // Helper for RunUpdate() that determines its parameters. |
+ void PostRunUpdate(); |
+ |
// Runnable method that updates the jumplist, once all the data |
// has been fetched. |
- void RunUpdate(); |
+ void RunUpdate(IncognitoModePrefs::Availability incognito_availability); |
// Helper method for RunUpdate to create icon files for the asynchrounously |
// loaded icons. |
void CreateIconFiles(const ShellLinkItemList& item_list); |
- private: |
- friend struct content::BrowserThread::DeleteOnThread< |
- content::BrowserThread::UI>; |
- friend class base::DeleteHelper<JumpList>; |
- ~JumpList(); |
- |
// For callbacks may be run after destruction. |
base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
@@ -145,6 +145,7 @@ class JumpList : public TabRestoreServiceObserver, |
// Lives on the UI thread. |
scoped_ptr<content::NotificationRegistrar> registrar_; |
+ scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
// App id to associate with the jump list. |
std::wstring app_id_; |