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

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

Issue 10868072: Make TabContents ctor private; poke hole for existing callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all green Created 8 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
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_UI_TAB_CONTENTS_TAB_CONTENTS_H_ 5 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_H_
6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_H_ 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 13
14 class AlternateErrorPageTabObserver; 14 class AlternateErrorPageTabObserver;
15 class AutocompleteHistoryManager; 15 class AutocompleteHistoryManager;
16 class AutofillManager; 16 class AutofillManager;
17 class AutofillExternalDelegate; 17 class AutofillExternalDelegate;
18 class AutomationTabHelper; 18 class AutomationTabHelper;
19 class BasePanelBrowserTest;
19 class BlockedContentTabHelper; 20 class BlockedContentTabHelper;
20 class BookmarkTabHelper; 21 class BookmarkTabHelper;
22 class Browser;
23 class BrowserCommandsTabContentsCreator;
24 class BrowserLauncherItemControllerContentsCreator;
25 class BrowserTabstripTabContentsCreator;
26 class ChromeWebContentsHandler;
27 class ConstrainedWebDialogDelegateBase;
21 class ConstrainedWindowTabHelper; 28 class ConstrainedWindowTabHelper;
22 class CoreTabHelper; 29 class CoreTabHelper;
30 class ExtensionTabUtil;
23 class ExternalProtocolObserver; 31 class ExternalProtocolObserver;
32 class ExternalTabContainerWin;
24 class FaviconTabHelper; 33 class FaviconTabHelper;
34 class FindBackendTestContentsCreator;
25 class FindTabHelper; 35 class FindTabHelper;
36 class GeolocationPermissionContextTests;
26 class HistoryTabHelper; 37 class HistoryTabHelper;
27 class HungPluginTabHelper; 38 class HungPluginTabHelper;
39 class InfoBarControllerContentsCreator;
28 class InfoBarTabHelper; 40 class InfoBarTabHelper;
41 class InstantLoader;
29 class MetroPinTabHelper; 42 class MetroPinTabHelper;
30 class NavigationMetricsRecorder; 43 class NavigationMetricsRecorder;
44 class OffscreenTabContentsCreator;
45 class OldBasePanelBrowserTest;
31 class OmniboxSearchHint; 46 class OmniboxSearchHint;
32 class PasswordManager; 47 class PasswordManager;
33 class PasswordManagerDelegate; 48 class PasswordManagerDelegate;
34 class PDFTabObserver; 49 class PDFTabObserver;
35 class PluginObserver; 50 class PluginObserver;
36 class PrefsTabHelper; 51 class PrefsTabHelper;
37 class Profile; 52 class Profile;
38 class RestoreTabHelper; 53 class RestoreTabHelper;
39 class SadTabHelper; 54 class SadTabHelper;
40 class SearchEngineTabHelper; 55 class SearchEngineTabHelper;
56 class ShellWindow;
41 class SnapshotTabHelper; 57 class SnapshotTabHelper;
42 class TabContentsSSLHelper; 58 class TabContentsSSLHelper;
59 class TabContentsTestHarness;
43 class TabSpecificContentSettings; 60 class TabSpecificContentSettings;
61 class TabStripModel;
62 class TabStripModelContentsCreator;
44 class ThumbnailGenerator; 63 class ThumbnailGenerator;
45 class TranslateTabHelper; 64 class TranslateTabHelper;
65 class TranslationInfoBarTestContentsCreator;
66 class WebDialogGtk;
67 class WebDialogWindowControllerTabContentsCreator;
68 class WebIntentInlineDispositionBrowserTest;
69 class WebIntentPickerCocoa;
46 class WebIntentPickerController; 70 class WebIntentPickerController;
71 class WebIntentPickerGtk;
72 class WebUITestContentsCreator;
47 class ZoomController; 73 class ZoomController;
48 74
49 #if defined(ENABLE_ONE_CLICK_SIGNIN) 75 #if defined(ENABLE_ONE_CLICK_SIGNIN)
50 class OneClickSigninHelper; 76 class OneClickSigninHelper;
51 #endif 77 #endif
52 78
53 namespace browser_sync { 79 namespace browser_sync {
54 class SyncedTabDelegate; 80 class SyncedTabDelegate;
55 } 81 }
56 82
57 namespace captive_portal { 83 namespace captive_portal {
58 class CaptivePortalTabHelper; 84 class CaptivePortalTabHelper;
59 } 85 }
60 86
61 namespace chrome { 87 namespace chrome {
62 namespace search { 88 namespace search {
63 class SearchTabHelper; 89 class SearchTabHelper;
64 } 90 }
65 } 91 }
66 92
67 namespace chrome_browser_net { 93 namespace chrome_browser_net {
68 class LoadTimeStatsTabHelper; 94 class LoadTimeStatsTabHelper;
69 } 95 }
70 96
97 namespace chromeos {
98 class SimpleWebViewDialog;
99 class WebUILoginView;
100 }
101
71 namespace extensions { 102 namespace extensions {
72 class TabHelper; 103 class TabHelper;
104 class WebAuthFlow;
73 class WebNavigationTabObserver; 105 class WebNavigationTabObserver;
74 } 106 }
75 107
76 namespace prerender { 108 namespace prerender {
109 class PrerenderContents;
77 class PrerenderTabHelper; 110 class PrerenderTabHelper;
78 } 111 }
79 112
80 namespace printing { 113 namespace printing {
81 class PrintViewManager; 114 class PrintViewManager;
82 class PrintPreviewMessageHandler; 115 class PrintPreviewMessageHandler;
83 } 116 }
84 117
85 namespace safe_browsing { 118 namespace safe_browsing {
86 class SafeBrowsingTabObserver; 119 class SafeBrowsingTabObserver;
87 } 120 }
88 121
89 // Wraps WebContents and all of its supporting objects in order to control 122 // Wraps WebContents and all of its supporting objects in order to control
90 // their ownership and lifetime. 123 // their ownership and lifetime.
91 // 124 //
92 // WARNING: Not every place where HTML can run has a TabContents. This class is 125 // WARNING: Not every place where HTML can run has a TabContents. This class is
93 // *only* used in a visible, actual, tab inside a browser. Examples of things 126 // *only* used in a visible, actual, tab inside a browser. Examples of things
94 // that do not have a TabContents include: 127 // that do not have a TabContents include:
95 // - Extension background pages and popup bubbles 128 // - Extension background pages and popup bubbles
96 // - HTML notification bubbles 129 // - HTML notification bubbles
97 // - Screensavers on Chrome OS 130 // - Screensavers on Chrome OS
98 // - Other random places we decide to display HTML over time 131 // - Other random places we decide to display HTML over time
99 // 132 //
100 // Consider carefully whether your feature is something that makes sense only 133 // Consider carefully whether your feature is something that makes sense only
101 // when a tab is displayed, or could make sense in other cases we use HTML. It 134 // when a tab is displayed, or could make sense in other cases we use HTML. It
102 // may makes sense to push down into WebContents and make configurable, or at 135 // may makes sense to push down into WebContents and make configurable, or at
103 // least to make easy for other WebContents hosts to include and support. 136 // least to make easy for other WebContents hosts to include and support.
104 class TabContents : public content::WebContentsObserver { 137 class TabContents : public content::WebContentsObserver {
105 public: 138 public:
106 // Takes ownership of |contents|, which must be heap-allocated (as it lives 139 class Factory {
107 // in a scoped_ptr) and can not be NULL. 140 private:
108 explicit TabContents(content::WebContents* contents); 141 // TabContents is going away <http://crbug.com/107201> so don't allow any
142 // more code to construct instances. Explicitly befriend those who currently
143 // do so.
144
145 friend class BasePanelBrowserTest;
146 friend class Browser;
147 friend class BrowserCommandsTabContentsCreator;
148 friend class BrowserLauncherItemControllerContentsCreator;
149 friend class BrowserTabstripTabContentsCreator;
150 friend class chromeos::SimpleWebViewDialog;
151 friend class chromeos::WebUILoginView;
152 friend class ChromeWebContentsHandler;
153 friend class ConstrainedWebDialogDelegateBase;
154 friend class extensions::WebAuthFlow;
155 friend class ExtensionTabUtil;
156 friend class ExternalTabContainerWin;
157 friend class FindBackendTestContentsCreator;
158 friend class GeolocationPermissionContextTests;
159 friend class InfoBarControllerContentsCreator;
160 friend class InstantLoader;
161 friend class OldBasePanelBrowserTest;
162 friend class OffscreenTabContentsCreator;
163 friend class prerender::PrerenderContents;
164 friend class ShellWindow;
165 friend class TabContentsTestHarness;
166 friend class TabStripModel;
167 friend class TabStripModelContentsCreator;
168 friend class TranslationInfoBarTestContentsCreator;
169 friend class WebDialogGtk;
170 friend class WebDialogWindowControllerTabContentsCreator;
171 friend class WebIntentInlineDispositionBrowserTest;
172 friend class WebIntentPickerCocoa;
173 friend class WebIntentPickerGtk;
174 friend class WebUITestContentsCreator;
175
176 static TabContents* CreateTabContents(content::WebContents* contents);
177 static TabContents* CloneTabContents(TabContents* contents);
178 };
179
109 virtual ~TabContents(); 180 virtual ~TabContents();
110 181
111 // Create a TabContents with the same state as this one. The returned
112 // heap-allocated pointer is owned by the caller.
113 TabContents* Clone();
114
115 // Helper to retrieve the existing instance that owns a given WebContents. 182 // Helper to retrieve the existing instance that owns a given WebContents.
116 // Returns NULL if there is no such existing instance. 183 // Returns NULL if there is no such existing instance.
117 // NOTE: This is not intended for general use. It is intended for situations 184 // NOTE: This is not intended for general use. It is intended for situations
118 // like callbacks from content/ where only a WebContents is available. In the 185 // like callbacks from content/ where only a WebContents is available. In the
119 // general case, please do NOT use this; plumb TabContents through the chrome/ 186 // general case, please do NOT use this; plumb TabContents through the chrome/
120 // code instead of WebContents. 187 // code instead of WebContents.
121 static TabContents* FromWebContents(content::WebContents* contents); 188 static TabContents* FromWebContents(content::WebContents* contents);
122 static const TabContents* FromWebContents( 189 static const TabContents* FromWebContents(
123 const content::WebContents* contents); 190 const content::WebContents* contents);
124 191
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return zoom_controller_.get(); 317 return zoom_controller_.get();
251 } 318 }
252 319
253 // Overrides ----------------------------------------------------------------- 320 // Overrides -----------------------------------------------------------------
254 321
255 // content::WebContentsObserver overrides: 322 // content::WebContentsObserver overrides:
256 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; 323 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
257 virtual void UserAgentOverrideSet(const std::string& user_agent) OVERRIDE; 324 virtual void UserAgentOverrideSet(const std::string& user_agent) OVERRIDE;
258 325
259 private: 326 private:
327 friend class TabContentsFactory;
328
329 // Takes ownership of |contents|, which must be heap-allocated (as it lives
330 // in a scoped_ptr) and can not be NULL.
331 explicit TabContents(content::WebContents* contents);
332
333 // Create a TabContents with the same state as this one. The returned
334 // heap-allocated pointer is owned by the caller.
335 TabContents* Clone();
336
260 // Tab Helpers --------------------------------------------------------------- 337 // Tab Helpers ---------------------------------------------------------------
261 // (These provide API for callers and have a getter function listed in the 338 // (These provide API for callers and have a getter function listed in the
262 // "Tab Helpers" section in the member functions area, above.) 339 // "Tab Helpers" section in the member functions area, above.)
263 340
264 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; 341 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
265 scoped_refptr<AutofillManager> autofill_manager_; 342 scoped_refptr<AutofillManager> autofill_manager_;
266 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; 343 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_;
267 scoped_ptr<AutomationTabHelper> automation_tab_helper_; 344 scoped_ptr<AutomationTabHelper> automation_tab_helper_;
268 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; 345 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_;
269 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; 346 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 415
339 // The supporting objects need to outlive the WebContents dtor (as they may 416 // The supporting objects need to outlive the WebContents dtor (as they may
340 // be called upon during its execution). As a result, this must come last 417 // be called upon during its execution). As a result, this must come last
341 // in the list. 418 // in the list.
342 scoped_ptr<content::WebContents> web_contents_; 419 scoped_ptr<content::WebContents> web_contents_;
343 420
344 DISALLOW_COPY_AND_ASSIGN(TabContents); 421 DISALLOW_COPY_AND_ASSIGN(TabContents);
345 }; 422 };
346 423
347 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_H_ 424 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/old_base_panel_browser_test.cc ('k') | chrome/browser/ui/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698