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

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

Issue 2892483002: Lose the user gesture expiration check on IdentifyReferrerChainByWebContents (Closed)
Patch Set: Created 3 years, 7 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // Remove entry from |user_gesture_map_| as a user_gesture is consumed by 249 // Remove entry from |user_gesture_map_| as a user_gesture is consumed by
250 // a navigation event. 250 // a navigation event.
251 if (it != user_gesture_map_.end() && timestamp >= it->second) 251 if (it != user_gesture_map_.end() && timestamp >= it->second)
252 user_gesture_map_.erase(it); 252 user_gesture_map_.erase(it);
253 } 253 }
254 254
255 bool SafeBrowsingNavigationObserverManager::HasUserGesture( 255 bool SafeBrowsingNavigationObserverManager::HasUserGesture(
256 content::WebContents* web_contents) { 256 content::WebContents* web_contents) {
257 if (!web_contents) 257 if (!web_contents)
258 return false; 258 return false;
259 auto it = user_gesture_map_.find(web_contents); 259 if (user_gesture_map_.find(web_contents) != user_gesture_map_.end())
lpz 2017/05/17 20:22:04 just to confirm my understanding. It's ok to remov
Jialiu Lin 2017/05/17 20:58:24 Yes, that's right.
260 if (it != user_gesture_map_.end() &&
261 !IsEventExpired(it->second, kUserGestureTTLInSecond)) {
262 return true; 260 return true;
263 }
264 return false; 261 return false;
265 } 262 }
266 263
267 void SafeBrowsingNavigationObserverManager::RecordHostToIpMapping( 264 void SafeBrowsingNavigationObserverManager::RecordHostToIpMapping(
268 const std::string& host, 265 const std::string& host,
269 const std::string& ip) { 266 const std::string& ip) {
270 auto insert_result = host_to_ip_map_.insert( 267 auto insert_result = host_to_ip_map_.insert(
271 std::make_pair(host, std::vector<ResolvedIPAddress>())); 268 std::make_pair(host, std::vector<ResolvedIPAddress>()));
272 if (!insert_result.second) { 269 if (!insert_result.second) {
273 // host_to_ip_map already contains this key. 270 // host_to_ip_map already contains this key.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void SafeBrowsingNavigationObserverManager::CleanUpNavigationEvents() { 429 void SafeBrowsingNavigationObserverManager::CleanUpNavigationEvents() {
433 std::size_t removal_count = navigation_event_list_.CleanUpNavigationEvents(); 430 std::size_t removal_count = navigation_event_list_.CleanUpNavigationEvents();
434 431
435 UMA_HISTOGRAM_COUNTS_10000( 432 UMA_HISTOGRAM_COUNTS_10000(
436 "SafeBrowsing.NavigationObserver.NavigationEventCleanUpCount", 433 "SafeBrowsing.NavigationObserver.NavigationEventCleanUpCount",
437 removal_count); 434 removal_count);
438 } 435 }
439 436
440 void SafeBrowsingNavigationObserverManager::CleanUpUserGestures() { 437 void SafeBrowsingNavigationObserverManager::CleanUpUserGestures() {
441 for (auto it = user_gesture_map_.begin(); it != user_gesture_map_.end();) { 438 for (auto it = user_gesture_map_.begin(); it != user_gesture_map_.end();) {
442 if (IsEventExpired(it->second, kUserGestureTTLInSecond)) 439 if (IsEventExpired(it->second, kNavigationFootprintTTLInSecond))
443 it = user_gesture_map_.erase(it); 440 it = user_gesture_map_.erase(it);
444 else 441 else
445 ++it; 442 ++it;
446 } 443 }
447 } 444 }
448 445
449 void SafeBrowsingNavigationObserverManager::CleanUpIpAddresses() { 446 void SafeBrowsingNavigationObserverManager::CleanUpIpAddresses() {
450 std::size_t remove_count = 0; 447 std::size_t remove_count = 0;
451 for (auto it = host_to_ip_map_.begin(); it != host_to_ip_map_.end();) { 448 for (auto it = host_to_ip_map_.begin(); it != host_to_ip_map_.end();) {
452 std::size_t size_before_removal = it->second.size(); 449 std::size_t size_before_removal = it->second.size();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 out_result)); 579 out_result));
583 // Stop searching if the size of out_referrer_chain already reached its 580 // Stop searching if the size of out_referrer_chain already reached its
584 // limit. 581 // limit.
585 if (out_referrer_chain->size() == kReferrerChainMaxLength) 582 if (out_referrer_chain->size() == kReferrerChainMaxLength)
586 return; 583 return;
587 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url; 584 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url;
588 } 585 }
589 } 586 }
590 587
591 } // namespace safe_browsing 588 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698