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

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

Issue 1350653004: [sessions] Properly namespace recently-componentized TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 5 years, 3 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 | « chrome/browser/extensions/api/sessions/sessions_api.cc ('k') | 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>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // 42 //
43 // This class observes the tabs and policies of the given Profile and updates 43 // This class observes the tabs and policies of the given Profile and updates
44 // the JumpList whenever a change is detected. 44 // the JumpList whenever a change is detected.
45 // 45 //
46 // Updating a JumpList requires some file operations and it is not good to 46 // Updating a JumpList requires some file operations and it is not good to
47 // update it in a UI thread. To solve this problem, this class posts to a 47 // update it in a UI thread. To solve this problem, this class posts to a
48 // runnable method when it actually updates a JumpList. 48 // runnable method when it actually updates a JumpList.
49 // 49 //
50 // Note. base::CancelableTaskTracker is not thread safe, so we 50 // Note. base::CancelableTaskTracker is not thread safe, so we
51 // always delete JumpList on UI thread (the same thread it got constructed on). 51 // always delete JumpList on UI thread (the same thread it got constructed on).
52 class JumpList : public TabRestoreServiceObserver, 52 class JumpList : public sessions::TabRestoreServiceObserver,
53 public content::NotificationObserver, 53 public content::NotificationObserver,
54 public history::TopSitesObserver, 54 public history::TopSitesObserver,
55 public base::RefCountedThreadSafe< 55 public base::RefCountedThreadSafe<
56 JumpList, 56 JumpList,
57 content::BrowserThread::DeleteOnUIThread> { 57 content::BrowserThread::DeleteOnUIThread> {
58 public: 58 public:
59 explicit JumpList(Profile* profile); 59 explicit JumpList(Profile* profile);
60 60
61 // NotificationObserver implementation. 61 // NotificationObserver implementation.
62 void Observe(int type, 62 void Observe(int type,
63 const content::NotificationSource& source, 63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) override; 64 const content::NotificationDetails& details) override;
65 65
66 // Observer callback for TabRestoreService::Observer to notify when a tab is 66 // Observer callback for TabRestoreService::Observer to notify when a tab is
67 // added or removed. 67 // added or removed.
68 void TabRestoreServiceChanged(TabRestoreService* service) override; 68 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override;
69 69
70 // Observer callback to notice when our associated TabRestoreService 70 // Observer callback to notice when our associated TabRestoreService
71 // is destroyed. 71 // is destroyed.
72 void TabRestoreServiceDestroyed(TabRestoreService* service) override; 72 void TabRestoreServiceDestroyed(
73 sessions::TabRestoreService* service) override;
73 74
74 // Cancel a pending jumplist update. 75 // Cancel a pending jumplist update.
75 void CancelPendingUpdate(); 76 void CancelPendingUpdate();
76 77
77 // Terminate the jumplist: cancel any pending updates and stop observing 78 // Terminate the jumplist: cancel any pending updates and stop observing
78 // the Profile and its services. This must be called before the |profile_| 79 // the Profile and its services. This must be called before the |profile_|
79 // is destroyed. 80 // is destroyed.
80 void Terminate(); 81 void Terminate();
81 82
82 // Returns true if the custom JumpList is enabled. 83 // Returns true if the custom JumpList is enabled.
83 // The custom jumplist works only on Windows 7 and above. 84 // The custom jumplist works only on Windows 7 and above.
84 static bool Enabled(); 85 static bool Enabled();
85 86
86 private: 87 private:
87 friend struct content::BrowserThread::DeleteOnThread< 88 friend struct content::BrowserThread::DeleteOnThread<
88 content::BrowserThread::UI>; 89 content::BrowserThread::UI>;
89 friend class base::DeleteHelper<JumpList>; 90 friend class base::DeleteHelper<JumpList>;
90 ~JumpList() override; 91 ~JumpList() override;
91 92
92 // Creates a ShellLinkItem object from a tab (or a window) and add it to the 93 // Creates a ShellLinkItem object from a tab (or a window) and add it to the
93 // given list. 94 // given list.
94 // These functions are copied from the RecentlyClosedTabsHandler class for 95 // These functions are copied from the RecentlyClosedTabsHandler class for
95 // compatibility with the new-tab page. 96 // compatibility with the new-tab page.
96 bool AddTab(const TabRestoreService::Tab* tab, 97 bool AddTab(const sessions::TabRestoreService::Tab* tab,
97 ShellLinkItemList* list, 98 ShellLinkItemList* list,
98 size_t max_items); 99 size_t max_items);
99 void AddWindow(const TabRestoreService::Window* window, 100 void AddWindow(const sessions::TabRestoreService::Window* window,
100 ShellLinkItemList* list, 101 ShellLinkItemList* list,
101 size_t max_items); 102 size_t max_items);
102 103
103 // Starts loading a favicon for each URL in |icon_urls_|. 104 // Starts loading a favicon for each URL in |icon_urls_|.
104 // This function sends a query to HistoryService. 105 // This function sends a query to HistoryService.
105 // When finishing loading all favicons, this function posts a task that 106 // When finishing loading all favicons, this function posts a task that
106 // decompresses collected favicons and updates a JumpList. 107 // decompresses collected favicons and updates a JumpList.
107 void StartLoadingFavicon(); 108 void StartLoadingFavicon();
108 109
109 // A callback function for HistoryService that notify when a requested favicon 110 // A callback function for HistoryService that notify when a requested favicon
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // as they may be used by up to 3 threads. 185 // as they may be used by up to 3 threads.
185 base::Lock list_lock_; 186 base::Lock list_lock_;
186 187
187 // For callbacks may be run after destruction. 188 // For callbacks may be run after destruction.
188 base::WeakPtrFactory<JumpList> weak_ptr_factory_; 189 base::WeakPtrFactory<JumpList> weak_ptr_factory_;
189 190
190 DISALLOW_COPY_AND_ASSIGN(JumpList); 191 DISALLOW_COPY_AND_ASSIGN(JumpList);
191 }; 192 };
192 193
193 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ 194 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/sessions/sessions_api.cc ('k') | chrome/browser/jumplist_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698