OLD | NEW |
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 CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 public NotificationObserver, | 98 public NotificationObserver, |
99 public NON_EXPORTED_BASE(NavigationControllerDelegate), | 99 public NON_EXPORTED_BASE(NavigationControllerDelegate), |
100 public NON_EXPORTED_BASE(NavigatorDelegate) { | 100 public NON_EXPORTED_BASE(NavigatorDelegate) { |
101 public: | 101 public: |
102 class FriendZone; | 102 class FriendZone; |
103 | 103 |
104 ~WebContentsImpl() override; | 104 ~WebContentsImpl() override; |
105 | 105 |
106 static WebContentsImpl* CreateWithOpener( | 106 static WebContentsImpl* CreateWithOpener( |
107 const WebContents::CreateParams& params, | 107 const WebContents::CreateParams& params, |
108 WebContentsImpl* opener); | 108 FrameTreeNode* opener); |
109 | 109 |
110 static std::vector<WebContentsImpl*> GetAllWebContents(); | 110 static std::vector<WebContentsImpl*> GetAllWebContents(); |
111 | 111 |
112 static WebContentsImpl* FromFrameTreeNode(FrameTreeNode* frame_tree_node); | 112 static WebContentsImpl* FromFrameTreeNode(FrameTreeNode* frame_tree_node); |
113 | 113 |
114 // Returns the opener WebContentsImpl, if any. This can be set to null if the | |
115 // opener is closed or the page clears its window.opener. | |
116 WebContentsImpl* opener() const { return opener_; } | |
117 | |
118 // Creates a swapped out RenderView. This is used by the browser plugin to | 114 // Creates a swapped out RenderView. This is used by the browser plugin to |
119 // create a swapped out RenderView in the embedder render process for the | 115 // create a swapped out RenderView in the embedder render process for the |
120 // guest, to expose the guest's window object to the embedder. | 116 // guest, to expose the guest's window object to the embedder. |
121 // This returns the routing ID of the newly created swapped out RenderView. | 117 // This returns the routing ID of the newly created swapped out RenderView. |
122 int CreateSwappedOutRenderView(SiteInstance* instance); | 118 int CreateSwappedOutRenderView(SiteInstance* instance); |
123 | 119 |
124 // Complex initialization here. Specifically needed to avoid having | 120 // Complex initialization here. Specifically needed to avoid having |
125 // members call back into our virtual functions in the constructor. | 121 // members call back into our virtual functions in the constructor. |
126 virtual void Init(const WebContents::CreateParams& params); | 122 virtual void Init(const WebContents::CreateParams& params); |
127 | 123 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 void SetClosedByUserGesture(bool value) override; | 334 void SetClosedByUserGesture(bool value) override; |
339 bool GetClosedByUserGesture() const override; | 335 bool GetClosedByUserGesture() const override; |
340 void ViewSource() override; | 336 void ViewSource() override; |
341 void ViewFrameSource(const GURL& url, const PageState& page_state) override; | 337 void ViewFrameSource(const GURL& url, const PageState& page_state) override; |
342 int GetMinimumZoomPercent() const override; | 338 int GetMinimumZoomPercent() const override; |
343 int GetMaximumZoomPercent() const override; | 339 int GetMaximumZoomPercent() const override; |
344 void ResetPageScale() override; | 340 void ResetPageScale() override; |
345 gfx::Size GetPreferredSize() const override; | 341 gfx::Size GetPreferredSize() const override; |
346 bool GotResponseToLockMouseRequest(bool allowed) override; | 342 bool GotResponseToLockMouseRequest(bool allowed) override; |
347 bool HasOpener() const override; | 343 bool HasOpener() const override; |
348 WebContents* GetOpener() const override; | 344 WebContentsImpl* GetOpener() const override; |
349 void DidChooseColorInColorChooser(SkColor color) override; | 345 void DidChooseColorInColorChooser(SkColor color) override; |
350 void DidEndColorChooser() override; | 346 void DidEndColorChooser() override; |
351 int DownloadImage(const GURL& url, | 347 int DownloadImage(const GURL& url, |
352 bool is_favicon, | 348 bool is_favicon, |
353 uint32_t max_bitmap_size, | 349 uint32_t max_bitmap_size, |
354 bool bypass_cache, | 350 bool bypass_cache, |
355 const ImageDownloadCallback& callback) override; | 351 const ImageDownloadCallback& callback) override; |
356 bool IsSubframe() const override; | 352 bool IsSubframe() const override; |
357 void Find(int request_id, | 353 void Find(int request_id, |
358 const base::string16& search_text, | 354 const base::string16& search_text, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 const GURL& frame_url, | 389 const GURL& frame_url, |
394 JavaScriptMessageType type, | 390 JavaScriptMessageType type, |
395 IPC::Message* reply_msg) override; | 391 IPC::Message* reply_msg) override; |
396 void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host, | 392 void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host, |
397 const base::string16& message, | 393 const base::string16& message, |
398 bool is_reload, | 394 bool is_reload, |
399 IPC::Message* reply_msg) override; | 395 IPC::Message* reply_msg) override; |
400 void DidAccessInitialDocument() override; | 396 void DidAccessInitialDocument() override; |
401 void DidChangeName(RenderFrameHost* render_frame_host, | 397 void DidChangeName(RenderFrameHost* render_frame_host, |
402 const std::string& name) override; | 398 const std::string& name) override; |
403 void DidDisownOpener(RenderFrameHost* render_frame_host) override; | |
404 void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) override; | 399 void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) override; |
405 void UpdateTitle(RenderFrameHost* render_frame_host, | 400 void UpdateTitle(RenderFrameHost* render_frame_host, |
406 int32 page_id, | 401 int32 page_id, |
407 const base::string16& title, | 402 const base::string16& title, |
408 base::i18n::TextDirection title_direction) override; | 403 base::i18n::TextDirection title_direction) override; |
409 void UpdateEncoding(RenderFrameHost* render_frame_host, | 404 void UpdateEncoding(RenderFrameHost* render_frame_host, |
410 const std::string& encoding) override; | 405 const std::string& encoding) override; |
411 WebContents* GetAsWebContents() override; | 406 WebContents* GetAsWebContents() override; |
412 bool IsNeverVisible() override; | 407 bool IsNeverVisible() override; |
413 AccessibilityMode GetAccessibilityMode() const override; | 408 AccessibilityMode GetAccessibilityMode() const override; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 719 |
725 // So InterstitialPageImpl can access SetIsLoading. | 720 // So InterstitialPageImpl can access SetIsLoading. |
726 friend class InterstitialPageImpl; | 721 friend class InterstitialPageImpl; |
727 | 722 |
728 // TODO(brettw) TestWebContents shouldn't exist! | 723 // TODO(brettw) TestWebContents shouldn't exist! |
729 friend class TestWebContents; | 724 friend class TestWebContents; |
730 | 725 |
731 class DestructionObserver; | 726 class DestructionObserver; |
732 | 727 |
733 // See WebContents::Create for a description of these parameters. | 728 // See WebContents::Create for a description of these parameters. |
734 WebContentsImpl(BrowserContext* browser_context, | 729 WebContentsImpl(BrowserContext* browser_context); |
735 WebContentsImpl* opener); | |
736 | 730 |
737 // Add and remove observers for page navigation notifications. The order in | 731 // Add and remove observers for page navigation notifications. The order in |
738 // which notifications are sent to observers is undefined. Clients must be | 732 // which notifications are sent to observers is undefined. Clients must be |
739 // sure to remove the observer before they go away. | 733 // sure to remove the observer before they go away. |
740 void AddObserver(WebContentsObserver* observer); | 734 void AddObserver(WebContentsObserver* observer); |
741 void RemoveObserver(WebContentsObserver* observer); | 735 void RemoveObserver(WebContentsObserver* observer); |
742 | 736 |
743 // Clears this tab's opener if it has been closed. | 737 // Clears a pending contents that has been closed before being shown. |
744 void OnWebContentsDestroyed(WebContentsImpl* web_contents); | 738 void OnWebContentsDestroyed(WebContentsImpl* web_contents); |
745 | 739 |
746 // Creates and adds to the map a destruction observer watching |web_contents|. | 740 // Creates and adds to the map a destruction observer watching |web_contents|. |
747 // No-op if such an observer already exists. | 741 // No-op if such an observer already exists. |
748 void AddDestructionObserver(WebContentsImpl* web_contents); | 742 void AddDestructionObserver(WebContentsImpl* web_contents); |
749 | 743 |
750 // Deletes and removes from the map a destruction observer | 744 // Deletes and removes from the map a destruction observer |
751 // watching |web_contents|. No-op if there is no such observer. | 745 // watching |web_contents|. No-op if there is no such observer. |
752 void RemoveDestructionObserver(WebContentsImpl* web_contents); | 746 void RemoveDestructionObserver(WebContentsImpl* web_contents); |
753 | 747 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1005 |
1012 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers; | 1006 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers; |
1013 DestructionObservers destruction_observers_; | 1007 DestructionObservers destruction_observers_; |
1014 | 1008 |
1015 // A list of observers notified when page state changes. Weak references. | 1009 // A list of observers notified when page state changes. Weak references. |
1016 // This MUST be listed above frame_tree_ since at destruction time the | 1010 // This MUST be listed above frame_tree_ since at destruction time the |
1017 // latter might cause RenderViewHost's destructor to call us and we might use | 1011 // latter might cause RenderViewHost's destructor to call us and we might use |
1018 // the observer list then. | 1012 // the observer list then. |
1019 base::ObserverList<WebContentsObserver> observers_; | 1013 base::ObserverList<WebContentsObserver> observers_; |
1020 | 1014 |
1021 // The tab that opened this tab, if any. Will be set to null if the opener | |
1022 // is closed. | |
1023 WebContentsImpl* opener_; | |
1024 | |
1025 // True if this tab was opened by another tab. This is not unset if the opener | 1015 // True if this tab was opened by another tab. This is not unset if the opener |
1026 // is closed. | 1016 // is closed. |
1027 bool created_with_opener_; | 1017 bool created_with_opener_; |
1028 | 1018 |
1029 #if defined(OS_WIN) | 1019 #if defined(OS_WIN) |
1030 gfx::NativeViewAccessible accessible_parent_; | 1020 gfx::NativeViewAccessible accessible_parent_; |
1031 #endif | 1021 #endif |
1032 | 1022 |
1033 // Helper classes ------------------------------------------------------------ | 1023 // Helper classes ------------------------------------------------------------ |
1034 | 1024 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 // Adds/removes a callback called on creation of each new WebContents. | 1275 // Adds/removes a callback called on creation of each new WebContents. |
1286 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1276 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
1287 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1277 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
1288 | 1278 |
1289 DISALLOW_COPY_AND_ASSIGN(FriendZone); | 1279 DISALLOW_COPY_AND_ASSIGN(FriendZone); |
1290 }; | 1280 }; |
1291 | 1281 |
1292 } // namespace content | 1282 } // namespace content |
1293 | 1283 |
1294 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1284 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |