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

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

Issue 8921006: Standardize StringToInt{,64} interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix namespace issues. Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_piece.h"
15 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/dom_operation_notification_details.h" 20 #include "chrome/browser/dom_operation_notification_details.h"
20 #include "chrome/browser/google/google_util.h" 21 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/safe_browsing/malware_details.h" 24 #include "chrome/browser/safe_browsing/malware_details.h"
24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
25 #include "chrome/browser/tab_contents/tab_util.h" 26 #include "chrome/browser/tab_contents/tab_util.h"
26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 27 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
27 #include "chrome/common/jstemplate_builder.h" 28 #include "chrome/common/jstemplate_builder.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "content/browser/tab_contents/navigation_controller.h" 31 #include "content/browser/tab_contents/navigation_controller.h"
31 #include "content/browser/tab_contents/navigation_entry.h" 32 #include "content/browser/tab_contents/navigation_entry.h"
32 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
33 #include "content/browser/user_metrics.h" 34 #include "content/browser/user_metrics.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
35 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
36 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
37 #include "grit/locale_settings.h" 38 #include "grit/locale_settings.h"
38 #include "net/base/escape.h" 39 #include "net/base/escape.h"
39 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
41 42
43 using base::StringPiece;
erikwright (departed) 2011/12/14 19:09:58 Remove 'using' for consistency with cbentzel's com
42 using content::BrowserThread; 44 using content::BrowserThread;
43 45
44 // For malware interstitial pages, we link the problematic URL to Google's 46 // For malware interstitial pages, we link the problematic URL to Google's
45 // diagnostic page. 47 // diagnostic page.
46 #if defined(GOOGLE_CHROME_BUILD) 48 #if defined(GOOGLE_CHROME_BUILD)
47 static const char* const kSbDiagnosticUrl = 49 static const char* const kSbDiagnosticUrl =
48 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=googlechrome"; 50 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=googlechrome";
49 #else 51 #else
50 static const char* const kSbDiagnosticUrl = 52 static const char* const kSbDiagnosticUrl =
51 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=chromium"; 53 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie nt=chromium";
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // We are deleted after this. 461 // We are deleted after this.
460 return; 462 return;
461 } 463 }
462 464
463 // The "report error" and "show diagnostic" commands can have a number 465 // The "report error" and "show diagnostic" commands can have a number
464 // appended to them, which is the index of the element they apply to. 466 // appended to them, which is the index of the element they apply to.
465 int element_index = 0; 467 int element_index = 0;
466 size_t colon_index = command.find(':'); 468 size_t colon_index = command.find(':');
467 if (colon_index != std::string::npos) { 469 if (colon_index != std::string::npos) {
468 DCHECK(colon_index < command.size() - 1); 470 DCHECK(colon_index < command.size() - 1);
469 bool result = base::StringToInt(command.begin() + colon_index + 1, 471 bool result = base::StringToInt(StringPiece(command.begin() +
470 command.end(), 472 colon_index + 1,
473 command.end()),
471 &element_index); 474 &element_index);
472 command = command.substr(0, colon_index); 475 command = command.substr(0, colon_index);
473 DCHECK(result); 476 DCHECK(result);
474 } 477 }
475 478
476 if (element_index >= static_cast<int>(unsafe_resources_.size())) { 479 if (element_index >= static_cast<int>(unsafe_resources_.size())) {
477 NOTREACHED(); 480 NOTREACHED();
478 return; 481 return;
479 } 482 }
480 483
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // Client-side phishing detection interstitials never block the main frame 710 // Client-side phishing detection interstitials never block the main frame
708 // load, since they happen after the page is finished loading. 711 // load, since they happen after the page is finished loading.
709 if (unsafe_resources[0].threat_type == 712 if (unsafe_resources[0].threat_type ==
710 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { 713 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) {
711 return false; 714 return false;
712 } 715 }
713 716
714 // Otherwise, check the threat type. 717 // Otherwise, check the threat type.
715 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; 718 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource;
716 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698