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

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

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 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 | Annotate | Revision Log
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/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/stringprintf.h"
13 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/dom_operation_notification_details.h" 18 #include "chrome/browser/dom_operation_notification_details.h"
18 #include "chrome/browser/google/google_util.h" 19 #include "chrome/browser/google/google_util.h"
19 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/safe_browsing/malware_details.h" 22 #include "chrome/browser/safe_browsing/malware_details.h"
22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 23 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 strings->SetString("continue_button", 280 strings->SetString("continue_button",
280 l10n_util::GetStringUTF16( 281 l10n_util::GetStringUTF16(
281 IDS_SAFE_BROWSING_MULTI_MALWARE_PROCEED_BUTTON)); 282 IDS_SAFE_BROWSING_MULTI_MALWARE_PROCEED_BUTTON));
282 strings->SetString("back_button", 283 strings->SetString("back_button",
283 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); 284 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
284 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); 285 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
285 } 286 }
286 287
287 void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( 288 void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
288 DictionaryValue* strings) { 289 DictionaryValue* strings) {
289 std::string diagnostic_link = StringPrintf(kSbDiagnosticHtml, 290 std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml,
290 l10n_util::GetStringUTF8( 291 l10n_util::GetStringUTF8(
291 IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); 292 IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
292 293
293 strings->SetString("badURL", url().host()); 294 strings->SetString("badURL", url().host());
294 // Check to see if we're blocking the main page, or a sub-resource on the 295 // Check to see if we're blocking the main page, or a sub-resource on the
295 // main page. 296 // main page.
296 string16 description1, description3, description5; 297 string16 description1, description3, description5;
297 if (is_main_frame_) { 298 if (is_main_frame_) {
298 description1 = l10n_util::GetStringFUTF16( 299 description1 = l10n_util::GetStringFUTF16(
299 IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, UTF8ToUTF16(url().host())); 300 IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, UTF8ToUTF16(url().host()));
300 } else { 301 } else {
301 description1 = l10n_util::GetStringFUTF16( 302 description1 = l10n_util::GetStringFUTF16(
302 IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4, 303 IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4,
303 UTF8ToUTF16(tab()->GetURL().host()), 304 UTF8ToUTF16(tab()->GetURL().host()),
304 UTF8ToUTF16(url().host())); 305 UTF8ToUTF16(url().host()));
305 } 306 }
306 307
307 std::string proceed_link = StringPrintf(kPLinkHtml, 308 std::string proceed_link = base::StringPrintf(kPLinkHtml,
308 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str()); 309 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str());
309 description3 = 310 description3 =
310 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3, 311 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3,
311 UTF8ToUTF16(proceed_link)); 312 UTF8ToUTF16(proceed_link));
312 313
313 PopulateStringDictionary( 314 PopulateStringDictionary(
314 strings, 315 strings,
315 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE), 316 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE),
316 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE), 317 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
317 description1, 318 description1,
(...skipping 13 matching lines...) Expand all
331 strings->SetString("proceed_link", 332 strings->SetString("proceed_link",
332 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK)); 333 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK));
333 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); 334 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
334 335
335 if (!CanShowMalwareDetailsOption()) { 336 if (!CanShowMalwareDetailsOption()) {
336 strings->SetBoolean(kDisplayCheckBox, false); 337 strings->SetBoolean(kDisplayCheckBox, false);
337 } else { 338 } else {
338 // Show the checkbox for sending malware details. 339 // Show the checkbox for sending malware details.
339 strings->SetBoolean(kDisplayCheckBox, true); 340 strings->SetBoolean(kDisplayCheckBox, true);
340 341
341 std::string privacy_link = StringPrintf( 342 std::string privacy_link = base::StringPrintf(
342 kPrivacyLinkHtml, 343 kPrivacyLinkHtml,
343 l10n_util::GetStringUTF8( 344 l10n_util::GetStringUTF8(
344 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); 345 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
345 346
346 strings->SetString("confirm_text", 347 strings->SetString("confirm_text",
347 l10n_util::GetStringFUTF16( 348 l10n_util::GetStringFUTF16(
348 IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, 349 IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
349 UTF8ToUTF16(privacy_link))); 350 UTF8ToUTF16(privacy_link)));
350 351
351 const PrefService::Preference* pref = 352 const PrefService::Preference* pref =
352 tab()->profile()->GetPrefs()->FindPreference( 353 tab()->profile()->GetPrefs()->FindPreference(
353 prefs::kSafeBrowsingReportingEnabled); 354 prefs::kSafeBrowsingReportingEnabled);
354 355
355 bool value; 356 bool value;
356 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { 357 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) {
357 strings->SetString(kBoxChecked, "yes"); 358 strings->SetString(kBoxChecked, "yes");
358 } else { 359 } else {
359 strings->SetString(kBoxChecked, ""); 360 strings->SetString(kBoxChecked, "");
360 } 361 }
361 } 362 }
362 } 363 }
363 364
364 void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( 365 void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
365 DictionaryValue* strings) { 366 DictionaryValue* strings) {
366 std::string proceed_link = StringPrintf(kPLinkHtml, l10n_util::GetStringUTF8( 367 std::string proceed_link = base::StringPrintf(
367 IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str()); 368 kPLinkHtml,
369 l10n_util::GetStringUTF8(
370 IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str());
368 string16 description3 = l10n_util::GetStringFUTF16( 371 string16 description3 = l10n_util::GetStringFUTF16(
369 IDS_SAFE_BROWSING_PHISHING_DESCRIPTION3, 372 IDS_SAFE_BROWSING_PHISHING_DESCRIPTION3,
370 UTF8ToUTF16(proceed_link)); 373 UTF8ToUTF16(proceed_link));
371 374
372 PopulateStringDictionary( 375 PopulateStringDictionary(
373 strings, 376 strings,
374 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE), 377 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE),
375 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE), 378 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
376 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1, 379 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1,
377 UTF8ToUTF16(url().host())), 380 UTF8ToUTF16(url().host())),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 GURL report_url = 467 GURL report_url =
465 safe_browsing_util::GeneratePhishingReportUrl(kSbReportPhishingUrl, 468 safe_browsing_util::GeneratePhishingReportUrl(kSbReportPhishingUrl,
466 bad_url_spec); 469 bad_url_spec);
467 tab()->OpenURL(report_url, GURL(), CURRENT_TAB, PageTransition::LINK); 470 tab()->OpenURL(report_url, GURL(), CURRENT_TAB, PageTransition::LINK);
468 return; 471 return;
469 } 472 }
470 473
471 if (command == kShowDiagnosticCommand) { 474 if (command == kShowDiagnosticCommand) {
472 // We're going to take the user to Google's SafeBrowsing diagnostic page. 475 // We're going to take the user to Google's SafeBrowsing diagnostic page.
473 std::string diagnostic = 476 std::string diagnostic =
474 StringPrintf(kSbDiagnosticUrl, 477 base::StringPrintf(kSbDiagnosticUrl,
475 EscapeQueryParamValue(bad_url_spec, true).c_str()); 478 EscapeQueryParamValue(bad_url_spec, true).c_str());
476 GURL diagnostic_url(diagnostic); 479 GURL diagnostic_url(diagnostic);
477 diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url); 480 diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url);
478 DCHECK(unsafe_resources_[element_index].threat_type == 481 DCHECK(unsafe_resources_[element_index].threat_type ==
479 SafeBrowsingService::URL_MALWARE); 482 SafeBrowsingService::URL_MALWARE);
480 tab()->OpenURL(diagnostic_url, GURL(), CURRENT_TAB, PageTransition::LINK); 483 tab()->OpenURL(diagnostic_url, GURL(), CURRENT_TAB, PageTransition::LINK);
481 return; 484 return;
482 } 485 }
483 486
484 NOTREACHED() << "Unexpected command: " << command; 487 NOTREACHED() << "Unexpected command: " << command;
485 } 488 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 671 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
669 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); 672 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource);
670 } 673 }
671 674
672 // static 675 // static
673 bool SafeBrowsingBlockingPage::IsMainPage( 676 bool SafeBrowsingBlockingPage::IsMainPage(
674 const UnsafeResourceList& unsafe_resources) { 677 const UnsafeResourceList& unsafe_resources) {
675 return unsafe_resources.size() == 1 && 678 return unsafe_resources.size() == 1 &&
676 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; 679 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
677 } 680 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_parser_unittest.cc ('k') | chrome/browser/safe_browsing/safe_browsing_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698