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

Side by Side Diff: chrome/browser/ui/tab_contents/tab_contents_wrapper.h

Issue 8865004: Create CoreTabHelper, move remaining core TCW functionality into it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
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_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ 5 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_
6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "chrome/browser/prefs/pref_change_registrar.h" 16 #include "chrome/browser/prefs/pref_change_registrar.h"
17 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/browser/tab_contents/tab_contents_observer.h" 18 #include "content/browser/tab_contents/tab_contents_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 20
21 class AutocompleteHistoryManager; 21 class AutocompleteHistoryManager;
22 class AutofillManager; 22 class AutofillManager;
23 class AutofillExternalDelegate; 23 class AutofillExternalDelegate;
24 class AutomationTabHelper; 24 class AutomationTabHelper;
25 class BlockedContentTabHelper; 25 class BlockedContentTabHelper;
26 class BookmarkTabHelper; 26 class BookmarkTabHelper;
27 class ConstrainedWindowTabHelper; 27 class ConstrainedWindowTabHelper;
28 class CoreTabHelper;
28 class DownloadRequestLimiterObserver; 29 class DownloadRequestLimiterObserver;
29 class ExtensionTabHelper; 30 class ExtensionTabHelper;
30 class ExtensionWebNavigationTabObserver; 31 class ExtensionWebNavigationTabObserver;
31 class ExternalProtocolObserver; 32 class ExternalProtocolObserver;
32 class FaviconTabHelper; 33 class FaviconTabHelper;
33 class FindTabHelper; 34 class FindTabHelper;
34 class HistoryTabHelper; 35 class HistoryTabHelper;
35 class InfoBarTabHelper; 36 class InfoBarTabHelper;
36 class OmniboxSearchHint; 37 class OmniboxSearchHint;
37 class PasswordManager; 38 class PasswordManager;
38 class PasswordManagerDelegate; 39 class PasswordManagerDelegate;
39 class PluginObserver; 40 class PluginObserver;
40 class PrefService; 41 class PrefService;
41 class PrefsTabHelper; 42 class PrefsTabHelper;
42 class Profile; 43 class Profile;
43 class RestoreTabHelper; 44 class RestoreTabHelper;
44 class SadTabObserver; 45 class SadTabObserver;
45 class SearchEngineTabHelper; 46 class SearchEngineTabHelper;
46 class TabContentsSSLHelper; 47 class TabContentsSSLHelper;
47 class TabContentsWrapperDelegate;
48 class TabContentsWrapperSyncedTabDelegate; 48 class TabContentsWrapperSyncedTabDelegate;
49 class TabSpecificContentSettings; 49 class TabSpecificContentSettings;
50 class ThumbnailGenerator; 50 class ThumbnailGenerator;
51 class TranslateTabHelper; 51 class TranslateTabHelper;
52 class WebIntentPickerController; 52 class WebIntentPickerController;
53 53
54 namespace IPC { 54 namespace IPC {
55 class Message; 55 class Message;
56 } 56 }
57 57
(...skipping 21 matching lines...) Expand all
79 public: 79 public:
80 // Takes ownership of |contents|, which must be heap-allocated (as it lives 80 // Takes ownership of |contents|, which must be heap-allocated (as it lives
81 // in a scoped_ptr) and can not be NULL. 81 // in a scoped_ptr) and can not be NULL.
82 explicit TabContentsWrapper(TabContents* contents); 82 explicit TabContentsWrapper(TabContents* contents);
83 virtual ~TabContentsWrapper(); 83 virtual ~TabContentsWrapper();
84 84
85 // Used to retrieve this object from |tab_contents_|, which is placed in 85 // Used to retrieve this object from |tab_contents_|, which is placed in
86 // its property bag to avoid adding additional interfaces. 86 // its property bag to avoid adding additional interfaces.
87 static base::PropertyAccessor<TabContentsWrapper*>* property_accessor(); 87 static base::PropertyAccessor<TabContentsWrapper*>* property_accessor();
88 88
89 static void RegisterUserPrefs(PrefService* prefs);
90
91 // Initial title assigned to NavigationEntries from Navigate.
92 static string16 GetDefaultTitle();
93
94 // Returns a human-readable description the tab's loading state.
95 string16 GetStatusText() const;
96
97 // Create a TabContentsWrapper with the same state as this one. The returned 89 // Create a TabContentsWrapper with the same state as this one. The returned
98 // heap-allocated pointer is owned by the caller. 90 // heap-allocated pointer is owned by the caller.
99 TabContentsWrapper* Clone(); 91 TabContentsWrapper* Clone();
100 92
101 // Captures a snapshot of the page.
102 void CaptureSnapshot();
103
104 // Stop this tab rendering in fullscreen mode.
105 void ExitFullscreenMode();
106
107 // Helper to retrieve the existing instance that wraps a given TabContents. 93 // Helper to retrieve the existing instance that wraps a given TabContents.
108 // Returns NULL if there is no such existing instance. 94 // Returns NULL if there is no such existing instance.
109 // NOTE: This is not intended for general use. It is intended for situations 95 // NOTE: This is not intended for general use. It is intended for situations
110 // like callbacks from content/ where only a TabContents is available. In the 96 // like callbacks from content/ where only a TabContents is available. In the
111 // general case, please do NOT use this; plumb TabContentsWrapper through the 97 // general case, please do NOT use this; plumb TabContentsWrapper through the
112 // chrome/ code instead of TabContents. 98 // chrome/ code instead of TabContents.
113 static TabContentsWrapper* GetCurrentWrapperForContents( 99 static TabContentsWrapper* GetCurrentWrapperForContents(
114 TabContents* contents); 100 TabContents* contents);
115 static const TabContentsWrapper* GetCurrentWrapperForContents( 101 static const TabContentsWrapper* GetCurrentWrapperForContents(
116 const TabContents* contents); 102 const TabContents* contents);
117 103
118 TabContentsWrapperDelegate* delegate() const { return delegate_; }
119 void set_delegate(TabContentsWrapperDelegate* d) { delegate_ = d; }
120
121 TabContents* tab_contents() const { return tab_contents_.get(); } 104 TabContents* tab_contents() const { return tab_contents_.get(); }
122 NavigationController& controller() const { 105 NavigationController& controller() const {
123 return tab_contents()->controller(); 106 return tab_contents()->controller();
124 } 107 }
125 TabContentsView* view() const { return tab_contents()->view(); } 108 TabContentsView* view() const { return tab_contents()->view(); }
126 RenderViewHost* render_view_host() const { 109 RenderViewHost* render_view_host() const {
127 return tab_contents()->render_view_host(); 110 return tab_contents()->render_view_host();
128 } 111 }
129 WebUI* web_ui() const { return tab_contents()->web_ui(); } 112 WebUI* web_ui() const { return tab_contents()->web_ui(); }
130 113
(...skipping 17 matching lines...) Expand all
148 } 131 }
149 132
150 BookmarkTabHelper* bookmark_tab_helper() { 133 BookmarkTabHelper* bookmark_tab_helper() {
151 return bookmark_tab_helper_.get(); 134 return bookmark_tab_helper_.get();
152 } 135 }
153 136
154 ConstrainedWindowTabHelper* constrained_window_tab_helper() { 137 ConstrainedWindowTabHelper* constrained_window_tab_helper() {
155 return constrained_window_tab_helper_.get(); 138 return constrained_window_tab_helper_.get();
156 } 139 }
157 140
141 CoreTabHelper* core_tab_helper() { return core_tab_helper_.get(); }
142
158 ExtensionTabHelper* extension_tab_helper() { 143 ExtensionTabHelper* extension_tab_helper() {
159 return extension_tab_helper_.get(); 144 return extension_tab_helper_.get();
160 } 145 }
161 146
162 const ExtensionTabHelper* extension_tab_helper() const { 147 const ExtensionTabHelper* extension_tab_helper() const {
163 return extension_tab_helper_.get(); 148 return extension_tab_helper_.get();
164 } 149 }
165 150
166 FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); } 151 FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); }
167 FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); } 152 FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return translate_tab_helper_.get(); 193 return translate_tab_helper_.get();
209 } 194 }
210 195
211 WebIntentPickerController* web_intent_picker_controller() { 196 WebIntentPickerController* web_intent_picker_controller() {
212 return web_intent_picker_controller_.get(); 197 return web_intent_picker_controller_.get();
213 } 198 }
214 199
215 // Overrides ----------------------------------------------------------------- 200 // Overrides -----------------------------------------------------------------
216 201
217 // TabContentsObserver overrides: 202 // TabContentsObserver overrides:
218 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
219 virtual void DidBecomeSelected() OVERRIDE;
220 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
221 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; 203 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE;
222 204
223 // content::NotificationObserver overrides: 205 // content::NotificationObserver overrides:
224 virtual void Observe(int type, 206 virtual void Observe(int type,
225 const content::NotificationSource& source, 207 const content::NotificationSource& source,
226 const content::NotificationDetails& details) OVERRIDE; 208 const content::NotificationDetails& details) OVERRIDE;
227 209
228 private: 210 private:
229 FRIEND_TEST_ALL_PREFIXES( 211 FRIEND_TEST_ALL_PREFIXES(
230 PrefsTabHelperTest, OverridePrefsOnViewCreation); 212 PrefsTabHelperTest, OverridePrefsOnViewCreation);
231 213
232 // Internal helpers ---------------------------------------------------------- 214 // Internal helpers ----------------------------------------------------------
233 215
234 // Message handlers.
235 void OnSnapshot(const SkBitmap& bitmap);
236 void OnPDFHasUnsupportedFeature();
237
238 // Returns the server that can provide alternate error pages. If the returned
239 // URL is empty, the default error page built into WebKit will be used.
240 GURL GetAlternateErrorPageURL() const;
241
242 // Send the alternate error page URL to the renderer.
243 void UpdateAlternateErrorPageURL(RenderViewHost* rvh);
244
245 // Create or destroy SafebrowsingDetectionHost as needed if the user's 216 // Create or destroy SafebrowsingDetectionHost as needed if the user's
246 // safe browsing preference has changed. 217 // safe browsing preference has changed.
247 void UpdateSafebrowsingDetectionHost(); 218 void UpdateSafebrowsingDetectionHost();
248 219
249 // Data for core operation --------------------------------------------------- 220 // Data for core operation ---------------------------------------------------
250 221
251 // Delegate for notifying our owner about stuff. Not owned by us.
252 TabContentsWrapperDelegate* delegate_;
253
254 content::NotificationRegistrar registrar_; 222 content::NotificationRegistrar registrar_;
255 PrefChangeRegistrar pref_change_registrar_; 223 PrefChangeRegistrar pref_change_registrar_;
256 224
257 // Data for current page ----------------------------------------------------- 225 // Data for current page -----------------------------------------------------
258 226
259 // Shows an info-bar to users when they search from a known search engine and 227 // Shows an info-bar to users when they search from a known search engine and
260 // have never used the omnibox for search before. 228 // have never used the omnibox for search before.
261 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_; 229 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_;
262 230
263 // Tab Helpers --------------------------------------------------------------- 231 // Tab Helpers ---------------------------------------------------------------
264 // (These provide API for callers and have a getter function listed in the 232 // (These provide API for callers and have a getter function listed in the
265 // "Tab Helpers" section in the member functions area, above.) 233 // "Tab Helpers" section in the member functions area, above.)
266 234
267 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; 235 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
268 scoped_refptr<AutofillManager> autofill_manager_; 236 scoped_refptr<AutofillManager> autofill_manager_;
269 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; 237 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_;
270 scoped_ptr<AutomationTabHelper> automation_tab_helper_; 238 scoped_ptr<AutomationTabHelper> automation_tab_helper_;
271 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; 239 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_;
272 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; 240 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_;
273 scoped_ptr<ConstrainedWindowTabHelper> constrained_window_tab_helper_; 241 scoped_ptr<ConstrainedWindowTabHelper> constrained_window_tab_helper_;
242 scoped_ptr<CoreTabHelper> core_tab_helper_;
274 scoped_ptr<ExtensionTabHelper> extension_tab_helper_; 243 scoped_ptr<ExtensionTabHelper> extension_tab_helper_;
275 scoped_ptr<FaviconTabHelper> favicon_tab_helper_; 244 scoped_ptr<FaviconTabHelper> favicon_tab_helper_;
276 scoped_ptr<FindTabHelper> find_tab_helper_; 245 scoped_ptr<FindTabHelper> find_tab_helper_;
277 scoped_ptr<HistoryTabHelper> history_tab_helper_; 246 scoped_ptr<HistoryTabHelper> history_tab_helper_;
278 scoped_ptr<InfoBarTabHelper> infobar_tab_helper_; 247 scoped_ptr<InfoBarTabHelper> infobar_tab_helper_;
279 248
280 // PasswordManager and its delegate. The delegate must outlive the manager, 249 // PasswordManager and its delegate. The delegate must outlive the manager,
281 // per documentation in password_manager.h. 250 // per documentation in password_manager.h.
282 scoped_ptr<PasswordManagerDelegate> password_manager_delegate_; 251 scoped_ptr<PasswordManagerDelegate> password_manager_delegate_;
283 scoped_ptr<PasswordManager> password_manager_; 252 scoped_ptr<PasswordManager> password_manager_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 295
327 // The supporting objects need to outlive the TabContents dtor (as they may 296 // The supporting objects need to outlive the TabContents dtor (as they may
328 // be called upon during its execution). As a result, this must come last 297 // be called upon during its execution). As a result, this must come last
329 // in the list. 298 // in the list.
330 scoped_ptr<TabContents> tab_contents_; 299 scoped_ptr<TabContents> tab_contents_;
331 300
332 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); 301 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper);
333 }; 302 };
334 303
335 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ 304 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698