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/history/history_types.h" | 18 #include "chrome/browser/history/history_types.h" |
| 19 #include "chrome/browser/jumplist_updater_win.h" | 19 #include "chrome/browser/jumplist_updater_win.h" |
| 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" | |
| 20 #include "chrome/browser/sessions/tab_restore_service.h" | 21 #include "chrome/browser/sessions/tab_restore_service.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 22 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 | 24 |
| 24 namespace chrome { | 25 namespace chrome { |
| 25 struct FaviconImageResult; | 26 struct FaviconImageResult; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 class NotificationRegistrar; | 30 class NotificationRegistrar; |
| 30 } | 31 } |
| 31 | 32 |
| 33 class PageUsageData; | |
| 34 class PrefChangeRegistrar; | |
| 32 class Profile; | 35 class Profile; |
| 33 class PageUsageData; | |
| 34 | 36 |
| 35 // A class which implements an application JumpList. | 37 // A class which implements an application JumpList. |
| 36 // This class encapsulates operations required for updating an application | 38 // This class encapsulates operations required for updating an application |
| 37 // JumpList: | 39 // JumpList: |
| 38 // * Retrieving "Most Visited" pages from HistoryService; | 40 // * Retrieving "Most Visited" pages from HistoryService; |
| 39 // * Retrieving strings from the application resource; | 41 // * Retrieving strings from the application resource; |
| 40 // * Creatng COM objects used by JumpList from PageUsageData objects; | 42 // * Creatng COM objects used by JumpList from PageUsageData objects; |
| 41 // * Adding COM objects to JumpList, etc. | 43 // * Adding COM objects to JumpList, etc. |
| 42 // | 44 // |
| 43 // This class also implements TabRestoreServiceObserver. So, once we call | 45 // This class also implements TabRestoreServiceObserver. So, once we call |
| 44 // AddObserver() and register this class as an observer, it automatically | 46 // AddObserver() and register this class as an observer, it automatically |
|
sky
2014/09/08 16:15:17
Update comments and what not about new functionali
Joao da Silva
2014/09/08 16:44:10
Turns out that there is a single user of this clas
| |
| 45 // updates a JumpList when a tab is added or removed. | 47 // updates a JumpList when a tab is added or removed. |
| 46 // | 48 // |
| 47 // Updating a JumpList requires some file operations and it is not good to | 49 // Updating a JumpList requires some file operations and it is not good to |
| 48 // update it in a UI thread. To solve this problem, this class posts to a | 50 // update it in a UI thread. To solve this problem, this class posts to a |
| 49 // runnable method when it actually updates a JumpList. | 51 // runnable method when it actually updates a JumpList. |
| 50 // | 52 // |
| 51 // Note. base::CancelableTaskTracker is not thread safe, so we | 53 // Note. base::CancelableTaskTracker is not thread safe, so we |
| 52 // always delete JumpList on UI thread (the same thread it got constructed on). | 54 // always delete JumpList on UI thread (the same thread it got constructed on). |
| 53 class JumpList : public TabRestoreServiceObserver, | 55 class JumpList : public TabRestoreServiceObserver, |
| 54 public content::NotificationObserver, | 56 public content::NotificationObserver, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 void OnFaviconDataAvailable( | 115 void OnFaviconDataAvailable( |
| 114 const favicon_base::FaviconImageResult& image_result); | 116 const favicon_base::FaviconImageResult& image_result); |
| 115 | 117 |
| 116 // Callback for TopSites that notifies when the "Most | 118 // Callback for TopSites that notifies when the "Most |
| 117 // Visited" list is available. This function updates the ShellLinkItemList | 119 // Visited" list is available. This function updates the ShellLinkItemList |
| 118 // objects and send another query that retrieves a favicon for each URL in | 120 // objects and send another query that retrieves a favicon for each URL in |
| 119 // the list. | 121 // the list. |
| 120 void OnMostVisitedURLsAvailable( | 122 void OnMostVisitedURLsAvailable( |
| 121 const history::MostVisitedURLList& data); | 123 const history::MostVisitedURLList& data); |
| 122 | 124 |
| 125 // Callback for changes to the incognito mode availability pref. | |
| 126 void OnIncognitoAvailabilityChanged(); | |
|
sky
2014/09/08 16:15:17
Can this and the PostRunUpdate be private?
Joao da Silva
2014/09/08 16:44:10
Done.
| |
| 127 | |
| 128 // Helper for RunUpdate() that determines its parameters. | |
| 129 void PostRunUpdate(); | |
| 130 | |
| 123 // Runnable method that updates the jumplist, once all the data | 131 // Runnable method that updates the jumplist, once all the data |
| 124 // has been fetched. | 132 // has been fetched. |
| 125 void RunUpdate(); | 133 void RunUpdate(IncognitoModePrefs::Availability incognito_availability); |
| 126 | 134 |
| 127 // Helper method for RunUpdate to create icon files for the asynchrounously | 135 // Helper method for RunUpdate to create icon files for the asynchrounously |
| 128 // loaded icons. | 136 // loaded icons. |
| 129 void CreateIconFiles(const ShellLinkItemList& item_list); | 137 void CreateIconFiles(const ShellLinkItemList& item_list); |
| 130 | 138 |
| 131 private: | 139 private: |
| 132 friend struct content::BrowserThread::DeleteOnThread< | 140 friend struct content::BrowserThread::DeleteOnThread< |
| 133 content::BrowserThread::UI>; | 141 content::BrowserThread::UI>; |
| 134 friend class base::DeleteHelper<JumpList>; | 142 friend class base::DeleteHelper<JumpList>; |
| 135 ~JumpList(); | 143 ~JumpList(); |
| 136 | 144 |
| 137 // For callbacks may be run after destruction. | 145 // For callbacks may be run after destruction. |
| 138 base::WeakPtrFactory<JumpList> weak_ptr_factory_; | 146 base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
| 139 | 147 |
| 140 // Tracks FaviconService tasks. | 148 // Tracks FaviconService tasks. |
| 141 base::CancelableTaskTracker cancelable_task_tracker_; | 149 base::CancelableTaskTracker cancelable_task_tracker_; |
| 142 | 150 |
| 143 // The Profile object is used to listen for events | 151 // The Profile object is used to listen for events |
| 144 Profile* profile_; | 152 Profile* profile_; |
| 145 | 153 |
| 146 // Lives on the UI thread. | 154 // Lives on the UI thread. |
| 147 scoped_ptr<content::NotificationRegistrar> registrar_; | 155 scoped_ptr<content::NotificationRegistrar> registrar_; |
| 156 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
| 148 | 157 |
| 149 // App id to associate with the jump list. | 158 // App id to associate with the jump list. |
| 150 std::wstring app_id_; | 159 std::wstring app_id_; |
| 151 | 160 |
| 152 // The directory which contains JumpList icons. | 161 // The directory which contains JumpList icons. |
| 153 base::FilePath icon_dir_; | 162 base::FilePath icon_dir_; |
| 154 | 163 |
| 155 // Items in the "Most Visited" category of the application JumpList, | 164 // Items in the "Most Visited" category of the application JumpList, |
| 156 // protected by the list_lock_. | 165 // protected by the list_lock_. |
| 157 ShellLinkItemList most_visited_pages_; | 166 ShellLinkItemList most_visited_pages_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 170 base::CancelableTaskTracker::TaskId task_id_; | 179 base::CancelableTaskTracker::TaskId task_id_; |
| 171 | 180 |
| 172 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 181 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
| 173 // as they may be used by up to 3 threads. | 182 // as they may be used by up to 3 threads. |
| 174 base::Lock list_lock_; | 183 base::Lock list_lock_; |
| 175 | 184 |
| 176 DISALLOW_COPY_AND_ASSIGN(JumpList); | 185 DISALLOW_COPY_AND_ASSIGN(JumpList); |
| 177 }; | 186 }; |
| 178 | 187 |
| 179 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ | 188 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ |
| OLD | NEW |