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

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

Issue 10268019: Stop including a continue URL for SafeBrowsing reports, to get the default confirmation page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_util.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
11 #include "crypto/sha2.h" 11 #include "crypto/sha2.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "googleurl/src/url_util.h" 13 #include "googleurl/src/url_util.h"
14 #include "net/base/escape.h" 14 #include "net/base/escape.h"
15 #include "unicode/locid.h"
16 15
17 #if defined(OS_WIN) 16 #if defined(OS_WIN)
18 #include "chrome/installer/util/browser_distribution.h" 17 #include "chrome/installer/util/browser_distribution.h"
19 #endif 18 #endif
20 19
21 // Continue to this URL after submitting the phishing report form. 20 static const char kReportParams[] = "?tpl=%s&url=%s";
22 // TODO(paulg): Change to a Chrome specific URL.
23 static const char kContinueUrlFormat[] =
24 "http://www.google.com/tools/firefox/toolbar/FT2/intl/%s/submit_success.html";
25
26 static const char kReportParams[] = "?tpl=%s&continue=%s&url=%s";
27 21
28 // SBChunk --------------------------------------------------------------------- 22 // SBChunk ---------------------------------------------------------------------
29 23
30 SBChunk::SBChunk() 24 SBChunk::SBChunk()
31 : chunk_number(0), 25 : chunk_number(0),
32 list_id(0), 26 list_id(0),
33 is_add(false) { 27 is_add(false) {
34 } 28 }
35 29
36 SBChunk::~SBChunk() {} 30 SBChunk::~SBChunk() {}
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return list_name.compare(kBinUrlList) == 0; 465 return list_name.compare(kBinUrlList) == 0;
472 } 466 }
473 467
474 bool IsBadbinhashList(const std::string& list_name) { 468 bool IsBadbinhashList(const std::string& list_name) {
475 return list_name.compare(kBinHashList) == 0; 469 return list_name.compare(kBinHashList) == 0;
476 } 470 }
477 471
478 GURL GeneratePhishingReportUrl(const std::string& report_page, 472 GURL GeneratePhishingReportUrl(const std::string& report_page,
479 const std::string& url_to_report, 473 const std::string& url_to_report,
480 bool is_client_side_detection) { 474 bool is_client_side_detection) {
481 icu::Locale locale = icu::Locale::getDefault();
482 const char* lang = locale.getLanguage();
483 if (!lang)
484 lang = "en"; // fallback
485 const std::string continue_esc = net::EscapeQueryParamValue(
486 base::StringPrintf(kContinueUrlFormat, lang), true);
487 const std::string current_esc = net::EscapeQueryParamValue(url_to_report, 475 const std::string current_esc = net::EscapeQueryParamValue(url_to_report,
488 true); 476 true);
489 477
490 #if defined(OS_WIN) 478 #if defined(OS_WIN)
491 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 479 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
492 std::string client_name(dist->GetSafeBrowsingName()); 480 std::string client_name(dist->GetSafeBrowsingName());
493 #else 481 #else
494 std::string client_name("googlechrome"); 482 std::string client_name("googlechrome");
495 #endif 483 #endif
496 if (is_client_side_detection) 484 if (is_client_side_detection)
497 client_name.append("_csd"); 485 client_name.append("_csd");
498 486
499 GURL report_url(report_page + base::StringPrintf(kReportParams, 487 GURL report_url(report_page + base::StringPrintf(kReportParams,
500 client_name.c_str(), 488 client_name.c_str(),
501 continue_esc.c_str(),
502 current_esc.c_str())); 489 current_esc.c_str()));
503 return google_util::AppendGoogleLocaleParam(report_url); 490 return google_util::AppendGoogleLocaleParam(report_url);
504 } 491 }
505 492
506 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) { 493 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) {
507 DCHECK_EQ(crypto::kSHA256Length, hash_in.size()); 494 DCHECK_EQ(crypto::kSHA256Length, hash_in.size());
508 memcpy(hash_out->full_hash, hash_in.data(), crypto::kSHA256Length); 495 memcpy(hash_out->full_hash, hash_in.data(), crypto::kSHA256Length);
509 } 496 }
510 497
511 std::string SBFullHashToString(const SBFullHash& hash) { 498 std::string SBFullHashToString(const SBFullHash& hash) {
512 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); 499 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash));
513 return std::string(hash.full_hash, sizeof(hash.full_hash)); 500 return std::string(hash.full_hash, sizeof(hash.full_hash));
514 } 501 }
515 } // namespace safe_browsing_util 502 } // namespace safe_browsing_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698