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

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

Issue 2890: Include chrome/browser/SConscript in Linux build.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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 | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/hmac.h" 7 #include "base/hmac.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/sha2.h" 9 #include "base/sha2.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 break; 130 break;
131 case '-': 131 case '-':
132 (*decoded)[i] = '+'; 132 (*decoded)[i] = '+';
133 break; 133 break;
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 bool VerifyMAC(const std::string& key, const std::string& mac, 138 bool VerifyMAC(const std::string& key, const std::string& mac,
139 const char* data, int data_length) { 139 const char* data, int data_length) {
140 #if !defined(OS_WIN)
141 // TODO(port): Remove #defines when linking issue with modp_b64 is resolved.
142 NOTIMPLEMENTED();
143 return false;
144 #endif
140 std::string key_copy = key; 145 std::string key_copy = key;
141 DecodeWebSafe(&key_copy); 146 DecodeWebSafe(&key_copy);
142 std::string decoded_key; 147 std::string decoded_key;
143 net::Base64Decode(key_copy, &decoded_key); 148 net::Base64Decode(key_copy, &decoded_key);
144 149
145 std::string mac_copy = mac; 150 std::string mac_copy = mac;
146 DecodeWebSafe(&mac_copy); 151 DecodeWebSafe(&mac_copy);
147 std::string decoded_mac; 152 std::string decoded_mac;
148 net::Base64Decode(mac_copy, &decoded_mac); 153 net::Base64Decode(mac_copy, &decoded_mac);
149 154
(...skipping 11 matching lines...) Expand all
161 void FreeChunks(std::deque<SBChunk>* chunks) { 166 void FreeChunks(std::deque<SBChunk>* chunks) {
162 while (!chunks->empty()) { 167 while (!chunks->empty()) {
163 while (!chunks->front().hosts.empty()) { 168 while (!chunks->front().hosts.empty()) {
164 chunks->front().hosts.front().entry->Destroy(); 169 chunks->front().hosts.front().entry->Destroy();
165 chunks->front().hosts.pop_front(); 170 chunks->front().hosts.pop_front();
166 } 171 }
167 chunks->pop_front(); 172 chunks->pop_front();
168 } 173 }
169 } 174 }
170 175
176 #if defined(OS_WIN)
177 // TODO(port): remove conditional #ifs when google_util is ported
171 GURL GeneratePhishingReportUrl(const std::string& report_page, 178 GURL GeneratePhishingReportUrl(const std::string& report_page,
172 const std::string& url_to_report) { 179 const std::string& url_to_report) {
173 Locale locale = Locale::getDefault(); 180 Locale locale = Locale::getDefault();
174 const char* lang = locale.getLanguage(); 181 const char* lang = locale.getLanguage();
175 if (!lang) 182 if (!lang)
176 lang = "en"; // fallback 183 lang = "en"; // fallback
177 const std::string continue_esc = 184 const std::string continue_esc =
178 EscapeQueryParamValue(StringPrintf(kContinueUrlFormat, lang)); 185 EscapeQueryParamValue(StringPrintf(kContinueUrlFormat, lang));
179 const std::string current_esc = EscapeQueryParamValue(url_to_report); 186 const std::string current_esc = EscapeQueryParamValue(url_to_report);
180 const std::string format = report_page + kReportParams; 187 const std::string format = report_page + kReportParams;
181 GURL report_url(StringPrintf(format.c_str(), 188 GURL report_url(StringPrintf(format.c_str(),
182 continue_esc.c_str(), 189 continue_esc.c_str(),
183 current_esc.c_str())); 190 current_esc.c_str()));
184 return google_util::AppendGoogleLocaleParam(report_url); 191 return google_util::AppendGoogleLocaleParam(report_url);
185 } 192 }
193 #endif
186 194
187 } // namespace safe_browsing_util 195 } // namespace safe_browsing_util
188 196
189 const int SBEntry::kMinSize = sizeof(SBEntry::Data); 197 const int SBEntry::kMinSize = sizeof(SBEntry::Data);
190 198
191 SBEntry* SBEntry::Create(Type type, int prefix_count) { 199 SBEntry* SBEntry::Create(Type type, int prefix_count) {
192 int size = Size(type, prefix_count); 200 int size = Size(type, prefix_count);
193 SBEntry *rv = static_cast<SBEntry*>(malloc(size)); 201 SBEntry *rv = static_cast<SBEntry*>(malloc(size));
194 memset(rv, 0, size); 202 memset(rv, 0, size);
195 rv->set_type(type); 203 rv->set_type(type);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 continue; 477 continue;
470 } 478 }
471 479
472 SBEntry* new_sub_entry = const_cast<SBEntry*>(entry); 480 SBEntry* new_sub_entry = const_cast<SBEntry*>(entry);
473 scoped_array<char> data; 481 scoped_array<char> data;
474 if (entry->IsSub() && entry->list_id() == list_id && entry->prefix_count()) { 482 if (entry->IsSub() && entry->list_id() == list_id && entry->prefix_count()) {
475 // Make a copy of the entry so that we can modify it. 483 // Make a copy of the entry so that we can modify it.
476 data.reset(new char[entry->Size()]); 484 data.reset(new char[entry->Size()]);
477 new_sub_entry = reinterpret_cast<SBEntry*>(data.get()); 485 new_sub_entry = reinterpret_cast<SBEntry*>(data.get());
478 memcpy(new_sub_entry, entry, entry->Size()); 486 memcpy(new_sub_entry, entry, entry->Size());
479 int new_prefix_count = 0;
480 // Remove any matching prefixes. 487 // Remove any matching prefixes.
481 for (int i = 0; i < new_sub_entry->prefix_count(); ++i) { 488 for (int i = 0; i < new_sub_entry->prefix_count(); ++i) {
482 if (new_sub_entry->ChunkIdAtPrefix(i) == chunk_id) 489 if (new_sub_entry->ChunkIdAtPrefix(i) == chunk_id)
483 new_sub_entry->RemovePrefix(i--); 490 new_sub_entry->RemovePrefix(i--);
484 } 491 }
485 492
486 if (new_sub_entry->prefix_count() == 0) 493 if (new_sub_entry->prefix_count() == 0)
487 continue; // We removed the last prefix in the entry, so remove it. 494 continue; // We removed the last prefix in the entry, so remove it.
488 } 495 }
489 496
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // Validate that the next entry is wholly contained inside of |data_|. 614 // Validate that the next entry is wholly contained inside of |data_|.
608 const char* end = data_.get() + size_; 615 const char* end = data_.get() + size_;
609 if (next + SBEntry::kMinSize <= end && next + next_entry->Size() <= end) { 616 if (next + SBEntry::kMinSize <= end && next + next_entry->Size() <= end) {
610 *entry = next_entry; 617 *entry = next_entry;
611 return true; 618 return true;
612 } 619 }
613 620
614 return false; 621 return false;
615 } 622 }
616 623
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698