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 265 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 | 718 |
724 // So InterstitialPageImpl can access SetIsLoading. | 719 // So InterstitialPageImpl can access SetIsLoading. |
725 friend class InterstitialPageImpl; | 720 friend class InterstitialPageImpl; |
726 | 721 |
727 // TODO(brettw) TestWebContents shouldn't exist! | 722 // TODO(brettw) TestWebContents shouldn't exist! |
728 friend class TestWebContents; | 723 friend class TestWebContents; |
729 | 724 |
730 class DestructionObserver; | 725 class DestructionObserver; |
731 | 726 |
732 // See WebContents::Create for a description of these parameters. | 727 // See WebContents::Create for a description of these parameters. |
733 WebContentsImpl(BrowserContext* browser_context, | 728 WebContentsImpl(BrowserContext* browser_context); |
734 WebContentsImpl* opener); | |
735 | 729 |
736 // Add and remove observers for page navigation notifications. The order in | 730 // Add and remove observers for page navigation notifications. The order in |
737 // which notifications are sent to observers is undefined. Clients must be | 731 // which notifications are sent to observers is undefined. Clients must be |
738 // sure to remove the observer before they go away. | 732 // sure to remove the observer before they go away. |
739 void AddObserver(WebContentsObserver* observer); | 733 void AddObserver(WebContentsObserver* observer); |
740 void RemoveObserver(WebContentsObserver* observer); | 734 void RemoveObserver(WebContentsObserver* observer); |
741 | 735 |
742 // Clears this tab's opener if it has been closed. | 736 // Clears a pending contents that has been closed before being shown. |
743 void OnWebContentsDestroyed(WebContentsImpl* web_contents); | 737 void OnWebContentsDestroyed(WebContentsImpl* web_contents); |
744 | 738 |
745 // Creates and adds to the map a destruction observer watching |web_contents|. | 739 // Creates and adds to the map a destruction observer watching |web_contents|. |
746 // No-op if such an observer already exists. | 740 // No-op if such an observer already exists. |
747 void AddDestructionObserver(WebContentsImpl* web_contents); | 741 void AddDestructionObserver(WebContentsImpl* web_contents); |
748 | 742 |
749 // Deletes and removes from the map a destruction observer | 743 // Deletes and removes from the map a destruction observer |
750 // watching |web_contents|. No-op if there is no such observer. | 744 // watching |web_contents|. No-op if there is no such observer. |
751 void RemoveDestructionObserver(WebContentsImpl* web_contents); | 745 void RemoveDestructionObserver(WebContentsImpl* web_contents); |
752 | 746 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 const base::string16& main_text, | 849 const base::string16& main_text, |
856 const base::string16& sub_text); | 850 const base::string16& sub_text); |
857 void OnHideValidationMessage(); | 851 void OnHideValidationMessage(); |
858 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); | 852 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); |
859 | 853 |
860 // Called by derived classes to indicate that we're no longer waiting for a | 854 // Called by derived classes to indicate that we're no longer waiting for a |
861 // response. This won't actually update the throbber, but it will get picked | 855 // response. This won't actually update the throbber, but it will get picked |
862 // up at the next animation step if the throbber is going. | 856 // up at the next animation step if the throbber is going. |
863 void SetNotWaitingForResponse() { waiting_for_response_ = false; } | 857 void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
864 | 858 |
859 // Returns the opener WebContentsImpl, if any. This can be null if the opener | |
860 // is closed or the page clears its window.opener. | |
861 WebContentsImpl* GetOpenerWebContents() const; | |
Charlie Reis
2015/06/09 04:38:38
Oh, for some reason I thought we were returning a
alexmos
2015/06/09 20:13:05
Done.
| |
862 | |
865 // Navigation helpers -------------------------------------------------------- | 863 // Navigation helpers -------------------------------------------------------- |
866 // | 864 // |
867 // These functions are helpers for Navigate() and DidNavigate(). | 865 // These functions are helpers for Navigate() and DidNavigate(). |
868 | 866 |
869 // Handles post-navigation tasks in DidNavigate AFTER the entry has been | 867 // Handles post-navigation tasks in DidNavigate AFTER the entry has been |
870 // committed to the navigation controller. Note that the navigation entry is | 868 // committed to the navigation controller. Note that the navigation entry is |
871 // not provided since it may be invalid/changed after being committed. The | 869 // not provided since it may be invalid/changed after being committed. The |
872 // current navigation entry is in the NavigationController at this point. | 870 // current navigation entry is in the NavigationController at this point. |
873 | 871 |
874 // If our controller was restored, update the max page ID associated with the | 872 // If our controller was restored, update the max page ID associated with the |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 | 1008 |
1011 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers; | 1009 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers; |
1012 DestructionObservers destruction_observers_; | 1010 DestructionObservers destruction_observers_; |
1013 | 1011 |
1014 // A list of observers notified when page state changes. Weak references. | 1012 // A list of observers notified when page state changes. Weak references. |
1015 // This MUST be listed above frame_tree_ since at destruction time the | 1013 // This MUST be listed above frame_tree_ since at destruction time the |
1016 // latter might cause RenderViewHost's destructor to call us and we might use | 1014 // latter might cause RenderViewHost's destructor to call us and we might use |
1017 // the observer list then. | 1015 // the observer list then. |
1018 base::ObserverList<WebContentsObserver> observers_; | 1016 base::ObserverList<WebContentsObserver> observers_; |
1019 | 1017 |
1020 // The tab that opened this tab, if any. Will be set to null if the opener | |
1021 // is closed. | |
1022 WebContentsImpl* opener_; | |
1023 | |
1024 // True if this tab was opened by another tab. This is not unset if the opener | 1018 // True if this tab was opened by another tab. This is not unset if the opener |
1025 // is closed. | 1019 // is closed. |
1026 bool created_with_opener_; | 1020 bool created_with_opener_; |
1027 | 1021 |
1028 #if defined(OS_WIN) | 1022 #if defined(OS_WIN) |
1029 gfx::NativeViewAccessible accessible_parent_; | 1023 gfx::NativeViewAccessible accessible_parent_; |
1030 #endif | 1024 #endif |
1031 | 1025 |
1032 // Helper classes ------------------------------------------------------------ | 1026 // Helper classes ------------------------------------------------------------ |
1033 | 1027 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1284 // Adds/removes a callback called on creation of each new WebContents. | 1278 // Adds/removes a callback called on creation of each new WebContents. |
1285 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1279 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
1286 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1280 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
1287 | 1281 |
1288 DISALLOW_COPY_AND_ASSIGN(FriendZone); | 1282 DISALLOW_COPY_AND_ASSIGN(FriendZone); |
1289 }; | 1283 }; |
1290 | 1284 |
1291 } // namespace content | 1285 } // namespace content |
1292 | 1286 |
1293 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1287 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |