Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc

Issue 2644133005: Include all server redirects in referrer chain (Closed)
Patch Set: proto change and adding two histograms Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_manager .h" 5 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 void SafeBrowsingNavigationObserverManager::RecordHostToIpMapping( 159 void SafeBrowsingNavigationObserverManager::RecordHostToIpMapping(
160 const std::string& host, 160 const std::string& host,
161 const std::string& ip) { 161 const std::string& ip) {
162 auto insert_result = host_to_ip_map_.insert( 162 auto insert_result = host_to_ip_map_.insert(
163 std::make_pair(host, std::vector<ResolvedIPAddress>())); 163 std::make_pair(host, std::vector<ResolvedIPAddress>()));
164 if (!insert_result.second) { 164 if (!insert_result.second) {
165 // host_to_ip_map already contains this key. 165 // host_to_ip_map already contains this key.
166 // If this IP is already in the vector, we update its timestamp. 166 // If this IP is already in the vector, we update its timestamp.
167 for (auto& vector_entry : insert_result.first->second) { 167 for (auto& vector_entry : insert_result.first->second) {
168 if (vector_entry.ip == host) { 168 if (vector_entry.ip == ip) {
169 vector_entry.timestamp = base::Time::Now(); 169 vector_entry.timestamp = base::Time::Now();
170 return; 170 return;
171 } 171 }
172 } 172 }
173 } 173 }
174 // If this is a new IP of this host, and we added to the end of the vector. 174 // If this is a new IP of this host, and we added to the end of the vector.
175 insert_result.first->second.push_back( 175 insert_result.first->second.push_back(
176 ResolvedIPAddress(base::Time::Now(), ip)); 176 ResolvedIPAddress(base::Time::Now(), ip));
177 } 177 }
178 178
(...skipping 22 matching lines...) Expand all
201 NavigationEvent* nav_event = FindNavigationEvent( 201 NavigationEvent* nav_event = FindNavigationEvent(
202 target_url, 202 target_url,
203 GURL(), 203 GURL(),
204 target_tab_id); 204 target_tab_id);
205 if (!nav_event) { 205 if (!nav_event) {
206 // We cannot find a single navigation event related to this download. 206 // We cannot find a single navigation event related to this download.
207 return NAVIGATION_EVENT_NOT_FOUND; 207 return NAVIGATION_EVENT_NOT_FOUND;
208 } 208 }
209 AttributionResult result = SUCCESS; 209 AttributionResult result = SUCCESS;
210 AddToReferrerChain(out_referrer_chain, nav_event, 210 AddToReferrerChain(out_referrer_chain, nav_event,
211 GURL(),
211 ReferrerChainEntry::DOWNLOAD_URL); 212 ReferrerChainEntry::DOWNLOAD_URL);
212 int user_gesture_count = 0; 213 int user_gesture_count = 0;
213 GetRemainingReferrerChain( 214 GetRemainingReferrerChain(
214 nav_event, 215 nav_event,
215 user_gesture_count, 216 user_gesture_count,
216 user_gesture_count_limit, 217 user_gesture_count_limit,
217 out_referrer_chain, 218 out_referrer_chain,
218 &result); 219 &result);
219 return result; 220 return result;
220 } 221 }
221 222
222 SafeBrowsingNavigationObserverManager::AttributionResult 223 SafeBrowsingNavigationObserverManager::AttributionResult
223 SafeBrowsingNavigationObserverManager::IdentifyReferrerChainForPPAPIDownload( 224 SafeBrowsingNavigationObserverManager::IdentifyReferrerChainForPPAPIDownload(
224 const GURL& initiating_frame_url, 225 const GURL& initiating_frame_url,
226 const GURL& initiating_main_frame_url,
225 int tab_id, 227 int tab_id,
226 bool has_user_gesture, 228 bool has_user_gesture,
227 int user_gesture_count_limit, 229 int user_gesture_count_limit,
228 ReferrerChain* out_referrer_chain) { 230 ReferrerChain* out_referrer_chain) {
229 if (!initiating_frame_url.is_valid()) 231 if (!initiating_frame_url.is_valid())
230 return INVALID_URL; 232 return INVALID_URL;
231 233
232 NavigationEvent* nav_event = 234 NavigationEvent* nav_event =
233 FindNavigationEvent(initiating_frame_url, GURL(), tab_id); 235 FindNavigationEvent(initiating_frame_url, GURL(), tab_id);
234 if (!nav_event) { 236 if (!nav_event) {
235 // We cannot find a single navigation event related to this download. 237 // We cannot find a single navigation event related to this download.
236 return NAVIGATION_EVENT_NOT_FOUND; 238 return NAVIGATION_EVENT_NOT_FOUND;
237 } 239 }
238 240
239 AttributionResult result = SUCCESS; 241 AttributionResult result = SUCCESS;
240 242
241 int user_gesture_count = 0; 243 int user_gesture_count = 0;
242 // If this initiating_frame has user gesture, we consider this as the landing 244 // If this initiating_frame has user gesture, we consider this as the landing
243 // page of the PPAPI download. 245 // page of the PPAPI download.
244 if (has_user_gesture) { 246 if (has_user_gesture) {
245 user_gesture_count = 1; 247 user_gesture_count = 1;
246 AddToReferrerChain(out_referrer_chain, nav_event, 248 AddToReferrerChain(out_referrer_chain, nav_event, initiating_main_frame_url,
247 GetURLTypeAndAdjustAttributionResult( 249 GetURLTypeAndAdjustAttributionResult(
248 user_gesture_count == user_gesture_count_limit, 250 user_gesture_count == user_gesture_count_limit,
249 &result)); 251 &result));
250 } else { 252 } else {
251 AddToReferrerChain(out_referrer_chain, nav_event, 253 AddToReferrerChain(out_referrer_chain, nav_event, initiating_main_frame_url,
252 nav_event->has_server_redirect 254 ReferrerChainEntry::CLIENT_REDIRECT);
253 ? ReferrerChainEntry::SERVER_REDIRECT
254 : ReferrerChainEntry::CLIENT_REDIRECT);
255 } 255 }
256 256
257 GetRemainingReferrerChain( 257 GetRemainingReferrerChain(
258 nav_event, 258 nav_event,
259 user_gesture_count, 259 user_gesture_count,
260 user_gesture_count_limit, 260 user_gesture_count_limit,
261 out_referrer_chain, 261 out_referrer_chain,
262 &result); 262 &result);
263 return result; 263 return result;
264 } 264 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 NavigationEvent nav_event; 297 NavigationEvent nav_event;
298 if (rfh) { 298 if (rfh) {
299 nav_event.source_url = SafeBrowsingNavigationObserverManager::ClearEmptyRef( 299 nav_event.source_url = SafeBrowsingNavigationObserverManager::ClearEmptyRef(
300 rfh->GetLastCommittedURL()); 300 rfh->GetLastCommittedURL());
301 } 301 }
302 nav_event.source_tab_id = SessionTabHelper::IdForTab(source_contents); 302 nav_event.source_tab_id = SessionTabHelper::IdForTab(source_contents);
303 nav_event.source_main_frame_url = 303 nav_event.source_main_frame_url =
304 SafeBrowsingNavigationObserverManager::ClearEmptyRef( 304 SafeBrowsingNavigationObserverManager::ClearEmptyRef(
305 source_contents->GetLastCommittedURL()); 305 source_contents->GetLastCommittedURL());
306 nav_event.original_request_url = target_url; 306 nav_event.original_request_url = target_url;
307 nav_event.destination_url = target_url;
308 nav_event.target_tab_id = SessionTabHelper::IdForTab(target_contents); 307 nav_event.target_tab_id = SessionTabHelper::IdForTab(target_contents);
309 nav_event.frame_id = rfh ? rfh->GetFrameTreeNodeId() : -1; 308 nav_event.frame_id = rfh ? rfh->GetFrameTreeNodeId() : -1;
310 auto it = user_gesture_map_.find(source_contents); 309 auto it = user_gesture_map_.find(source_contents);
311 if (it != user_gesture_map_.end() && 310 if (it != user_gesture_map_.end() &&
312 !SafeBrowsingNavigationObserverManager::IsUserGestureExpired( 311 !SafeBrowsingNavigationObserverManager::IsUserGestureExpired(
313 it->second)) { 312 it->second)) {
314 nav_event.is_user_initiated = true; 313 nav_event.is_user_initiated = true;
315 OnUserGestureConsumed(it->first, it->second); 314 OnUserGestureConsumed(it->first, it->second);
316 } else { 315 } else {
317 nav_event.is_user_initiated = false; 316 nav_event.is_user_initiated = false;
318 } 317 }
319 318
320 auto insertion_result = navigation_map_.insert( 319 auto insertion_result = navigation_map_.insert(
321 std::make_pair(target_url, std::vector<NavigationEvent>())); 320 std::make_pair(target_url, std::vector<NavigationEvent>()));
322 insertion_result.first->second.push_back(std::move(nav_event)); 321 insertion_result.first->second.push_back(std::move(nav_event));
323 } 322 }
324 323
325 void SafeBrowsingNavigationObserverManager::CleanUpNavigationEvents() { 324 void SafeBrowsingNavigationObserverManager::CleanUpNavigationEvents() {
326 // Remove any stale NavigationEnvent, if it is older than 325 // Remove any stale NavigationEnvent, if it is older than
327 // kNavigationFootprintTTLInSecond. 326 // kNavigationFootprintTTLInSecond.
327 std::size_t remove_count = 0;
328 for (auto it = navigation_map_.begin(); it != navigation_map_.end();) { 328 for (auto it = navigation_map_.begin(); it != navigation_map_.end();) {
329 std::size_t size_before_removal = it->second.size();
329 it->second.erase(std::remove_if(it->second.begin(), it->second.end(), 330 it->second.erase(std::remove_if(it->second.begin(), it->second.end(),
330 [](const NavigationEvent& nav_event) { 331 [](const NavigationEvent& nav_event) {
331 return IsEventExpired( 332 return IsEventExpired(
332 nav_event.last_updated, 333 nav_event.last_updated,
333 kNavigationFootprintTTLInSecond); 334 kNavigationFootprintTTLInSecond);
334 }), 335 }),
335 it->second.end()); 336 it->second.end());
336 if (it->second.size() == 0) 337 std::size_t size_after_removal = it->second.size();
338 remove_count += (size_before_removal-size_after_removal);
Nathan Parker 2017/01/27 22:53:38 nit: spaces around - here and below
Jialiu Lin 2017/01/27 23:25:06 Yes. Did git cl format.
339 if (size_after_removal == 0)
337 it = navigation_map_.erase(it); 340 it = navigation_map_.erase(it);
338 else 341 else
339 ++it; 342 ++it;
340 } 343 }
344 UMA_HISTOGRAM_COUNTS_10000(
345 "SafeBrowsing.NavigationObserver.NavigationEventCleanUpCount",
346 remove_count);
341 } 347 }
342 348
343 void SafeBrowsingNavigationObserverManager::CleanUpUserGestures() { 349 void SafeBrowsingNavigationObserverManager::CleanUpUserGestures() {
344 for (auto it = user_gesture_map_.begin(); it != user_gesture_map_.end();) { 350 for (auto it = user_gesture_map_.begin(); it != user_gesture_map_.end();) {
345 if (IsEventExpired(it->second, kUserGestureTTLInSecond)) 351 if (IsEventExpired(it->second, kUserGestureTTLInSecond))
346 it = user_gesture_map_.erase(it); 352 it = user_gesture_map_.erase(it);
347 else 353 else
348 ++it; 354 ++it;
349 } 355 }
350 } 356 }
351 357
352 void SafeBrowsingNavigationObserverManager::CleanUpIpAddresses() { 358 void SafeBrowsingNavigationObserverManager::CleanUpIpAddresses() {
359 std::size_t remove_count = 0;
353 for (auto it = host_to_ip_map_.begin(); it != host_to_ip_map_.end();) { 360 for (auto it = host_to_ip_map_.begin(); it != host_to_ip_map_.end();) {
361 std::size_t size_before_removal = it->second.size();
354 it->second.erase(std::remove_if(it->second.begin(), it->second.end(), 362 it->second.erase(std::remove_if(it->second.begin(), it->second.end(),
355 [](const ResolvedIPAddress& resolved_ip) { 363 [](const ResolvedIPAddress& resolved_ip) {
356 return IsEventExpired( 364 return IsEventExpired(
357 resolved_ip.timestamp, 365 resolved_ip.timestamp,
358 kNavigationFootprintTTLInSecond); 366 kNavigationFootprintTTLInSecond);
359 }), 367 }),
360 it->second.end()); 368 it->second.end());
361 if (it->second.size() == 0) 369 std::size_t size_after_removal = it->second.size();
370 remove_count += (size_before_removal-size_after_removal);
371 if (size_after_removal == 0)
362 it = host_to_ip_map_.erase(it); 372 it = host_to_ip_map_.erase(it);
363 else 373 else
364 ++it; 374 ++it;
365 } 375 }
376 UMA_HISTOGRAM_COUNTS_10000(
377 "SafeBrowsing.NavigationObserver.IPAddressCleanUpCount",
378 remove_count);
366 } 379 }
367 380
368 bool SafeBrowsingNavigationObserverManager::IsCleanUpScheduled() const { 381 bool SafeBrowsingNavigationObserverManager::IsCleanUpScheduled() const {
369 return cleanup_timer_.IsRunning(); 382 return cleanup_timer_.IsRunning();
370 } 383 }
371 384
372 void SafeBrowsingNavigationObserverManager::ScheduleNextCleanUpAfterInterval( 385 void SafeBrowsingNavigationObserverManager::ScheduleNextCleanUpAfterInterval(
373 base::TimeDelta interval) { 386 base::TimeDelta interval) {
374 DCHECK_GT(interval, base::TimeDelta()); 387 DCHECK_GT(interval, base::TimeDelta());
375 cleanup_timer_.Stop(); 388 cleanup_timer_.Stop();
(...skipping 14 matching lines...) Expand all
390 GURL search_url = 403 GURL search_url =
391 target_url.is_empty() ? target_main_frame_url : target_url; 404 target_url.is_empty() ? target_main_frame_url : target_url;
392 auto it = navigation_map_.find(search_url); 405 auto it = navigation_map_.find(search_url);
393 if (it == navigation_map_.end()) 406 if (it == navigation_map_.end())
394 return nullptr; 407 return nullptr;
395 408
396 // Since navigation events are recorded in chronological order, we traverse 409 // Since navigation events are recorded in chronological order, we traverse
397 // the vector in reverse order to get the latest match. 410 // the vector in reverse order to get the latest match.
398 for (auto rit = it->second.rbegin(); rit != it->second.rend(); ++rit) { 411 for (auto rit = it->second.rbegin(); rit != it->second.rend(); ++rit) {
399 // If tab id is not valid, we only compare url, otherwise we compare both. 412 // If tab id is not valid, we only compare url, otherwise we compare both.
400 if (rit->destination_url == search_url && 413 if (rit->GetDestinationUrl() == search_url &&
401 (target_tab_id == -1 || rit->target_tab_id == target_tab_id)) { 414 (target_tab_id == -1 || rit->target_tab_id == target_tab_id)) {
402 // If both source_url and source_main_frame_url are empty, and this 415 // If both source_url and source_main_frame_url are empty, and this
403 // navigation is not triggered by user, a retargeting navigation probably 416 // navigation is not triggered by user, a retargeting navigation probably
404 // causes this navigation. In this case, we skip this navigation event and 417 // causes this navigation. In this case, we skip this navigation event and
405 // looks for the retargeting navigation event. 418 // looks for the retargeting navigation event.
406 if (rit->source_url.is_empty() && rit->source_main_frame_url.is_empty() && 419 if (rit->source_url.is_empty() && rit->source_main_frame_url.is_empty() &&
407 !rit->is_user_initiated) { 420 !rit->is_user_initiated) {
408 // If there is a server redirection immediately after retargeting, we 421 // If there is a server redirection immediately after retargeting, we
409 // need to adjust our search url to the original request. 422 // need to adjust our search url to the original request.
410 if (rit->has_server_redirect){ 423 if (!rit->server_redirect_urls.empty()){
411 NavigationEvent* retargeting_nav_event = 424 NavigationEvent* retargeting_nav_event =
412 FindNavigationEvent(rit->original_request_url, 425 FindNavigationEvent(rit->original_request_url,
413 GURL(), 426 GURL(),
414 rit->target_tab_id); 427 rit->target_tab_id);
415 if (!retargeting_nav_event) 428 if (!retargeting_nav_event)
416 return nullptr; 429 return nullptr;
417 // Adjust retargeting navigation event's attributes. 430 // Adjust retargeting navigation event's attributes.
418 retargeting_nav_event->has_server_redirect = true; 431 retargeting_nav_event->server_redirect_urls.push_back(
419 retargeting_nav_event->destination_url = search_url; 432 std::move(search_url));
420 return retargeting_nav_event; 433 return retargeting_nav_event;
421 } else { 434 } else {
422 continue; 435 continue;
423 } 436 }
424 } else { 437 } else {
425 return &*rit; 438 return &*rit;
426 } 439 }
427 } 440 }
428 } 441 }
429 return nullptr; 442 return nullptr;
430 } 443 }
431 444
432 void SafeBrowsingNavigationObserverManager::AddToReferrerChain( 445 void SafeBrowsingNavigationObserverManager::AddToReferrerChain(
433 ReferrerChain* referrer_chain, 446 ReferrerChain* referrer_chain,
434 NavigationEvent* nav_event, 447 NavigationEvent* nav_event,
448 const GURL& destination_main_frame_url,
435 ReferrerChainEntry::URLType type) { 449 ReferrerChainEntry::URLType type) {
436 std::unique_ptr<ReferrerChainEntry> referrer_chain_entry = 450 std::unique_ptr<ReferrerChainEntry> referrer_chain_entry =
437 base::MakeUnique<ReferrerChainEntry>(); 451 base::MakeUnique<ReferrerChainEntry>();
438 referrer_chain_entry->set_url(nav_event->destination_url.spec()); 452 const GURL destination_url = nav_event->GetDestinationUrl();
453 referrer_chain_entry->set_url(destination_url.spec());
454 if (destination_main_frame_url.is_valid() &&
455 destination_url != destination_main_frame_url)
456 referrer_chain_entry->set_main_frame_url(destination_main_frame_url.spec());
439 referrer_chain_entry->set_type(type); 457 referrer_chain_entry->set_type(type);
440 auto ip_it = host_to_ip_map_.find(nav_event->destination_url.host()); 458 auto ip_it = host_to_ip_map_.find(destination_url.host());
441 if (ip_it != host_to_ip_map_.end()) { 459 if (ip_it != host_to_ip_map_.end()) {
442 for (ResolvedIPAddress entry : ip_it->second) { 460 for (ResolvedIPAddress entry : ip_it->second) {
443 referrer_chain_entry->add_ip_addresses(entry.ip); 461 referrer_chain_entry->add_ip_addresses(entry.ip);
444 } 462 }
445 } 463 }
446 // Since we only track navigation to landing referrer, we will not log the 464 // Since we only track navigation to landing referrer, we will not log the
447 // referrer of the landing referrer page. 465 // referrer of the landing referrer page.
448 if (type != ReferrerChainEntry::LANDING_REFERRER) { 466 if (type != ReferrerChainEntry::LANDING_REFERRER) {
449 referrer_chain_entry->set_referrer_url(nav_event->source_url.spec()); 467 referrer_chain_entry->set_referrer_url(nav_event->source_url.spec());
450 referrer_chain_entry->set_referrer_main_frame_url( 468 // Only set |referrer_main_frame_url| if it is diff from |referrer_url|.
451 nav_event->source_main_frame_url.spec()); 469 if (nav_event->source_main_frame_url.is_valid() &&
470 nav_event->source_url != nav_event->source_main_frame_url) {
471 referrer_chain_entry->set_referrer_main_frame_url(
472 nav_event->source_main_frame_url.spec());
473 }
452 } 474 }
453 referrer_chain_entry->set_is_retargeting(nav_event->source_tab_id != 475 referrer_chain_entry->set_is_retargeting(nav_event->source_tab_id !=
454 nav_event->target_tab_id); 476 nav_event->target_tab_id);
455 referrer_chain_entry->set_navigation_time_msec( 477 referrer_chain_entry->set_navigation_time_msec(
456 nav_event->last_updated.ToJavaTime()); 478 nav_event->last_updated.ToJavaTime());
479 if (!nav_event->server_redirect_urls.empty()) {
480 // The first entry in |server_redirect_chain| should be the original request
481 // url.
482 ReferrerChainEntry::ServerRedirect* server_redirect =
483 referrer_chain_entry->add_server_redirect_chain();
484 server_redirect->set_url(nav_event->original_request_url.spec());
485 for (const GURL& redirect: nav_event->server_redirect_urls) {
486 server_redirect = referrer_chain_entry->add_server_redirect_chain();
487 server_redirect->set_url(redirect.spec());
488 }
489 }
457 referrer_chain->push_back(std::move(referrer_chain_entry)); 490 referrer_chain->push_back(std::move(referrer_chain_entry));
458 } 491 }
459 492
460 void SafeBrowsingNavigationObserverManager::GetRemainingReferrerChain( 493 void SafeBrowsingNavigationObserverManager::GetRemainingReferrerChain(
461 NavigationEvent* last_nav_event_traced, 494 NavigationEvent* last_nav_event_traced,
462 int current_user_gesture_count, 495 int current_user_gesture_count,
463 int user_gesture_count_limit, 496 int user_gesture_count_limit,
464 ReferrerChain* out_referrer_chain, 497 ReferrerChain* out_referrer_chain,
465 SafeBrowsingNavigationObserverManager::AttributionResult* out_result) { 498 SafeBrowsingNavigationObserverManager::AttributionResult* out_result) {
466 499 GURL last_main_frame_url_traced(
500 last_nav_event_traced->source_main_frame_url);
Nathan Parker 2017/01/27 22:53:38 What's the different between source_main_frame_url
Jialiu Lin 2017/01/27 23:25:07 Yes, that's right. From the campaign example auk@
467 while (current_user_gesture_count < user_gesture_count_limit) { 501 while (current_user_gesture_count < user_gesture_count_limit) {
468 // Back trace to the next nav_event that was initiated by the user. 502 // Back trace to the next nav_event that was initiated by the user.
469 while (!last_nav_event_traced->is_user_initiated) { 503 while (!last_nav_event_traced->is_user_initiated) {
470 last_nav_event_traced = 504 last_nav_event_traced =
471 FindNavigationEvent(last_nav_event_traced->source_url, 505 FindNavigationEvent(last_nav_event_traced->source_url,
472 last_nav_event_traced->source_main_frame_url, 506 last_nav_event_traced->source_main_frame_url,
473 last_nav_event_traced->source_tab_id); 507 last_nav_event_traced->source_tab_id);
474 if (!last_nav_event_traced) 508 if (!last_nav_event_traced)
475 return; 509 return;
476 AddToReferrerChain(out_referrer_chain, last_nav_event_traced, 510 AddToReferrerChain(out_referrer_chain, last_nav_event_traced,
477 last_nav_event_traced->has_server_redirect 511 last_main_frame_url_traced,
Nathan Parker 2017/01/27 22:53:38 Do we no longer need SERVER_REDIRECT?
Jialiu Lin 2017/01/27 23:25:06 We don't need SERVER_REDIRECT, since this can be d
478 ? ReferrerChainEntry::SERVER_REDIRECT 512 ReferrerChainEntry::CLIENT_REDIRECT);
479 : ReferrerChainEntry::CLIENT_REDIRECT); 513 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url;
480 } 514 }
481 515
482 current_user_gesture_count++; 516 current_user_gesture_count++;
483 517
484 518
485 // If the source_url and source_main_frame_url of current navigation event 519 // If the source_url and source_main_frame_url of current navigation event
486 // are empty, and is_user_initiated is true, this is a browser initiated 520 // are empty, and is_user_initiated is true, this is a browser initiated
487 // navigation (e.g. trigged by typing in address bar, clicking on bookmark, 521 // navigation (e.g. trigged by typing in address bar, clicking on bookmark,
488 // etc). We reached the end of the referrer chain. 522 // etc). We reached the end of the referrer chain.
489 if (last_nav_event_traced->source_url.is_empty() && 523 if (last_nav_event_traced->source_url.is_empty() &&
490 last_nav_event_traced->source_main_frame_url.is_empty()) { 524 last_nav_event_traced->source_main_frame_url.is_empty()) {
491 DCHECK(last_nav_event_traced->is_user_initiated); 525 DCHECK(last_nav_event_traced->is_user_initiated);
492 return; 526 return;
493 } 527 }
494 528
495 last_nav_event_traced = 529 last_nav_event_traced =
496 FindNavigationEvent(last_nav_event_traced->source_url, 530 FindNavigationEvent(last_nav_event_traced->source_url,
497 last_nav_event_traced->source_main_frame_url, 531 last_nav_event_traced->source_main_frame_url,
498 last_nav_event_traced->source_tab_id); 532 last_nav_event_traced->source_tab_id);
499 if (!last_nav_event_traced) 533 if (!last_nav_event_traced)
500 return; 534 return;
501 535
502 AddToReferrerChain(out_referrer_chain, last_nav_event_traced, 536 AddToReferrerChain(out_referrer_chain, last_nav_event_traced,
537 last_main_frame_url_traced,
503 GetURLTypeAndAdjustAttributionResult( 538 GetURLTypeAndAdjustAttributionResult(
504 current_user_gesture_count == 539 current_user_gesture_count ==
505 user_gesture_count_limit, 540 user_gesture_count_limit,
506 out_result)); 541 out_result));
542 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url;
507 } 543 }
508 } 544 }
509 545
510 } // namespace safe_browsing 546 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698