OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/activity_log/uma_policy.h" | 5 #include "chrome/browser/extensions/activity_log/uma_policy.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/active_script_controller.h" | 10 #include "chrome/browser/extensions/active_script_controller.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 case Action::NUM_INJECTION_TYPES: | 179 case Action::NUM_INJECTION_TYPES: |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 } | 181 } |
182 | 182 |
183 return ret_bit; | 183 return ret_bit; |
184 } | 184 } |
185 | 185 |
186 void UmaPolicy::HistogramOnClose(const std::string& cleaned_url, | 186 void UmaPolicy::HistogramOnClose(const std::string& cleaned_url, |
187 content::WebContents* web_contents) { | 187 content::WebContents* web_contents) { |
188 // Let's try to avoid histogramming useless URLs. | 188 // Let's try to avoid histogramming useless URLs. |
189 if (cleaned_url.empty() || cleaned_url == content::kAboutBlankURL || | 189 if (cleaned_url.empty() || cleaned_url == url::kAboutBlankURL || |
190 cleaned_url == chrome::kChromeUINewTabURL) | 190 cleaned_url == chrome::kChromeUINewTabURL) |
191 return; | 191 return; |
192 | 192 |
193 int statuses[MAX_STATUS - 1]; | 193 int statuses[MAX_STATUS - 1]; |
194 std::memset(statuses, 0, sizeof(statuses)); | 194 std::memset(statuses, 0, sizeof(statuses)); |
195 | 195 |
196 ActiveScriptController* active_script_controller = | 196 ActiveScriptController* active_script_controller = |
197 ActiveScriptController::GetForWebContents(web_contents); | 197 ActiveScriptController::GetForWebContents(web_contents); |
198 SiteMap::iterator site_lookup = url_status_.find(cleaned_url); | 198 SiteMap::iterator site_lookup = url_status_.find(cleaned_url); |
199 const ExtensionMap& exts = site_lookup->second; | 199 const ExtensionMap& exts = site_lookup->second; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 // Helpers. -------------------------------------------------------------------- | 391 // Helpers. -------------------------------------------------------------------- |
392 | 392 |
393 // We don't want to treat # ref navigations as if they were new pageloads. | 393 // We don't want to treat # ref navigations as if they were new pageloads. |
394 // So we get rid of the ref if it has it. | 394 // So we get rid of the ref if it has it. |
395 // We convert to a string in the hopes that this is faster than Replacements. | 395 // We convert to a string in the hopes that this is faster than Replacements. |
396 std::string UmaPolicy::CleanURL(const GURL& gurl) { | 396 std::string UmaPolicy::CleanURL(const GURL& gurl) { |
397 if (gurl.spec().empty()) | 397 if (gurl.spec().empty()) |
398 return GURL(content::kAboutBlankURL).spec(); | 398 return GURL(url::kAboutBlankURL).spec(); |
399 if (!gurl.is_valid()) | 399 if (!gurl.is_valid()) |
400 return gurl.spec(); | 400 return gurl.spec(); |
401 if (!gurl.has_ref()) | 401 if (!gurl.has_ref()) |
402 return gurl.spec(); | 402 return gurl.spec(); |
403 std::string port = ""; | 403 std::string port = ""; |
404 if (gurl.has_port()) | 404 if (gurl.has_port()) |
405 port = ":" + gurl.port(); | 405 port = ":" + gurl.port(); |
406 std::string query = ""; | 406 std::string query = ""; |
407 if (gurl.has_query()) | 407 if (gurl.has_query()) |
408 query = "?" + gurl.query(); | 408 query = "?" + gurl.query(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return "AdLikelyReplaced"; | 454 return "AdLikelyReplaced"; |
455 case NONE: | 455 case NONE: |
456 case MAX_STATUS: | 456 case MAX_STATUS: |
457 default: | 457 default: |
458 NOTREACHED(); | 458 NOTREACHED(); |
459 return ""; | 459 return ""; |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 } // namespace extensions | 463 } // namespace extensions |
OLD | NEW |