Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: chrome/browser/jumplist_win.h

Issue 931853003: [Win] Revert the profile switcher code from the jumplist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also remove kActivateExistingProfileBrowser Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
22 #include "chrome/browser/sessions/tab_restore_service.h" 20 #include "chrome/browser/sessions/tab_restore_service.h"
23 #include "chrome/browser/sessions/tab_restore_service_observer.h" 21 #include "chrome/browser/sessions/tab_restore_service_observer.h"
24 #include "components/history/core/browser/history_types.h" 22 #include "components/history/core/browser/history_types.h"
25 #include "components/history/core/browser/top_sites_observer.h" 23 #include "components/history/core/browser/top_sites_observer.h"
26 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/notification_observer.h"
27 26
28 namespace chrome { 27 namespace chrome {
29 struct FaviconImageResult; 28 struct FaviconImageResult;
30 } 29 }
31 30
32 namespace content { 31 namespace content {
33 class NotificationRegistrar; 32 class NotificationRegistrar;
34 } 33 }
35 34
36 class PrefChangeRegistrar; 35 class PrefChangeRegistrar;
(...skipping 10 matching lines...) Expand all
47 // the JumpList whenever a change is detected. 46 // the JumpList whenever a change is detected.
48 // 47 //
49 // Updating a JumpList requires some file operations and it is not good to 48 // Updating a JumpList requires some file operations and it is not good to
50 // update it in a UI thread. To solve this problem, this class posts to a 49 // update it in a UI thread. To solve this problem, this class posts to a
51 // runnable method when it actually updates a JumpList. 50 // runnable method when it actually updates a JumpList.
52 // 51 //
53 // Note. base::CancelableTaskTracker is not thread safe, so we 52 // Note. base::CancelableTaskTracker is not thread safe, so we
54 // always delete JumpList on UI thread (the same thread it got constructed on). 53 // always delete JumpList on UI thread (the same thread it got constructed on).
55 class JumpList : public TabRestoreServiceObserver, 54 class JumpList : public TabRestoreServiceObserver,
56 public content::NotificationObserver, 55 public content::NotificationObserver,
57 public AvatarMenuObserver,
58 public history::TopSitesObserver, 56 public history::TopSitesObserver,
59 public base::RefCountedThreadSafe< 57 public base::RefCountedThreadSafe<
60 JumpList, 58 JumpList,
61 content::BrowserThread::DeleteOnUIThread> { 59 content::BrowserThread::DeleteOnUIThread> {
62 public: 60 public:
63 explicit JumpList(Profile* profile); 61 explicit JumpList(Profile* profile);
64 62
65 // NotificationObserver implementation. 63 // NotificationObserver implementation.
66 void Observe(int type, 64 void Observe(int type,
67 const content::NotificationSource& source, 65 const content::NotificationSource& source,
68 const content::NotificationDetails& details) override; 66 const content::NotificationDetails& details) override;
69 67
70 // Observer callback for TabRestoreService::Observer to notify when a tab is 68 // Observer callback for TabRestoreService::Observer to notify when a tab is
71 // added or removed. 69 // added or removed.
72 void TabRestoreServiceChanged(TabRestoreService* service) override; 70 void TabRestoreServiceChanged(TabRestoreService* service) override;
73 71
74 // Observer callback to notice when our associated TabRestoreService 72 // Observer callback to notice when our associated TabRestoreService
75 // is destroyed. 73 // is destroyed.
76 void TabRestoreServiceDestroyed(TabRestoreService* service) override; 74 void TabRestoreServiceDestroyed(TabRestoreService* service) override;
77 75
78 // Overridden from AvatarMenuObserver:
79 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override;
80
81 // Cancel a pending jumplist update. 76 // Cancel a pending jumplist update.
82 void CancelPendingUpdate(); 77 void CancelPendingUpdate();
83 78
84 // Terminate the jumplist: cancel any pending updates and stop observing 79 // Terminate the jumplist: cancel any pending updates and stop observing
85 // the Profile and its services. This must be called before the |profile_| 80 // the Profile and its services. This must be called before the |profile_|
86 // is destroyed. 81 // is destroyed.
87 void Terminate(); 82 void Terminate();
88 83
89 // Returns true if the custom JumpList is enabled. 84 // Returns true if the custom JumpList is enabled.
90 // The custom jumplist works only on Windows 7 and above. 85 // The custom jumplist works only on Windows 7 and above.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 130
136 // Runnable method that updates the jumplist, once all the data 131 // Runnable method that updates the jumplist, once all the data
137 // has been fetched. 132 // has been fetched.
138 void RunUpdateOnFileThread( 133 void RunUpdateOnFileThread(
139 IncognitoModePrefs::Availability incognito_availability); 134 IncognitoModePrefs::Availability incognito_availability);
140 135
141 // Helper method for RunUpdate to create icon files for the asynchrounously 136 // Helper method for RunUpdate to create icon files for the asynchrounously
142 // loaded icons. 137 // loaded icons.
143 void CreateIconFiles(const ShellLinkItemList& item_list); 138 void CreateIconFiles(const ShellLinkItemList& item_list);
144 139
145 // Called when the list of Profiles has changed. This function updates the
146 // |profile_switcher_| ShellLinkItemList.
147 void UpdateProfileSwitcher();
148
149 // history::TopSitesObserver implementation. 140 // history::TopSitesObserver implementation.
150 void TopSitesLoaded(history::TopSites* top_sites) override; 141 void TopSitesLoaded(history::TopSites* top_sites) override;
151 void TopSitesChanged(history::TopSites* top_sites) override; 142 void TopSitesChanged(history::TopSites* top_sites) override;
152 143
153 // Tracks FaviconService tasks. 144 // Tracks FaviconService tasks.
154 base::CancelableTaskTracker cancelable_task_tracker_; 145 base::CancelableTaskTracker cancelable_task_tracker_;
155 146
156 // The Profile object is used to listen for events 147 // The Profile object is used to listen for events
157 Profile* profile_; 148 Profile* profile_;
158 149
159 // Lives on the UI thread. 150 // Lives on the UI thread.
160 scoped_ptr<content::NotificationRegistrar> registrar_; 151 scoped_ptr<content::NotificationRegistrar> registrar_;
161 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; 152 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
162 153
163 // App id to associate with the jump list. 154 // App id to associate with the jump list.
164 std::wstring app_id_; 155 std::wstring app_id_;
165 156
166 // The directory which contains JumpList icons. 157 // The directory which contains JumpList icons.
167 base::FilePath icon_dir_; 158 base::FilePath icon_dir_;
168 159
169 // Items in the "Most Visited" category of the application JumpList, 160 // Items in the "Most Visited" category of the application JumpList,
170 // protected by the list_lock_. 161 // protected by the list_lock_.
171 ShellLinkItemList most_visited_pages_; 162 ShellLinkItemList most_visited_pages_;
172 163
173 // Items in the "Recently Closed" category of the application JumpList, 164 // Items in the "Recently Closed" category of the application JumpList,
174 // protected by the list_lock_. 165 // protected by the list_lock_.
175 ShellLinkItemList recently_closed_pages_; 166 ShellLinkItemList recently_closed_pages_;
176 167
177 // Items in the "People" category of the application JumpList, protected
178 // by the list_lock_.
179 ShellLinkItemList profile_switcher_;
180
181 // A list of URLs we need to retrieve their favicons, 168 // A list of URLs we need to retrieve their favicons,
182 // protected by the list_lock_. 169 // protected by the list_lock_.
183 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair; 170 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair;
184 std::list<URLPair> icon_urls_; 171 std::list<URLPair> icon_urls_;
185 172
186 // Id of last favicon task. It's used to cancel current task if a new one 173 // Id of last favicon task. It's used to cancel current task if a new one
187 // comes in before it finishes. 174 // comes in before it finishes.
188 base::CancelableTaskTracker::TaskId task_id_; 175 base::CancelableTaskTracker::TaskId task_id_;
189 176
190 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ 177 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_
191 // as they may be used by up to 3 threads. 178 // as they may be used by up to 3 threads.
192 base::Lock list_lock_; 179 base::Lock list_lock_;
193 180
194 // For callbacks may be run after destruction. 181 // For callbacks may be run after destruction.
195 base::WeakPtrFactory<JumpList> weak_ptr_factory_; 182 base::WeakPtrFactory<JumpList> weak_ptr_factory_;
196 183
197 // Contains data about existing Profiles.
198 scoped_ptr<AvatarMenu> avatar_menu_;
199
200 // Whether the experiment that is replacing "Most Visited" category with a
201 // "People" category is enabled.
202 bool use_profiles_category_;
203
204 DISALLOW_COPY_AND_ASSIGN(JumpList); 184 DISALLOW_COPY_AND_ASSIGN(JumpList);
205 }; 185 };
206 186
207 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ 187 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698