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 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 if (details->source_render_frame_id == 0) | 147 if (details->source_render_frame_id == 0) |
148 return; | 148 return; |
149 WebNavigationTabObserver* tab_observer = | 149 WebNavigationTabObserver* tab_observer = |
150 WebNavigationTabObserver::Get(details->source_web_contents); | 150 WebNavigationTabObserver::Get(details->source_web_contents); |
151 if (!tab_observer) { | 151 if (!tab_observer) { |
152 // If you hit this DCHECK(), please add reproduction steps to | 152 // If you hit this DCHECK(), please add reproduction steps to |
153 // http://crbug.com/109464. | 153 // http://crbug.com/109464. |
154 DCHECK(GetViewType(details->source_web_contents) != VIEW_TYPE_TAB_CONTENTS); | 154 DCHECK(GetViewType(details->source_web_contents) != VIEW_TYPE_TAB_CONTENTS); |
155 return; | 155 return; |
156 } | 156 } |
157 | |
Patrick Noland
2017/02/14 01:16:16
remove this newline
| |
157 const FrameNavigationState& frame_navigation_state = | 158 const FrameNavigationState& frame_navigation_state = |
158 tab_observer->frame_navigation_state(); | 159 tab_observer->frame_navigation_state(); |
159 | 160 |
160 content::RenderFrameHost* frame_host = content::RenderFrameHost::FromID( | 161 content::RenderFrameHost* frame_host = content::RenderFrameHost::FromID( |
161 details->source_render_process_id, details->source_render_frame_id); | 162 details->source_render_process_id, details->source_render_frame_id); |
162 if (!frame_navigation_state.CanSendEvents(frame_host)) | 163 if (!frame_navigation_state.CanSendEvents(frame_host)) |
163 return; | 164 return; |
164 | 165 |
165 // If the WebContents isn't yet inserted into a tab strip, we need to delay | 166 // If the WebContents isn't yet inserted into a tab strip, we need to delay |
166 // the extension event until the WebContents is fully initialized. | 167 // the extension event until the WebContents is fully initialized. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 } | 377 } |
377 navigation_state_.SetErrorOccurredInFrame(render_frame_host); | 378 navigation_state_.SetErrorOccurredInFrame(render_frame_host); |
378 } | 379 } |
379 | 380 |
380 void WebNavigationTabObserver::DidOpenRequestedURL( | 381 void WebNavigationTabObserver::DidOpenRequestedURL( |
381 content::WebContents* new_contents, | 382 content::WebContents* new_contents, |
382 content::RenderFrameHost* source_render_frame_host, | 383 content::RenderFrameHost* source_render_frame_host, |
383 const GURL& url, | 384 const GURL& url, |
384 const content::Referrer& referrer, | 385 const content::Referrer& referrer, |
385 WindowOpenDisposition disposition, | 386 WindowOpenDisposition disposition, |
386 ui::PageTransition transition) { | 387 ui::PageTransition transition, |
388 bool started_from_context_menu) { | |
387 if (!navigation_state_.CanSendEvents(source_render_frame_host)) | 389 if (!navigation_state_.CanSendEvents(source_render_frame_host)) |
388 return; | 390 return; |
389 | 391 |
390 // We only send the onCreatedNavigationTarget if we end up creating a new | 392 // We only send the onCreatedNavigationTarget if we end up creating a new |
391 // window. | 393 // window. |
392 if (disposition != WindowOpenDisposition::SINGLETON_TAB && | 394 if (disposition != WindowOpenDisposition::SINGLETON_TAB && |
393 disposition != WindowOpenDisposition::NEW_FOREGROUND_TAB && | 395 disposition != WindowOpenDisposition::NEW_FOREGROUND_TAB && |
394 disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB && | 396 disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB && |
395 disposition != WindowOpenDisposition::NEW_POPUP && | 397 disposition != WindowOpenDisposition::NEW_POPUP && |
396 disposition != WindowOpenDisposition::NEW_WINDOW && | 398 disposition != WindowOpenDisposition::NEW_WINDOW && |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 return g_factory.Pointer(); | 589 return g_factory.Pointer(); |
588 } | 590 } |
589 | 591 |
590 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 592 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
591 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 593 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
592 Profile::FromBrowserContext(browser_context_))); | 594 Profile::FromBrowserContext(browser_context_))); |
593 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 595 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
594 } | 596 } |
595 | 597 |
596 } // namespace extensions | 598 } // namespace extensions |
OLD | NEW |