Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_ | 5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_ |
| 6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ | 6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/task/cancelable_task_tracker.h" | 16 #include "base/task/cancelable_task_tracker.h" |
| 17 #include "chrome/browser/history/history_service.h" | 17 #include "chrome/browser/history/history_service.h" |
| 18 #include "chrome/browser/jumplist_updater_win.h" | 18 #include "chrome/browser/jumplist_updater_win.h" |
| 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 20 #include "chrome/browser/profiles/avatar_menu.h" | |
| 21 #include "chrome/browser/profiles/avatar_menu_observer.h" | |
| 20 #include "chrome/browser/sessions/tab_restore_service.h" | 22 #include "chrome/browser/sessions/tab_restore_service.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 23 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 22 #include "components/history/core/browser/history_types.h" | 24 #include "components/history/core/browser/history_types.h" |
| 23 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 24 | 26 |
| 25 namespace chrome { | 27 namespace chrome { |
| 26 struct FaviconImageResult; | 28 struct FaviconImageResult; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 46 // the JumpList whenever a change is detected. | 48 // the JumpList whenever a change is detected. |
| 47 // | 49 // |
| 48 // Updating a JumpList requires some file operations and it is not good to | 50 // Updating a JumpList requires some file operations and it is not good to |
| 49 // update it in a UI thread. To solve this problem, this class posts to a | 51 // update it in a UI thread. To solve this problem, this class posts to a |
| 50 // runnable method when it actually updates a JumpList. | 52 // runnable method when it actually updates a JumpList. |
| 51 // | 53 // |
| 52 // Note. base::CancelableTaskTracker is not thread safe, so we | 54 // Note. base::CancelableTaskTracker is not thread safe, so we |
| 53 // always delete JumpList on UI thread (the same thread it got constructed on). | 55 // always delete JumpList on UI thread (the same thread it got constructed on). |
| 54 class JumpList : public TabRestoreServiceObserver, | 56 class JumpList : public TabRestoreServiceObserver, |
| 55 public content::NotificationObserver, | 57 public content::NotificationObserver, |
| 58 public AvatarMenuObserver, | |
| 56 public base::RefCountedThreadSafe< | 59 public base::RefCountedThreadSafe< |
| 57 JumpList, content::BrowserThread::DeleteOnUIThread> { | 60 JumpList, content::BrowserThread::DeleteOnUIThread> { |
| 58 public: | 61 public: |
| 59 explicit JumpList(Profile* profile); | 62 explicit JumpList(Profile* profile); |
| 60 | 63 |
| 61 // NotificationObserver implementation. | 64 // NotificationObserver implementation. |
| 62 virtual void Observe(int type, | 65 virtual void Observe(int type, |
| 63 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details); | 67 const content::NotificationDetails& details); |
| 65 | 68 |
| 66 // Observer callback for TabRestoreService::Observer to notify when a tab is | 69 // Observer callback for TabRestoreService::Observer to notify when a tab is |
| 67 // added or removed. | 70 // added or removed. |
| 68 virtual void TabRestoreServiceChanged(TabRestoreService* service); | 71 virtual void TabRestoreServiceChanged(TabRestoreService* service); |
| 69 | 72 |
| 70 // Observer callback to notice when our associated TabRestoreService | 73 // Observer callback to notice when our associated TabRestoreService |
| 71 // is destroyed. | 74 // is destroyed. |
| 72 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); | 75 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); |
| 73 | 76 |
| 77 // Overridden from AvatarMenuObserver: | |
| 78 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; | |
|
tapted
2014/11/03 23:57:06
nit: I think this will eventually lose the `virtua
noms (inactive)
2014/11/04 20:03:09
Done. Cleaned up the other ones too.
| |
| 79 | |
| 74 // Cancel a pending jumplist update. | 80 // Cancel a pending jumplist update. |
| 75 void CancelPendingUpdate(); | 81 void CancelPendingUpdate(); |
| 76 | 82 |
| 77 // Terminate the jumplist: cancel any pending updates and stop observing | 83 // Terminate the jumplist: cancel any pending updates and stop observing |
| 78 // the Profile and its services. This must be called before the |profile_| | 84 // the Profile and its services. This must be called before the |profile_| |
| 79 // is destroyed. | 85 // is destroyed. |
| 80 void Terminate(); | 86 void Terminate(); |
| 81 | 87 |
| 82 // Returns true if the custom JumpList is enabled. | 88 // Returns true if the custom JumpList is enabled. |
| 83 // The custom jumplist works only on Windows 7 and above. | 89 // The custom jumplist works only on Windows 7 and above. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 void PostRunUpdate(); | 133 void PostRunUpdate(); |
| 128 | 134 |
| 129 // Runnable method that updates the jumplist, once all the data | 135 // Runnable method that updates the jumplist, once all the data |
| 130 // has been fetched. | 136 // has been fetched. |
| 131 void RunUpdate(IncognitoModePrefs::Availability incognito_availability); | 137 void RunUpdate(IncognitoModePrefs::Availability incognito_availability); |
| 132 | 138 |
| 133 // Helper method for RunUpdate to create icon files for the asynchrounously | 139 // Helper method for RunUpdate to create icon files for the asynchrounously |
| 134 // loaded icons. | 140 // loaded icons. |
| 135 void CreateIconFiles(const ShellLinkItemList& item_list); | 141 void CreateIconFiles(const ShellLinkItemList& item_list); |
| 136 | 142 |
| 143 // Update the cached list of profile avatars to be used as the Profiles | |
| 144 // category JumpList icons. | |
| 145 void UpdateProfileAvatars(); | |
| 146 | |
| 137 // Tracks FaviconService tasks. | 147 // Tracks FaviconService tasks. |
| 138 base::CancelableTaskTracker cancelable_task_tracker_; | 148 base::CancelableTaskTracker cancelable_task_tracker_; |
| 139 | 149 |
| 140 // The Profile object is used to listen for events | 150 // The Profile object is used to listen for events |
| 141 Profile* profile_; | 151 Profile* profile_; |
| 142 | 152 |
| 143 // Lives on the UI thread. | 153 // Lives on the UI thread. |
| 144 scoped_ptr<content::NotificationRegistrar> registrar_; | 154 scoped_ptr<content::NotificationRegistrar> registrar_; |
| 145 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 155 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 146 | 156 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 167 // comes in before it finishes. | 177 // comes in before it finishes. |
| 168 base::CancelableTaskTracker::TaskId task_id_; | 178 base::CancelableTaskTracker::TaskId task_id_; |
| 169 | 179 |
| 170 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 180 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
| 171 // as they may be used by up to 3 threads. | 181 // as they may be used by up to 3 threads. |
| 172 base::Lock list_lock_; | 182 base::Lock list_lock_; |
| 173 | 183 |
| 174 // For callbacks may be run after destruction. | 184 // For callbacks may be run after destruction. |
| 175 base::WeakPtrFactory<JumpList> weak_ptr_factory_; | 185 base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
| 176 | 186 |
| 187 scoped_ptr<AvatarMenu> avatar_menu_; | |
|
tapted
2014/11/03 23:57:06
nit: comment? (for consistency - it looks lonely)
noms (inactive)
2014/11/04 20:03:09
Done.
| |
| 188 | |
| 189 // Profile avatars used as icons by the items in the Profiles category. | |
| 190 std::vector<gfx::Image> profile_avatars_; | |
| 191 | |
| 177 DISALLOW_COPY_AND_ASSIGN(JumpList); | 192 DISALLOW_COPY_AND_ASSIGN(JumpList); |
| 178 }; | 193 }; |
| 179 | 194 |
| 180 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ | 195 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ |
| OLD | NEW |