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

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

Issue 7538022: Jumplist Bug (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | chrome/browser/jumplist_win.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/synchronization/lock.h"
15 #include "chrome/browser/history/history.h" 16 #include "chrome/browser/history/history.h"
17 #include "chrome/browser/history/history_types.h"
18 #include "chrome/browser/history/top_sites.h"
16 #include "chrome/browser/sessions/tab_restore_service.h" 19 #include "chrome/browser/sessions/tab_restore_service.h"
17 #include "chrome/browser/sessions/tab_restore_service_observer.h" 20 #include "chrome/browser/sessions/tab_restore_service_observer.h"
21 #include "chrome/browser/ui/webui/ntp/base_most_visited_handler.h"
MAD 2011/08/05 21:21:43 This doesn't exist anymore...
18 #include "content/browser/cancelable_request.h" 22 #include "content/browser/cancelable_request.h"
19 23
20 class FilePath; 24 class FilePath;
21 class Profile; 25 class Profile;
22 class PageUsageData; 26 class PageUsageData;
23 27
24 // Represents a class used for creating an IShellLink object by the utility 28 // Represents a class used for creating an IShellLink object by the utility
25 // functions in this file. 29 // functions in this file.
26 // This class consists of three strings and a integer. 30 // This class consists of three strings and a integer.
27 // * arguments (std::wstring) 31 // * arguments (std::wstring)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // JumpList: 93 // JumpList:
90 // * Retrieving "Most Visited" pages from HistoryService; 94 // * Retrieving "Most Visited" pages from HistoryService;
91 // * Retrieving strings from the application resource; 95 // * Retrieving strings from the application resource;
92 // * Creatng COM objects used by JumpList from PageUsageData objects; 96 // * Creatng COM objects used by JumpList from PageUsageData objects;
93 // * Adding COM objects to JumpList, etc. 97 // * Adding COM objects to JumpList, etc.
94 // 98 //
95 // This class also implements TabRestoreServiceObserver. So, once we call 99 // This class also implements TabRestoreServiceObserver. So, once we call
96 // AddObserver() and register this class as an observer, it automatically 100 // AddObserver() and register this class as an observer, it automatically
97 // updates a JumpList when a tab is added or removed. 101 // updates a JumpList when a tab is added or removed.
98 // 102 //
103 // This class also implements BaseMostVisitedHandler. So by calling
MAD 2011/08/05 21:21:43 Update this comment, base class doesn't exist anym
104 // AddObserver() we also register for TOP_SITES_CHANGED notifications, and the
105 // JumpList is updated when a top site is added or blacklisted.
106 //
99 // Updating a JumpList requires some file operations and it is not good to 107 // Updating a JumpList requires some file operations and it is not good to
100 // update it in a UI thread. To solve this problem, this class posts a 108 // update it in a UI thread. To solve this problem, this class posts a
101 // task when it actually updates a JumpList. (This task is implemented in an 109 // task when it actually updates a JumpList. (This task is implemented in an
102 // anomynous namespace in "jumplist_win.cc".) 110 // anomynous namespace in "jumplist_win.cc".)
103 class JumpList : public TabRestoreServiceObserver { 111 class JumpList : public TabRestoreServiceObserver,
112 public NotificationObserver,
113 public base::RefCountedThreadSafe<JumpList> {
104 public: 114 public:
105 JumpList(); 115 JumpList();
106 ~JumpList(); 116 ~JumpList();
107 117
118 // NotificationObserver implementation.
119 virtual void Observe(int type,
120 const NotificationSource& source,
121 const NotificationDetails& details);
122
108 // Registers (or unregisters) this object as an observer. 123 // Registers (or unregisters) this object as an observer.
109 // When the TabRestoreService object notifies the tab status is changed, this 124 // When the TabRestoreService object notifies the tab status is changed, this
110 // class automatically updates an application JumpList. 125 // class automatically updates an application JumpList.
111 bool AddObserver(Profile* profile); 126 bool AddObserver(Profile* profile);
112 void RemoveObserver(); 127 void RemoveObserver();
113 128
114 // Observer callback for TabRestoreService::Observer to notify when a tab is 129 // Observer callback for TabRestoreService::Observer to notify when a tab is
115 // added or removed. 130 // added or removed.
116 // This function sends a query that retrieves "Most Visited" pages to 131 // This function sends a query that retrieves "Most Visited" pages to
117 // HistoryService. When the query finishes successfully, HistoryService call 132 // HistoryService. When the query finishes successfully, HistoryService call
118 // OnSegmentUsageAvailable(). 133 // OnSegmentUsageAvailable().
119 virtual void TabRestoreServiceChanged(TabRestoreService* service); 134 virtual void TabRestoreServiceChanged(TabRestoreService* service);
120 135
121 // Observer callback to notice when our associated TabRestoreService 136 // Observer callback to notice when our associated TabRestoreService
122 // is destroyed. 137 // is destroyed.
123 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); 138 virtual void TabRestoreServiceDestroyed(TabRestoreService* service);
124 139
140 // Send a request to the HistoryService to get the most visited pages.
141 void StartQueryForMostVisited();
142
125 // Returns true if the custom JumpList is enabled. 143 // Returns true if the custom JumpList is enabled.
126 // We use the custom JumpList when we satisfy the following conditions: 144 // We use the custom JumpList when we satisfy the following conditions:
127 // * Chromium is running on Windows 7 and; 145 // * Chromium is running on Windows 7 and;
128 // * Chromium is lauched without a "--disable-custom-jumplist" option. 146 // * Chromium is lauched without a "--disable-custom-jumplist" option.
129 // TODO(hbono): to be enabled by default when we finalize the categories and 147 // TODO(hbono): to be enabled by default when we finalize the categories and
130 // items of our JumpList. 148 // items of our JumpList.
131 static bool Enabled(); 149 static bool Enabled();
132 150
133 protected: 151 protected:
134 // Creates a ShellLinkItem object from a tab (or a window) and add it to the 152 // Creates a ShellLinkItem object from a tab (or a window) and add it to the
(...skipping 20 matching lines...) Expand all
155 173
156 // A callback function for HistoryService that notify when a requested favicon 174 // A callback function for HistoryService that notify when a requested favicon
157 // is available. 175 // is available.
158 // To avoid file operations, this function just attaches the given data to 176 // To avoid file operations, this function just attaches the given data to
159 // a ShellLinkItem object. 177 // a ShellLinkItem object.
160 // When finishing loading all favicons, this function posts a task that 178 // When finishing loading all favicons, this function posts a task that
161 // decompresses collected favicons and updates a JumpList. 179 // decompresses collected favicons and updates a JumpList.
162 void OnFaviconDataAvailable(HistoryService::Handle handle, 180 void OnFaviconDataAvailable(HistoryService::Handle handle,
163 history::FaviconData favicon); 181 history::FaviconData favicon);
164 182
183 // Callback for TopSites. BaseMostVisitedHandler that notifies when the "Most
MAD 2011/08/05 21:21:43 Mention of removed base class again...
184 // Visited" list is available. This function updates the ShellLinkItemList
185 // objects and send another query that retrieves a favicon for each URL in
186 // the list.
187 void OnMostVisitedURLsAvailable(
188 const history::MostVisitedURLList& data);
MAD 2011/08/05 21:21:43 Bad indent, should be only 4 more spaces than prev
189
190 // Runnable method that updates the jumplist, once have all the data
191 // has been fetched.
192 void JumpList::RunUpdate();
193
165 private: 194 private:
166 // Our consumers for HistoryService. 195 // Our consumers for HistoryService.
167 CancelableRequestConsumer most_visited_consumer_; 196 CancelableRequestConsumer most_visited_consumer_;
168 CancelableRequestConsumer favicon_consumer_; 197 CancelableRequestConsumer favicon_consumer_;
198 CancelableRequestConsumer topsites_consumer_;
169 199
170 // The Profile object used for listening its events.
171 Profile* profile_; 200 Profile* profile_;
172 201
202 NotificationRegistrar registrar_;
203
173 // App id to associate with the jump list. 204 // App id to associate with the jump list.
174 std::wstring app_id_; 205 std::wstring app_id_;
175 206
176 // The directory which contains JumpList icons. 207 // The directory which contains JumpList icons.
177 FilePath icon_dir_; 208 FilePath icon_dir_;
178 209
179 // Items in the "Most Visited" category of the application JumpList. 210 // Items in the "Most Visited" category of the application JumpList.
180 ShellLinkItemList most_visited_pages_; 211 ShellLinkItemList most_visited_pages_;
181 212
182 // Items in the "Recently Closed" category of the application JumpList. 213 // Items in the "Recently Closed" category of the application JumpList.
183 ShellLinkItemList recently_closed_pages_; 214 ShellLinkItemList recently_closed_pages_;
184 215
185 // A list of URLs we need to retrieve their favicons. 216 // A list of URLs we need to retrieve their favicons.
186 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair; 217 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair;
187 std::list<URLPair> icon_urls_; 218 std::list<URLPair> icon_urls_;
219
220 // Handle of last favicon request used to cancel if a new request
221 // comes in before the current one returns.
222 FaviconService::Handle handle_;
223
224 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_
225 // as they may be used by up to 3 threads.
MAD 2011/08/05 21:21:43 We should also add comments to the data members pr
226 base::Lock list_lock_;
188 }; 227 };
189 228
190 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ 229 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | chrome/browser/jumplist_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698