Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 nav_event->frame_id = navigation_handle->GetFrameTreeNodeId(); | 137 nav_event->frame_id = navigation_handle->GetFrameTreeNodeId(); |
| 138 | 138 |
| 139 // If there was a URL previously committed in the current RenderFrameHost, | 139 // If there was a URL previously committed in the current RenderFrameHost, |
| 140 // set it as the source url of this navigation. Otherwise, this is the | 140 // set it as the source url of this navigation. Otherwise, this is the |
| 141 // first url going to commit in this frame. We set navigation_handle's URL as | 141 // first url going to commit in this frame. We set navigation_handle's URL as |
| 142 // the source url. | 142 // the source url. |
| 143 // TODO(jialiul): source_url, source_tab_id, and source_main_frame_url may be | 143 // TODO(jialiul): source_url, source_tab_id, and source_main_frame_url may be |
| 144 // incorrect when another frame is targeting this frame. Need to refine this | 144 // incorrect when another frame is targeting this frame. Need to refine this |
| 145 // logic after the true initiator details are added to NavigationHandle | 145 // logic after the true initiator details are added to NavigationHandle |
| 146 // (https://crbug.com/651895). | 146 // (https://crbug.com/651895). |
| 147 int current_process_id = | |
| 148 navigation_handle->GetStartingSiteInstance()->GetProcess()->GetID(); | |
|
Charlie Reis
2017/05/01 21:56:59
This is only ok because it matches the limitations
| |
| 147 content::RenderFrameHost* current_frame_host = | 149 content::RenderFrameHost* current_frame_host = |
| 148 navigation_handle->GetWebContents()->FindFrameByFrameTreeNodeId( | 150 navigation_handle->GetWebContents()->FindFrameByFrameTreeNodeId( |
| 149 nav_event->frame_id); | 151 nav_event->frame_id, current_process_id); |
| 150 // For browser initiated navigation (e.g. from address bar or bookmark), we | 152 // For browser initiated navigation (e.g. from address bar or bookmark), we |
| 151 // don't fill the source_url to prevent attributing navigation to the last | 153 // don't fill the source_url to prevent attributing navigation to the last |
| 152 // committed navigation. | 154 // committed navigation. |
| 153 if (navigation_handle->IsRendererInitiated() && current_frame_host && | 155 if (navigation_handle->IsRendererInitiated() && current_frame_host && |
| 154 current_frame_host->GetLastCommittedURL().is_valid()) { | 156 current_frame_host->GetLastCommittedURL().is_valid()) { |
| 155 nav_event->source_url = | 157 nav_event->source_url = |
| 156 SafeBrowsingNavigationObserverManager::ClearEmptyRef( | 158 SafeBrowsingNavigationObserverManager::ClearEmptyRef( |
| 157 current_frame_host->GetLastCommittedURL()); | 159 current_frame_host->GetLastCommittedURL()); |
| 158 } | 160 } |
| 159 nav_event->original_request_url = | 161 nav_event->original_request_url = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 ui::PageTransition transition, | 251 ui::PageTransition transition, |
| 250 bool started_from_context_menu, | 252 bool started_from_context_menu, |
| 251 bool renderer_initiated) { | 253 bool renderer_initiated) { |
| 252 manager_->RecordNewWebContents( | 254 manager_->RecordNewWebContents( |
| 253 web_contents(), source_render_frame_host->GetProcess()->GetID(), | 255 web_contents(), source_render_frame_host->GetProcess()->GetID(), |
| 254 source_render_frame_host->GetRoutingID(), url, new_contents, | 256 source_render_frame_host->GetRoutingID(), url, new_contents, |
| 255 renderer_initiated); | 257 renderer_initiated); |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace safe_browsing | 260 } // namespace safe_browsing |
| OLD | NEW |