| OLD | NEW |
| 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 "content/browser/tab_contents/tab_contents.h" | 16 #include "base/property_bag.h" |
| 17 #include "content/browser/tab_contents/tab_contents_observer.h" | 17 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 18 | 18 |
| 19 class AlternateErrorPageTabObserver; | 19 class AlternateErrorPageTabObserver; |
| 20 class AutocompleteHistoryManager; | 20 class AutocompleteHistoryManager; |
| 21 class AutofillManager; | 21 class AutofillManager; |
| 22 class AutofillExternalDelegate; | 22 class AutofillExternalDelegate; |
| 23 class AutomationTabHelper; | 23 class AutomationTabHelper; |
| 24 class BlockedContentTabHelper; | 24 class BlockedContentTabHelper; |
| 25 class BookmarkTabHelper; | 25 class BookmarkTabHelper; |
| 26 class ConstrainedWindowTabHelper; | 26 class ConstrainedWindowTabHelper; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 class PrintPreviewMessageHandler; | 65 class PrintPreviewMessageHandler; |
| 66 } | 66 } |
| 67 | 67 |
| 68 namespace safe_browsing { | 68 namespace safe_browsing { |
| 69 class SafeBrowsingTabObserver; | 69 class SafeBrowsingTabObserver; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Wraps TabContents and all of its supporting objects in order to control | 72 // Wraps TabContents and all of its supporting objects in order to control |
| 73 // their ownership and lifetime, while allowing TabContents to remain generic | 73 // their ownership and lifetime, while allowing TabContents to remain generic |
| 74 // and re-usable in other projects. | 74 // and re-usable in other projects. |
| 75 // TODO(pinkerton): Eventually, this class will become TabContents as far as | 75 // |
| 76 // TODO(avi): Eventually, this class will become TabContents as far as |
| 76 // the browser front-end is concerned, and the current TabContents will be | 77 // the browser front-end is concerned, and the current TabContents will be |
| 77 // renamed to something like WebPage or WebView (ben's suggestions). | 78 // renamed to something like WebContents; <http://crbug.com/105875>. |
| 78 class TabContentsWrapper : public TabContentsObserver { | 79 class TabContentsWrapper : public TabContentsObserver { |
| 79 public: | 80 public: |
| 80 // Takes ownership of |contents|, which must be heap-allocated (as it lives | 81 // Takes ownership of |contents|, which must be heap-allocated (as it lives |
| 81 // in a scoped_ptr) and can not be NULL. | 82 // in a scoped_ptr) and can not be NULL. |
| 82 explicit TabContentsWrapper(TabContents* contents); | 83 explicit TabContentsWrapper(TabContents* contents); |
| 83 virtual ~TabContentsWrapper(); | 84 virtual ~TabContentsWrapper(); |
| 84 | 85 |
| 85 // Used to retrieve this object from |tab_contents_|, which is placed in | |
| 86 // its property bag to avoid adding additional interfaces. | |
| 87 static base::PropertyAccessor<TabContentsWrapper*>* property_accessor(); | |
| 88 | |
| 89 // Create a TabContentsWrapper with the same state as this one. The returned | 86 // Create a TabContentsWrapper with the same state as this one. The returned |
| 90 // heap-allocated pointer is owned by the caller. | 87 // heap-allocated pointer is owned by the caller. |
| 91 TabContentsWrapper* Clone(); | 88 TabContentsWrapper* Clone(); |
| 92 | 89 |
| 93 // Helper to retrieve the existing instance that wraps a given TabContents. | 90 // Helper to retrieve the existing instance that wraps a given TabContents. |
| 94 // Returns NULL if there is no such existing instance. | 91 // Returns NULL if there is no such existing instance. |
| 95 // NOTE: This is not intended for general use. It is intended for situations | 92 // NOTE: This is not intended for general use. It is intended for situations |
| 96 // like callbacks from content/ where only a TabContents is available. In the | 93 // like callbacks from content/ where only a TabContents is available. In the |
| 97 // general case, please do NOT use this; plumb TabContentsWrapper through the | 94 // general case, please do NOT use this; plumb TabContentsWrapper through the |
| 98 // chrome/ code instead of TabContents. | 95 // chrome/ code instead of TabContents. |
| 99 static TabContentsWrapper* GetCurrentWrapperForContents( | 96 static TabContentsWrapper* GetCurrentWrapperForContents( |
| 100 TabContents* contents); | 97 TabContents* contents); |
| 101 static const TabContentsWrapper* GetCurrentWrapperForContents( | 98 static const TabContentsWrapper* GetCurrentWrapperForContents( |
| 102 const TabContents* contents); | 99 const TabContents* contents); |
| 103 | 100 |
| 101 // Returns the TabContents that this wraps. |
| 104 TabContents* tab_contents() const { return tab_contents_.get(); } | 102 TabContents* tab_contents() const { return tab_contents_.get(); } |
| 105 NavigationController& controller() const { | |
| 106 return tab_contents()->controller(); | |
| 107 } | |
| 108 TabContentsView* view() const { return tab_contents()->view(); } | |
| 109 RenderViewHost* render_view_host() const { | |
| 110 return tab_contents()->render_view_host(); | |
| 111 } | |
| 112 WebUI* web_ui() const { return tab_contents()->web_ui(); } | |
| 113 | 103 |
| 104 // Returns the Profile that is associated with this TabContentsWrapper. |
| 114 Profile* profile() const; | 105 Profile* profile() const; |
| 115 | 106 |
| 116 // Tab Helpers --------------------------------------------------------------- | 107 // Tab Helpers --------------------------------------------------------------- |
| 117 | 108 |
| 118 AutocompleteHistoryManager* autocomplete_history_manager() { | 109 AutocompleteHistoryManager* autocomplete_history_manager() { |
| 119 return autocomplete_history_manager_.get(); | 110 return autocomplete_history_manager_.get(); |
| 120 } | 111 } |
| 121 | 112 |
| 122 AutofillManager* autofill_manager() { return autofill_manager_.get(); } | 113 AutofillManager* autofill_manager() { return autofill_manager_.get(); } |
| 123 | 114 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 190 |
| 200 // Overrides ----------------------------------------------------------------- | 191 // Overrides ----------------------------------------------------------------- |
| 201 | 192 |
| 202 // TabContentsObserver overrides: | 193 // TabContentsObserver overrides: |
| 203 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; | 194 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; |
| 204 | 195 |
| 205 private: | 196 private: |
| 206 FRIEND_TEST_ALL_PREFIXES( | 197 FRIEND_TEST_ALL_PREFIXES( |
| 207 PrefsTabHelperTest, OverridePrefsOnViewCreation); | 198 PrefsTabHelperTest, OverridePrefsOnViewCreation); |
| 208 | 199 |
| 200 // Used to retrieve this object from |tab_contents_|, which is placed in |
| 201 // its property bag to avoid adding additional interfaces. |
| 202 static base::PropertyAccessor<TabContentsWrapper*>* property_accessor(); |
| 203 |
| 209 // Tab Helpers --------------------------------------------------------------- | 204 // Tab Helpers --------------------------------------------------------------- |
| 210 // (These provide API for callers and have a getter function listed in the | 205 // (These provide API for callers and have a getter function listed in the |
| 211 // "Tab Helpers" section in the member functions area, above.) | 206 // "Tab Helpers" section in the member functions area, above.) |
| 212 | 207 |
| 213 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; | 208 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; |
| 214 scoped_refptr<AutofillManager> autofill_manager_; | 209 scoped_refptr<AutofillManager> autofill_manager_; |
| 215 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; | 210 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; |
| 216 scoped_ptr<AutomationTabHelper> automation_tab_helper_; | 211 scoped_ptr<AutomationTabHelper> automation_tab_helper_; |
| 217 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; | 212 scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_; |
| 218 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; | 213 scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 230 scoped_ptr<PasswordManager> password_manager_; | 225 scoped_ptr<PasswordManager> password_manager_; |
| 231 | 226 |
| 232 scoped_ptr<PrefsTabHelper> prefs_tab_helper_; | 227 scoped_ptr<PrefsTabHelper> prefs_tab_helper_; |
| 233 scoped_ptr<prerender::PrerenderTabHelper> prerender_tab_helper_; | 228 scoped_ptr<prerender::PrerenderTabHelper> prerender_tab_helper_; |
| 234 | 229 |
| 235 // Handles print job for this contents. | 230 // Handles print job for this contents. |
| 236 scoped_ptr<printing::PrintViewManager> print_view_manager_; | 231 scoped_ptr<printing::PrintViewManager> print_view_manager_; |
| 237 | 232 |
| 238 scoped_ptr<RestoreTabHelper> restore_tab_helper_; | 233 scoped_ptr<RestoreTabHelper> restore_tab_helper_; |
| 239 | 234 |
| 240 // Handles displaying a web intents picker to the user. | |
| 241 scoped_ptr<WebIntentPickerController> web_intent_picker_controller_; | |
| 242 | |
| 243 scoped_ptr<SearchEngineTabHelper> search_engine_tab_helper_; | 235 scoped_ptr<SearchEngineTabHelper> search_engine_tab_helper_; |
| 244 scoped_ptr<SnapshotTabHelper> snapshot_tab_helper_; | 236 scoped_ptr<SnapshotTabHelper> snapshot_tab_helper_; |
| 245 scoped_ptr<TabContentsSSLHelper> ssl_helper_; | 237 scoped_ptr<TabContentsSSLHelper> ssl_helper_; |
| 246 scoped_ptr<TabContentsWrapperSyncedTabDelegate> synced_tab_delegate_; | 238 scoped_ptr<TabContentsWrapperSyncedTabDelegate> synced_tab_delegate_; |
| 247 | 239 |
| 248 // The TabSpecificContentSettings object is used to query the blocked content | 240 // The TabSpecificContentSettings object is used to query the blocked content |
| 249 // state by various UI elements. | 241 // state by various UI elements. |
| 250 scoped_ptr<TabSpecificContentSettings> content_settings_; | 242 scoped_ptr<TabSpecificContentSettings> content_settings_; |
| 251 | 243 |
| 252 scoped_ptr<TranslateTabHelper> translate_tab_helper_; | 244 scoped_ptr<TranslateTabHelper> translate_tab_helper_; |
| 253 | 245 |
| 246 // Handles displaying a web intents picker to the user. |
| 247 scoped_ptr<WebIntentPickerController> web_intent_picker_controller_; |
| 248 |
| 254 // Per-tab observers --------------------------------------------------------- | 249 // Per-tab observers --------------------------------------------------------- |
| 255 // (These provide no API for callers; objects that need to exist 1:1 with tabs | 250 // (These provide no API for callers; objects that need to exist 1:1 with tabs |
| 256 // and silently do their thing live here.) | 251 // and silently do their thing live here.) |
| 257 | 252 |
| 258 scoped_ptr<AlternateErrorPageTabObserver> alternate_error_page_tab_observer_; | 253 scoped_ptr<AlternateErrorPageTabObserver> alternate_error_page_tab_observer_; |
| 259 scoped_ptr<DownloadRequestLimiterObserver> download_request_limiter_observer_; | 254 scoped_ptr<DownloadRequestLimiterObserver> download_request_limiter_observer_; |
| 260 scoped_ptr<ExtensionWebNavigationTabObserver> webnavigation_observer_; | 255 scoped_ptr<ExtensionWebNavigationTabObserver> webnavigation_observer_; |
| 261 scoped_ptr<ExternalProtocolObserver> external_protocol_observer_; | 256 scoped_ptr<ExternalProtocolObserver> external_protocol_observer_; |
| 262 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_; | 257 scoped_ptr<OmniboxSearchHint> omnibox_search_hint_; |
| 263 scoped_ptr<PDFTabObserver> pdf_tab_observer_; | 258 scoped_ptr<PDFTabObserver> pdf_tab_observer_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 275 | 270 |
| 276 // The supporting objects need to outlive the TabContents dtor (as they may | 271 // The supporting objects need to outlive the TabContents dtor (as they may |
| 277 // be called upon during its execution). As a result, this must come last | 272 // be called upon during its execution). As a result, this must come last |
| 278 // in the list. | 273 // in the list. |
| 279 scoped_ptr<TabContents> tab_contents_; | 274 scoped_ptr<TabContents> tab_contents_; |
| 280 | 275 |
| 281 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); | 276 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); |
| 282 }; | 277 }; |
| 283 | 278 |
| 284 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ | 279 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ |
| OLD | NEW |