| Index: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
|
| diff --git a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
|
| index b6608faf9cc3eaa350831b9f5e05481282094e98..b4c0b3bd88108e3d02e404c5686e19932dfb1168 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc
|
| @@ -10,17 +10,13 @@
|
| #include "base/time/time.h"
|
| #include "base/timer/timer.h"
|
| #include "chrome/browser/browser_process.h"
|
| -#include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h"
|
| #include "chrome/browser/safe_browsing/safe_browsing_service.h"
|
| #include "chrome/browser/sessions/session_tab_helper.h"
|
| -#include "chrome/browser/tab_contents/retargeting_details.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "content/public/browser/navigation_details.h"
|
| -#include "content/public/browser/notification_service.h"
|
| -#include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -227,8 +223,6 @@ bool SafeBrowsingNavigationObserverManager::IsEnabledAndReady(
|
|
|
| SafeBrowsingNavigationObserverManager::SafeBrowsingNavigationObserverManager()
|
| : navigation_event_list_(kNavigationRecordMaxSize) {
|
| - registrar_.Add(this, chrome::NOTIFICATION_RETARGETING,
|
| - content::NotificationService::AllSources());
|
|
|
| // Schedule clean up in 2 minutes.
|
| ScheduleNextCleanUpAfterInterval(
|
| @@ -396,33 +390,22 @@ SafeBrowsingNavigationObserverManager::
|
| SafeBrowsingNavigationObserverManager::
|
| ~SafeBrowsingNavigationObserverManager() {}
|
|
|
| -void SafeBrowsingNavigationObserverManager::Observe(
|
| - int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) {
|
| - if (type == chrome::NOTIFICATION_RETARGETING)
|
| - RecordRetargeting(details);
|
| -}
|
| -
|
| -void SafeBrowsingNavigationObserverManager::RecordRetargeting(
|
| - const content::NotificationDetails& details) {
|
| - const RetargetingDetails* retargeting_detail =
|
| - content::Details<const RetargetingDetails>(details).ptr();
|
| - DCHECK(retargeting_detail);
|
| - content::WebContents* source_contents =
|
| - retargeting_detail->source_web_contents;
|
| - content::WebContents* target_contents =
|
| - retargeting_detail->target_web_contents;
|
| - DCHECK(source_contents);
|
| - DCHECK(target_contents);
|
| +void SafeBrowsingNavigationObserverManager::RecordNewWebContents(
|
| + content::WebContents* source_web_contents,
|
| + int source_render_process_id,
|
| + int source_render_frame_id,
|
| + GURL target_url,
|
| + content::WebContents* target_web_contents,
|
| + bool not_yet_in_tabstrip) {
|
| + DCHECK(source_web_contents);
|
| + DCHECK(target_web_contents);
|
|
|
| content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
|
| - retargeting_detail->source_render_process_id,
|
| - retargeting_detail->source_render_frame_id);
|
| + source_render_process_id, source_render_frame_id);
|
| // Remove the "#" at the end of URL, since it does not point to any actual
|
| // page fragment ID.
|
| - GURL target_url = SafeBrowsingNavigationObserverManager::ClearEmptyRef(
|
| - retargeting_detail->target_url);
|
| + GURL cleaned_target_url =
|
| + SafeBrowsingNavigationObserverManager::ClearEmptyRef(target_url);
|
|
|
| std::unique_ptr<NavigationEvent> nav_event =
|
| base::MakeUnique<NavigationEvent>();
|
| @@ -431,14 +414,14 @@ void SafeBrowsingNavigationObserverManager::RecordRetargeting(
|
| SafeBrowsingNavigationObserverManager::ClearEmptyRef(
|
| rfh->GetLastCommittedURL());
|
| }
|
| - nav_event->source_tab_id = SessionTabHelper::IdForTab(source_contents);
|
| + nav_event->source_tab_id = SessionTabHelper::IdForTab(source_web_contents);
|
| nav_event->source_main_frame_url =
|
| SafeBrowsingNavigationObserverManager::ClearEmptyRef(
|
| - source_contents->GetLastCommittedURL());
|
| - nav_event->original_request_url = target_url;
|
| - nav_event->target_tab_id = SessionTabHelper::IdForTab(target_contents);
|
| + source_web_contents->GetLastCommittedURL());
|
| + nav_event->original_request_url = cleaned_target_url;
|
| + nav_event->target_tab_id = SessionTabHelper::IdForTab(target_web_contents);
|
| nav_event->frame_id = rfh ? rfh->GetFrameTreeNodeId() : -1;
|
| - auto it = user_gesture_map_.find(source_contents);
|
| + auto it = user_gesture_map_.find(source_web_contents);
|
| if (it != user_gesture_map_.end() &&
|
| !SafeBrowsingNavigationObserverManager::IsUserGestureExpired(
|
| it->second)) {
|
|
|