| 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 // Defines the Chrome Extensions WebNavigation API functions for observing and | 5 // Defines the Chrome Extensions WebNavigation API functions for observing and |
| 6 // intercepting navigation events, as specified in the extension JSON API. | 6 // intercepting navigation events, as specified in the extension JSON API. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
| 9 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const; | 47 content::RenderViewHost* GetRenderViewHostInProcess(int process_id) const; |
| 48 | 48 |
| 49 // content::NotificationObserver implementation. | 49 // content::NotificationObserver implementation. |
| 50 virtual void Observe(int type, | 50 virtual void Observe(int type, |
| 51 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
| 52 const content::NotificationDetails& details) OVERRIDE; | 52 const content::NotificationDetails& details) OVERRIDE; |
| 53 | 53 |
| 54 // content::WebContentsObserver implementation. | 54 // content::WebContentsObserver implementation. |
| 55 virtual void RenderFrameDeleted( |
| 56 content::RenderFrameHost* render_frame_host) OVERRIDE; |
| 55 virtual void RenderViewDeleted( | 57 virtual void RenderViewDeleted( |
| 56 content::RenderViewHost* render_view_host) OVERRIDE; | 58 content::RenderViewHost* render_view_host) OVERRIDE; |
| 57 virtual void AboutToNavigateRenderView( | 59 virtual void AboutToNavigateRenderView( |
| 58 content::RenderViewHost* render_view_host) OVERRIDE; | 60 content::RenderViewHost* render_view_host) OVERRIDE; |
| 59 virtual void DidStartProvisionalLoadForFrame( | 61 virtual void DidStartProvisionalLoadForFrame( |
| 60 content::RenderFrameHost* render_frame_host, | 62 content::RenderFrameHost* render_frame_host, |
| 61 const GURL& validated_url, | 63 const GURL& validated_url, |
| 62 bool is_error_page, | 64 bool is_error_page, |
| 63 bool is_iframe_srcdoc) OVERRIDE; | 65 bool is_iframe_srcdoc) OVERRIDE; |
| 64 virtual void DidCommitProvisionalLoadForFrame( | 66 virtual void DidCommitProvisionalLoadForFrame( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 virtual void FrameDetached( | 92 virtual void FrameDetached( |
| 91 content::RenderFrameHost* render_view_host) OVERRIDE; | 93 content::RenderFrameHost* render_view_host) OVERRIDE; |
| 92 virtual void WebContentsDestroyed() OVERRIDE; | 94 virtual void WebContentsDestroyed() OVERRIDE; |
| 93 | 95 |
| 94 private: | 96 private: |
| 95 explicit WebNavigationTabObserver(content::WebContents* web_contents); | 97 explicit WebNavigationTabObserver(content::WebContents* web_contents); |
| 96 friend class content::WebContentsUserData<WebNavigationTabObserver>; | 98 friend class content::WebContentsUserData<WebNavigationTabObserver>; |
| 97 | 99 |
| 98 // True if the transition and target url correspond to a reference fragment | 100 // True if the transition and target url correspond to a reference fragment |
| 99 // navigation. | 101 // navigation. |
| 100 bool IsReferenceFragmentNavigation(FrameNavigationState::FrameID frame_id, | 102 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, |
| 101 const GURL& url); | 103 const GURL& url); |
| 102 | 104 |
| 103 // Creates and sends onErrorOccurred events for all on-going navigations. If | 105 // Creates and sends onErrorOccurred events for all on-going navigations. If |
| 104 // |render_view_host| is non-NULL, only generates events for frames in this | 106 // |render_view_host| is non-NULL, only generates events for frames in this |
| 105 // render view host. If |id_to_skip| is given, no events are sent for that | 107 // render view host. If |frame_host_to_skip| is given, no events are sent for |
| 108 // that |
| 106 // frame. | 109 // frame. |
| 107 void SendErrorEvents(content::WebContents* web_contents, | 110 void SendErrorEvents(content::WebContents* web_contents, |
| 108 content::RenderViewHost* render_view_host, | 111 content::RenderViewHost* render_view_host, |
| 109 FrameNavigationState::FrameID id_to_skip); | 112 content::RenderFrameHost* frame_host_to_skip); |
| 110 | 113 |
| 111 // Tracks the state of the frames we are sending events for. | 114 // Tracks the state of the frames we are sending events for. |
| 112 FrameNavigationState navigation_state_; | 115 FrameNavigationState navigation_state_; |
| 113 | 116 |
| 114 // Used for tracking registrations to redirect notifications. | 117 // Used for tracking registrations to redirect notifications. |
| 115 content::NotificationRegistrar registrar_; | 118 content::NotificationRegistrar registrar_; |
| 116 | 119 |
| 117 // The current RenderViewHost of the observed WebContents. | 120 // The current RenderViewHost of the observed WebContents. |
| 118 content::RenderViewHost* render_view_host_; | 121 content::RenderViewHost* render_view_host_; |
| 119 | 122 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 public content::NotificationObserver { | 134 public content::NotificationObserver { |
| 132 public: | 135 public: |
| 133 explicit WebNavigationEventRouter(Profile* profile); | 136 explicit WebNavigationEventRouter(Profile* profile); |
| 134 virtual ~WebNavigationEventRouter(); | 137 virtual ~WebNavigationEventRouter(); |
| 135 | 138 |
| 136 private: | 139 private: |
| 137 // Used to cache the information about newly created WebContents objects. | 140 // Used to cache the information about newly created WebContents objects. |
| 138 struct PendingWebContents{ | 141 struct PendingWebContents{ |
| 139 PendingWebContents(); | 142 PendingWebContents(); |
| 140 PendingWebContents(content::WebContents* source_web_contents, | 143 PendingWebContents(content::WebContents* source_web_contents, |
| 141 int64 source_frame_id, | 144 content::RenderFrameHost* source_frame_host, |
| 142 bool source_frame_is_main_frame, | |
| 143 content::WebContents* target_web_contents, | 145 content::WebContents* target_web_contents, |
| 144 const GURL& target_url); | 146 const GURL& target_url); |
| 145 ~PendingWebContents(); | 147 ~PendingWebContents(); |
| 146 | 148 |
| 147 content::WebContents* source_web_contents; | 149 content::WebContents* source_web_contents; |
| 148 int64 source_frame_id; | 150 content::RenderFrameHost* source_frame_host; |
| 149 bool source_frame_is_main_frame; | |
| 150 content::WebContents* target_web_contents; | 151 content::WebContents* target_web_contents; |
| 151 GURL target_url; | 152 GURL target_url; |
| 152 }; | 153 }; |
| 153 | 154 |
| 154 // TabStripModelObserver implementation. | 155 // TabStripModelObserver implementation. |
| 155 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 156 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 156 content::WebContents* old_contents, | 157 content::WebContents* old_contents, |
| 157 content::WebContents* new_contents, | 158 content::WebContents* new_contents, |
| 158 int index) OVERRIDE; | 159 int index) OVERRIDE; |
| 159 | 160 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 237 |
| 237 // Created lazily upon OnListenerAdded. | 238 // Created lazily upon OnListenerAdded. |
| 238 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; | 239 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; |
| 239 | 240 |
| 240 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); | 241 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); |
| 241 }; | 242 }; |
| 242 | 243 |
| 243 } // namespace extensions | 244 } // namespace extensions |
| 244 | 245 |
| 245 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 246 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
| OLD | NEW |