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

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

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 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 | 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>
(...skipping 14 matching lines...) Expand all
25 class BookmarkTabHelper; 25 class BookmarkTabHelper;
26 class DownloadRequestLimiterObserver; 26 class DownloadRequestLimiterObserver;
27 class Extension; 27 class Extension;
28 class ExtensionTabHelper; 28 class ExtensionTabHelper;
29 class ExtensionWebNavigationTabObserver; 29 class ExtensionWebNavigationTabObserver;
30 class ExternalProtocolObserver; 30 class ExternalProtocolObserver;
31 class FaviconTabHelper; 31 class FaviconTabHelper;
32 class FileSelectObserver; 32 class FileSelectObserver;
33 class FindTabHelper; 33 class FindTabHelper;
34 class FirewallTraversalObserver; 34 class FirewallTraversalObserver;
35 class InfoBarDelegate; 35 class InfoBarTabHelper;
36 class HistoryTabHelper; 36 class HistoryTabHelper;
37 class NavigationController; 37 class NavigationController;
38 class OmniboxSearchHint; 38 class OmniboxSearchHint;
39 class PasswordManager; 39 class PasswordManager;
40 class PasswordManagerDelegate; 40 class PasswordManagerDelegate;
41 class PluginObserver; 41 class PluginObserver;
42 class Profile; 42 class Profile;
43 class RestoreTabHelper; 43 class RestoreTabHelper;
44 class SearchEngineTabHelper; 44 class SearchEngineTabHelper;
45 class TabContentsSSLHelper; 45 class TabContentsSSLHelper;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Returns a human-readable description the tab's loading state. 96 // Returns a human-readable description the tab's loading state.
97 string16 GetStatusText() const; 97 string16 GetStatusText() const;
98 98
99 // Create a TabContentsWrapper with the same state as this one. The returned 99 // Create a TabContentsWrapper with the same state as this one. The returned
100 // heap-allocated pointer is owned by the caller. 100 // heap-allocated pointer is owned by the caller.
101 TabContentsWrapper* Clone(); 101 TabContentsWrapper* Clone();
102 102
103 // Captures a snapshot of the page. 103 // Captures a snapshot of the page.
104 void CaptureSnapshot(); 104 void CaptureSnapshot();
105 105
106 // Stop this tab rendering in fullscreen mode.
107 void ExitFullscreenMode();
108
106 // Helper to retrieve the existing instance that wraps a given TabContents. 109 // Helper to retrieve the existing instance that wraps a given TabContents.
107 // Returns NULL if there is no such existing instance. 110 // Returns NULL if there is no such existing instance.
108 // NOTE: This is not intended for general use. It is intended for situations 111 // NOTE: This is not intended for general use. It is intended for situations
109 // like callbacks from content/ where only a TabContents is available. In the 112 // like callbacks from content/ where only a TabContents is available. In the
110 // general case, please do NOT use this; plumb TabContentsWrapper through the 113 // general case, please do NOT use this; plumb TabContentsWrapper through the
111 // chrome/ code instead of TabContents. 114 // chrome/ code instead of TabContents.
112 static TabContentsWrapper* GetCurrentWrapperForContents( 115 static TabContentsWrapper* GetCurrentWrapperForContents(
113 TabContents* contents); 116 TabContents* contents);
114 static const TabContentsWrapper* GetCurrentWrapperForContents( 117 static const TabContentsWrapper* GetCurrentWrapperForContents(
115 const TabContents* contents); 118 const TabContents* contents);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return extension_tab_helper_.get(); 161 return extension_tab_helper_.get();
159 } 162 }
160 163
161 const ExtensionTabHelper* extension_tab_helper() const { 164 const ExtensionTabHelper* extension_tab_helper() const {
162 return extension_tab_helper_.get(); 165 return extension_tab_helper_.get();
163 } 166 }
164 167
165 FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); } 168 FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); }
166 FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); } 169 FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); }
167 HistoryTabHelper* history_tab_helper() { return history_tab_helper_.get(); } 170 HistoryTabHelper* history_tab_helper() { return history_tab_helper_.get(); }
171 InfoBarTabHelper* infobar_tab_helper() { return infobar_tab_helper_.get(); }
168 PasswordManager* password_manager() { return password_manager_.get(); } 172 PasswordManager* password_manager() { return password_manager_.get(); }
169 173
170 prerender::PrerenderTabHelper* prerender_tab_helper() { 174 prerender::PrerenderTabHelper* prerender_tab_helper() {
171 return prerender_tab_helper_.get(); 175 return prerender_tab_helper_.get();
172 } 176 }
173 177
174 printing::PrintViewManager* print_view_manager() { 178 printing::PrintViewManager* print_view_manager() {
175 return print_view_manager_.get(); 179 return print_view_manager_.get();
176 } 180 }
177 181
(...skipping 30 matching lines...) Expand all
208 virtual void RenderViewGone() OVERRIDE; 212 virtual void RenderViewGone() OVERRIDE;
209 virtual void DidBecomeSelected() OVERRIDE; 213 virtual void DidBecomeSelected() OVERRIDE;
210 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 214 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
211 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; 215 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE;
212 216
213 // NotificationObserver overrides: 217 // NotificationObserver overrides:
214 virtual void Observe(int type, 218 virtual void Observe(int type,
215 const NotificationSource& source, 219 const NotificationSource& source,
216 const NotificationDetails& details) OVERRIDE; 220 const NotificationDetails& details) OVERRIDE;
217 221
218 // Infobars ------------------------------------------------------------------
219
220 // Adds an InfoBar for the specified |delegate|.
221 //
222 // If infobars are disabled for this tab or the tab already has a delegate
223 // which returns true for InfoBarDelegate::EqualsDelegate(delegate),
224 // |delegate| is closed immediately without being added.
225 void AddInfoBar(InfoBarDelegate* delegate);
226
227 // Removes the InfoBar for the specified |delegate|.
228 //
229 // If infobars are disabled for this tab, this will do nothing, on the
230 // assumption that the matching AddInfoBar() call will have already closed the
231 // delegate (see above).
232 void RemoveInfoBar(InfoBarDelegate* delegate);
233
234 // Replaces one infobar with another, without any animation in between.
235 //
236 // If infobars are disabled for this tab, |new_delegate| is closed immediately
237 // without being added, and nothing else happens.
238 //
239 // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
240 void ReplaceInfoBar(InfoBarDelegate* old_delegate,
241 InfoBarDelegate* new_delegate);
242
243 // Enumeration and access functions.
244 size_t infobar_count() const { return infobars_.size(); }
245 // WARNING: This does not sanity-check |index|!
246 InfoBarDelegate* GetInfoBarDelegateAt(size_t index);
247 void set_infobars_enabled(bool value) { infobars_enabled_ = value; }
248
249 // Stop this tab rendering in fullscreen mode.
250 void ExitFullscreenMode();
251
252 private: 222 private:
253 // Internal helpers ---------------------------------------------------------- 223 // Internal helpers ----------------------------------------------------------
254 224
255 // Message handlers. 225 // Message handlers.
256 void OnSnapshot(const SkBitmap& bitmap); 226 void OnSnapshot(const SkBitmap& bitmap);
257 void OnPDFHasUnsupportedFeature(); 227 void OnPDFHasUnsupportedFeature();
258 void OnDidBlockDisplayingInsecureContent();
259 void OnDidBlockRunningInsecureContent();
260 228
261 // Returns the server that can provide alternate error pages. If the returned 229 // Returns the server that can provide alternate error pages. If the returned
262 // URL is empty, the default error page built into WebKit will be used. 230 // URL is empty, the default error page built into WebKit will be used.
263 GURL GetAlternateErrorPageURL() const; 231 GURL GetAlternateErrorPageURL() const;
264 232
265 // Send the alternate error page URL to the renderer. 233 // Send the alternate error page URL to the renderer.
266 void UpdateAlternateErrorPageURL(RenderViewHost* rvh); 234 void UpdateAlternateErrorPageURL(RenderViewHost* rvh);
267 235
268 // Update the RenderView's WebPreferences. 236 // Update the RenderView's WebPreferences.
269 void UpdateWebPreferences(); 237 void UpdateWebPreferences();
270 238
271 // Update the TabContents's RendererPreferences. 239 // Update the TabContents's RendererPreferences.
272 void UpdateRendererPreferences(); 240 void UpdateRendererPreferences();
273 241
274 // Create or destroy SafebrowsingDetectionHost as needed if the user's 242 // Create or destroy SafebrowsingDetectionHost as needed if the user's
275 // safe browsing preference has changed. 243 // safe browsing preference has changed.
276 void UpdateSafebrowsingDetectionHost(); 244 void UpdateSafebrowsingDetectionHost();
277 245
278 void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate);
279 void RemoveAllInfoBars(bool animate);
280
281 // Data for core operation --------------------------------------------------- 246 // Data for core operation ---------------------------------------------------
282 247
283 // Delegate for notifying our owner about stuff. Not owned by us. 248 // Delegate for notifying our owner about stuff. Not owned by us.
284 TabContentsWrapperDelegate* delegate_; 249 TabContentsWrapperDelegate* delegate_;
285 250
286 // Delegates for InfoBars associated with this TabContentsWrapper.
287 std::vector<InfoBarDelegate*> infobars_;
288 bool infobars_enabled_;
289
290 NotificationRegistrar registrar_; 251 NotificationRegistrar registrar_;
291 PrefChangeRegistrar pref_change_registrar_; 252 PrefChangeRegistrar pref_change_registrar_;
292 253
293 // Helper which implements the SyncedTabDelegate interface. 254 // Helper which implements the SyncedTabDelegate interface.
294 scoped_ptr<TabContentsWrapperSyncedTabDelegate> synced_tab_delegate_; 255 scoped_ptr<TabContentsWrapperSyncedTabDelegate> synced_tab_delegate_;
295 256
296 // Data for current page ----------------------------------------------------- 257 // Data for current page -----------------------------------------------------
297 258
298 // Shows an info-bar to users when they search from a known search engine and 259 // Shows an info-bar to users when they search from a known search engine and
299 // have never used the omnibox for search before. 260 // have never used the omnibox for search before.
300 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_; 261 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_;
301 262
302 // Tab Helpers --------------------------------------------------------------- 263 // Tab Helpers ---------------------------------------------------------------
303 // (These provide API for callers and have a getter function listed in the 264 // (These provide API for callers and have a getter function listed in the
304 // "Tab Helpers" section in the member functions area, above.) 265 // "Tab Helpers" section in the member functions area, above.)
305 266
306 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; 267 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
307 scoped_ptr<AutofillManager> autofill_manager_; 268 scoped_ptr<AutofillManager> autofill_manager_;
308 scoped_ptr<AutomationTabHelper> automation_tab_helper_; 269 scoped_ptr<AutomationTabHelper> automation_tab_helper_;
309 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; 270 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_;
310 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; 271 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_;
311 scoped_ptr<ExtensionTabHelper> extension_tab_helper_; 272 scoped_ptr<ExtensionTabHelper> extension_tab_helper_;
312 scoped_ptr<FaviconTabHelper> favicon_tab_helper_; 273 scoped_ptr<FaviconTabHelper> favicon_tab_helper_;
313 scoped_ptr<FindTabHelper> find_tab_helper_; 274 scoped_ptr<FindTabHelper> find_tab_helper_;
314 scoped_ptr<HistoryTabHelper> history_tab_helper_; 275 scoped_ptr<HistoryTabHelper> history_tab_helper_;
276 scoped_ptr<InfoBarTabHelper> infobar_tab_helper_;
315 277
316 // PasswordManager and its delegate. The delegate must outlive the manager, 278 // PasswordManager and its delegate. The delegate must outlive the manager,
317 // per documentation in password_manager.h. 279 // per documentation in password_manager.h.
318 scoped_ptr<PasswordManagerDelegate> password_manager_delegate_; 280 scoped_ptr<PasswordManagerDelegate> password_manager_delegate_;
319 scoped_ptr<PasswordManager> password_manager_; 281 scoped_ptr<PasswordManager> password_manager_;
320 282
321 scoped_ptr<prerender::PrerenderTabHelper> prerender_tab_helper_; 283 scoped_ptr<prerender::PrerenderTabHelper> prerender_tab_helper_;
322 284
323 // Handles print job for this contents. 285 // Handles print job for this contents.
324 scoped_ptr<printing::PrintViewManager> print_view_manager_; 286 scoped_ptr<printing::PrintViewManager> print_view_manager_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 319
358 // The supporting objects need to outlive the TabContents dtor (as they may 320 // The supporting objects need to outlive the TabContents dtor (as they may
359 // be called upon during its execution). As a result, this must come last 321 // be called upon during its execution). As a result, this must come last
360 // in the list. 322 // in the list.
361 scoped_ptr<TabContents> tab_contents_; 323 scoped_ptr<TabContents> tab_contents_;
362 324
363 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); 325 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper);
364 }; 326 };
365 327
366 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ 328 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/shell_dialogs.cc ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698