| 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 15 matching lines...) Expand all Loading... |
| 80 const base::string16& error_description) OVERRIDE; | 82 const base::string16& error_description) OVERRIDE; |
| 81 virtual void DidGetRedirectForResourceRequest( | 83 virtual void DidGetRedirectForResourceRequest( |
| 82 content::RenderViewHost* render_view_host, | 84 content::RenderViewHost* render_view_host, |
| 83 const content::ResourceRedirectDetails& details) OVERRIDE; | 85 const content::ResourceRedirectDetails& details) OVERRIDE; |
| 84 virtual void DidOpenRequestedURL(content::WebContents* new_contents, | 86 virtual void DidOpenRequestedURL(content::WebContents* new_contents, |
| 85 const GURL& url, | 87 const GURL& url, |
| 86 const content::Referrer& referrer, | 88 const content::Referrer& referrer, |
| 87 WindowOpenDisposition disposition, | 89 WindowOpenDisposition disposition, |
| 88 content::PageTransition transition, | 90 content::PageTransition transition, |
| 89 int64 source_frame_num) OVERRIDE; | 91 int64 source_frame_num) OVERRIDE; |
| 90 virtual void FrameDetached( | |
| 91 content::RenderFrameHost* render_view_host) OVERRIDE; | |
| 92 virtual void WebContentsDestroyed() OVERRIDE; | 92 virtual void WebContentsDestroyed() OVERRIDE; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 explicit WebNavigationTabObserver(content::WebContents* web_contents); | 95 explicit WebNavigationTabObserver(content::WebContents* web_contents); |
| 96 friend class content::WebContentsUserData<WebNavigationTabObserver>; | 96 friend class content::WebContentsUserData<WebNavigationTabObserver>; |
| 97 | 97 |
| 98 // True if the transition and target url correspond to a reference fragment | 98 // True if the transition and target url correspond to a reference fragment |
| 99 // navigation. | 99 // navigation. |
| 100 bool IsReferenceFragmentNavigation(FrameNavigationState::FrameID frame_id, | 100 bool IsReferenceFragmentNavigation(content::RenderFrameHost* frame_host, |
| 101 const GURL& url); | 101 const GURL& url); |
| 102 | 102 |
| 103 // Creates and sends onErrorOccurred events for all on-going navigations. If | 103 // 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 | 104 // |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 | 105 // render view host. If |frame_host_to_skip| is given, no events are sent for |
| 106 // that |
| 106 // frame. | 107 // frame. |
| 107 void SendErrorEvents(content::WebContents* web_contents, | 108 void SendErrorEvents(content::WebContents* web_contents, |
| 108 content::RenderViewHost* render_view_host, | 109 content::RenderViewHost* render_view_host, |
| 109 FrameNavigationState::FrameID id_to_skip); | 110 content::RenderFrameHost* frame_host_to_skip); |
| 110 | 111 |
| 111 // Tracks the state of the frames we are sending events for. | 112 // Tracks the state of the frames we are sending events for. |
| 112 FrameNavigationState navigation_state_; | 113 FrameNavigationState navigation_state_; |
| 113 | 114 |
| 114 // Used for tracking registrations to redirect notifications. | 115 // Used for tracking registrations to redirect notifications. |
| 115 content::NotificationRegistrar registrar_; | 116 content::NotificationRegistrar registrar_; |
| 116 | 117 |
| 117 // The current RenderViewHost of the observed WebContents. | 118 // The current RenderViewHost of the observed WebContents. |
| 118 content::RenderViewHost* render_view_host_; | 119 content::RenderViewHost* render_view_host_; |
| 119 | 120 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 public content::NotificationObserver { | 132 public content::NotificationObserver { |
| 132 public: | 133 public: |
| 133 explicit WebNavigationEventRouter(Profile* profile); | 134 explicit WebNavigationEventRouter(Profile* profile); |
| 134 virtual ~WebNavigationEventRouter(); | 135 virtual ~WebNavigationEventRouter(); |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 // Used to cache the information about newly created WebContents objects. | 138 // Used to cache the information about newly created WebContents objects. |
| 138 struct PendingWebContents{ | 139 struct PendingWebContents{ |
| 139 PendingWebContents(); | 140 PendingWebContents(); |
| 140 PendingWebContents(content::WebContents* source_web_contents, | 141 PendingWebContents(content::WebContents* source_web_contents, |
| 141 int64 source_frame_id, | 142 content::RenderFrameHost* source_frame_host, |
| 142 bool source_frame_is_main_frame, | |
| 143 content::WebContents* target_web_contents, | 143 content::WebContents* target_web_contents, |
| 144 const GURL& target_url); | 144 const GURL& target_url); |
| 145 ~PendingWebContents(); | 145 ~PendingWebContents(); |
| 146 | 146 |
| 147 content::WebContents* source_web_contents; | 147 content::WebContents* source_web_contents; |
| 148 int64 source_frame_id; | 148 content::RenderFrameHost* source_frame_host; |
| 149 bool source_frame_is_main_frame; | |
| 150 content::WebContents* target_web_contents; | 149 content::WebContents* target_web_contents; |
| 151 GURL target_url; | 150 GURL target_url; |
| 152 }; | 151 }; |
| 153 | 152 |
| 154 // TabStripModelObserver implementation. | 153 // TabStripModelObserver implementation. |
| 155 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 154 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 156 content::WebContents* old_contents, | 155 content::WebContents* old_contents, |
| 157 content::WebContents* new_contents, | 156 content::WebContents* new_contents, |
| 158 int index) OVERRIDE; | 157 int index) OVERRIDE; |
| 159 | 158 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 235 |
| 237 // Created lazily upon OnListenerAdded. | 236 // Created lazily upon OnListenerAdded. |
| 238 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; | 237 scoped_ptr<WebNavigationEventRouter> web_navigation_event_router_; |
| 239 | 238 |
| 240 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); | 239 DISALLOW_COPY_AND_ASSIGN(WebNavigationAPI); |
| 241 }; | 240 }; |
| 242 | 241 |
| 243 } // namespace extensions | 242 } // namespace extensions |
| 244 | 243 |
| 245 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ | 244 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_H_ |
| OLD | NEW |