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

Side by Side Diff: chrome/browser/sessions/tab_restore_service_helper.h

Issue 1321713005: Abstract WebContents/NavigationController from core TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_ 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_
6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_ 6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/sessions/tab_restore_service.h" 14 #include "chrome/browser/sessions/tab_restore_service.h"
15 #include "components/sessions/session_id.h" 15 #include "components/sessions/session_id.h"
16 #include "components/sessions/session_types.h" 16 #include "components/sessions/session_types.h"
17 17
18 class TabRestoreService; 18 class TabRestoreService;
19 class TabRestoreServiceDelegate; 19 class TabRestoreServiceDelegate;
20 class TabRestoreServiceObserver; 20 class TabRestoreServiceObserver;
21 class TimeFactory; 21 class TimeFactory;
22 22
23 namespace content {
24 class NavigationController;
25 class WebContents;
26 }
27
28 namespace sessions { 23 namespace sessions {
29 class TabRestoreServiceClient; 24 class TabRestoreServiceClient;
30 } 25 }
31 26
32 // Helper class used to implement InMemoryTabRestoreService and 27 // Helper class used to implement InMemoryTabRestoreService and
33 // PersistentTabRestoreService. See tab_restore_service.h for method-level 28 // PersistentTabRestoreService. See tab_restore_service.h for method-level
34 // comments. 29 // comments.
35 class TabRestoreServiceHelper { 30 class TabRestoreServiceHelper {
36 public: 31 public:
37 typedef TabRestoreService::Entries Entries; 32 typedef TabRestoreService::Entries Entries;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 TabRestoreServiceHelper(TabRestoreService* tab_restore_service, 65 TabRestoreServiceHelper(TabRestoreService* tab_restore_service,
71 Observer* observer, 66 Observer* observer,
72 sessions::TabRestoreServiceClient* client, 67 sessions::TabRestoreServiceClient* client,
73 TimeFactory* time_factory); 68 TimeFactory* time_factory);
74 69
75 ~TabRestoreServiceHelper(); 70 ~TabRestoreServiceHelper();
76 71
77 // Helper methods used to implement TabRestoreService. 72 // Helper methods used to implement TabRestoreService.
78 void AddObserver(TabRestoreServiceObserver* observer); 73 void AddObserver(TabRestoreServiceObserver* observer);
79 void RemoveObserver(TabRestoreServiceObserver* observer); 74 void RemoveObserver(TabRestoreServiceObserver* observer);
80 void CreateHistoricalTab(content::WebContents* contents, int index); 75 void CreateHistoricalTab(sessions::LiveTab* live_tab, int index);
81 void BrowserClosing(TabRestoreServiceDelegate* delegate); 76 void BrowserClosing(TabRestoreServiceDelegate* delegate);
82 void BrowserClosed(TabRestoreServiceDelegate* delegate); 77 void BrowserClosed(TabRestoreServiceDelegate* delegate);
83 void ClearEntries(); 78 void ClearEntries();
84 const Entries& entries() const; 79 const Entries& entries() const;
85 std::vector<content::WebContents*> RestoreMostRecentEntry( 80 std::vector<sessions::LiveTab*> RestoreMostRecentEntry(
86 TabRestoreServiceDelegate* delegate, 81 TabRestoreServiceDelegate* delegate,
87 int host_desktop_type); 82 int host_desktop_type);
88 Tab* RemoveTabEntryById(SessionID::id_type id); 83 Tab* RemoveTabEntryById(SessionID::id_type id);
89 std::vector<content::WebContents*> RestoreEntryById( 84 std::vector<sessions::LiveTab*> RestoreEntryById(
90 TabRestoreServiceDelegate* delegate, 85 TabRestoreServiceDelegate* delegate,
91 SessionID::id_type id, 86 SessionID::id_type id,
92 int host_desktop_type, 87 int host_desktop_type,
93 WindowOpenDisposition disposition); 88 WindowOpenDisposition disposition);
94 89
95 // Notifies observers the tabs have changed. 90 // Notifies observers the tabs have changed.
96 void NotifyTabsChanged(); 91 void NotifyTabsChanged();
97 92
98 // Notifies observers the service has loaded. 93 // Notifies observers the service has loaded.
99 void NotifyLoaded(); 94 void NotifyLoaded();
(...skipping 13 matching lines...) Expand all
113 // identifies a tab, then the iterator position of the Window in which the Tab 108 // identifies a tab, then the iterator position of the Window in which the Tab
114 // resides is returned. 109 // resides is returned.
115 Entries::iterator GetEntryIteratorById(SessionID::id_type id); 110 Entries::iterator GetEntryIteratorById(SessionID::id_type id);
116 111
117 // Calls either ValidateTab or ValidateWindow as appropriate. 112 // Calls either ValidateTab or ValidateWindow as appropriate.
118 static bool ValidateEntry(Entry* entry); 113 static bool ValidateEntry(Entry* entry);
119 114
120 private: 115 private:
121 friend class PersistentTabRestoreService; 116 friend class PersistentTabRestoreService;
122 117
123 // Populates the tab's navigations from the NavigationController, and its 118 // Populates the tab's navigations from the LiveTab, and its browser_id and
124 // browser_id and pinned state from the browser. 119 // pinned state from the delegate.
125 void PopulateTab(Tab* tab, 120 void PopulateTab(Tab* tab,
126 int index, 121 int index,
127 TabRestoreServiceDelegate* delegate, 122 TabRestoreServiceDelegate* delegate,
128 content::NavigationController* controller); 123 sessions::LiveTab* live_tab);
129 124
130 // This is a helper function for RestoreEntryById() for restoring a single 125 // This is a helper function for RestoreEntryById() for restoring a single
131 // tab. If |delegate| is NULL, this creates a new window for the entry. This 126 // tab. If |delegate| is NULL, this creates a new window for the entry. This
132 // returns the TabRestoreServiceDelegate into which the tab was restored. 127 // returns the TabRestoreServiceDelegate into which the tab was restored.
133 // |disposition| will be respected, but if it is UNKNOWN then the tab's 128 // |disposition| will be respected, but if it is UNKNOWN then the tab's
134 // original attributes will be respected instead. If a new 129 // original attributes will be respected instead. If a new
135 // TabRestoreServiceDelegate needs to be created for this tab, 130 // TabRestoreServiceDelegate needs to be created for this tab,
136 // |host_desktop_type| will be passed to 131 // |host_desktop_type| will be passed to
137 // TabRestoreServiceClient::CreateTabRestoreServiceDelegate(). If present, 132 // TabRestoreServiceClient::CreateTabRestoreServiceDelegate(). If present,
138 // |contents| will be populated with the WebContents of the restored tab. 133 // |live_tab| will be populated with the LiveTab of the restored tab.
139 TabRestoreServiceDelegate* RestoreTab(const Tab& tab, 134 TabRestoreServiceDelegate* RestoreTab(const Tab& tab,
140 TabRestoreServiceDelegate* delegate, 135 TabRestoreServiceDelegate* delegate,
141 int host_desktop_type, 136 int host_desktop_type,
142 WindowOpenDisposition disposition, 137 WindowOpenDisposition disposition,
143 content::WebContents** contents); 138 sessions::LiveTab** live_tab);
144 139
145 // Returns true if |tab| has more than one navigation. If |tab| has more 140 // Returns true if |tab| has more than one navigation. If |tab| has more
146 // than one navigation |tab->current_navigation_index| is constrained based 141 // than one navigation |tab->current_navigation_index| is constrained based
147 // on the number of navigations. 142 // on the number of navigations.
148 static bool ValidateTab(Tab* tab); 143 static bool ValidateTab(Tab* tab);
149 144
150 // Validates all the tabs in a window, plus the window's active tab index. 145 // Validates all the tabs in a window, plus the window's active tab index.
151 static bool ValidateWindow(Window* window); 146 static bool ValidateWindow(Window* window);
152 147
153 // Returns true if |tab| is one we care about restoring. 148 // Returns true if |tab| is one we care about restoring.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // corresponding BrowserClosed. We cache the set of delegates closing to 181 // corresponding BrowserClosed. We cache the set of delegates closing to
187 // avoid creating historical tabs for them. 182 // avoid creating historical tabs for them.
188 std::set<TabRestoreServiceDelegate*> closing_delegates_; 183 std::set<TabRestoreServiceDelegate*> closing_delegates_;
189 184
190 TimeFactory* const time_factory_; 185 TimeFactory* const time_factory_;
191 186
192 DISALLOW_COPY_AND_ASSIGN(TabRestoreServiceHelper); 187 DISALLOW_COPY_AND_ASSIGN(TabRestoreServiceHelper);
193 }; 188 };
194 189
195 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_ 190 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service_delegate.h ('k') | chrome/browser/sessions/tab_restore_service_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698