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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 return; | 114 return; |
115 | 115 |
116 helpers::DispatchOnTabReplaced(old_contents, profile_, new_contents); | 116 helpers::DispatchOnTabReplaced(old_contents, profile_, new_contents); |
117 } | 117 } |
118 | 118 |
119 void WebNavigationEventRouter::Observe( | 119 void WebNavigationEventRouter::Observe( |
120 int type, | 120 int type, |
121 const content::NotificationSource& source, | 121 const content::NotificationSource& source, |
122 const content::NotificationDetails& details) { | 122 const content::NotificationDetails& details) { |
123 switch (type) { | 123 switch (type) { |
124 case chrome::NOTIFICATION_RETARGETING: { | 124 case chrome::NOTIFICATION_RETARGETING: { |
Charlie Reis
2017/02/16 00:21:10
I was curious if this was dead, but apparently it'
Patrick Noland
2017/02/16 00:57:12
Acknowledged.
| |
125 Profile* profile = content::Source<Profile>(source).ptr(); | 125 Profile* profile = content::Source<Profile>(source).ptr(); |
126 if (profile->GetOriginalProfile() == profile_) { | 126 if (profile->GetOriginalProfile() == profile_) { |
127 Retargeting( | 127 Retargeting( |
128 content::Details<const RetargetingDetails>(details).ptr()); | 128 content::Details<const RetargetingDetails>(details).ptr()); |
129 } | 129 } |
130 break; | 130 break; |
131 } | 131 } |
132 | 132 |
133 case chrome::NOTIFICATION_TAB_ADDED: | 133 case chrome::NOTIFICATION_TAB_ADDED: |
134 TabAdded(content::Details<content::WebContents>(details).ptr()); | 134 TabAdded(content::Details<content::WebContents>(details).ptr()); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 } | 376 } |
377 navigation_state_.SetErrorOccurredInFrame(render_frame_host); | 377 navigation_state_.SetErrorOccurredInFrame(render_frame_host); |
378 } | 378 } |
379 | 379 |
380 void WebNavigationTabObserver::DidOpenRequestedURL( | 380 void WebNavigationTabObserver::DidOpenRequestedURL( |
381 content::WebContents* new_contents, | 381 content::WebContents* new_contents, |
382 content::RenderFrameHost* source_render_frame_host, | 382 content::RenderFrameHost* source_render_frame_host, |
383 const GURL& url, | 383 const GURL& url, |
384 const content::Referrer& referrer, | 384 const content::Referrer& referrer, |
385 WindowOpenDisposition disposition, | 385 WindowOpenDisposition disposition, |
386 ui::PageTransition transition) { | 386 ui::PageTransition transition, |
387 bool started_from_context_menu) { | |
387 if (!navigation_state_.CanSendEvents(source_render_frame_host)) | 388 if (!navigation_state_.CanSendEvents(source_render_frame_host)) |
388 return; | 389 return; |
389 | 390 |
390 // We only send the onCreatedNavigationTarget if we end up creating a new | 391 // We only send the onCreatedNavigationTarget if we end up creating a new |
391 // window. | 392 // window. |
392 if (disposition != WindowOpenDisposition::SINGLETON_TAB && | 393 if (disposition != WindowOpenDisposition::SINGLETON_TAB && |
393 disposition != WindowOpenDisposition::NEW_FOREGROUND_TAB && | 394 disposition != WindowOpenDisposition::NEW_FOREGROUND_TAB && |
394 disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB && | 395 disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB && |
395 disposition != WindowOpenDisposition::NEW_POPUP && | 396 disposition != WindowOpenDisposition::NEW_POPUP && |
396 disposition != WindowOpenDisposition::NEW_WINDOW && | 397 disposition != WindowOpenDisposition::NEW_WINDOW && |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 return g_factory.Pointer(); | 588 return g_factory.Pointer(); |
588 } | 589 } |
589 | 590 |
590 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 591 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
591 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 592 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
592 Profile::FromBrowserContext(browser_context_))); | 593 Profile::FromBrowserContext(browser_context_))); |
593 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 594 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
594 } | 595 } |
595 | 596 |
596 } // namespace extensions | 597 } // namespace extensions |
OLD | NEW |