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

Side by Side Diff: chrome/browser/importer/toolbar_importer.cc

Issue 9572001: Do cookie checks in NetworkDelegate instead of the URLRequest::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 8 years, 9 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) 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/importer/toolbar_importer.h" 5 #include "chrome/browser/importer/toolbar_importer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/first_run/first_run.h" 14 #include "chrome/browser/first_run/first_run.h"
15 #include "chrome/browser/importer/importer_bridge.h" 15 #include "chrome/browser/importer/importer_bridge.h"
16 #include "chrome/browser/importer/importer_data_types.h" 16 #include "chrome/browser/importer/importer_data_types.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/libxml_utils.h" 18 #include "chrome/common/libxml_utils.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/common/content_url_request_user_data.h"
20 #include "content/public/common/url_fetcher.h" 21 #include "content/public/common/url_fetcher.h"
21 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
22 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
25 26
26 // Toolbar5Importer 27 // Toolbar5Importer
27 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply"; 28 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply";
28 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks"; 29 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks";
29 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark"; 30 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark";
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Retrieve authorization token from the network. 208 // Retrieve authorization token from the network.
208 std::string url_string(kT5AuthorizationTokenUrl); 209 std::string url_string(kT5AuthorizationTokenUrl);
209 url_string.replace(url_string.find(kRandomNumberToken), 210 url_string.replace(url_string.find(kRandomNumberToken),
210 arraysize(kRandomNumberToken) - 1, 211 arraysize(kRandomNumberToken) - 1,
211 random_string); 212 random_string);
212 GURL url(url_string); 213 GURL url(url_string);
213 214
214 token_fetcher_ = content::URLFetcher::Create( 215 token_fetcher_ = content::URLFetcher::Create(
215 url, content::URLFetcher::GET, this); 216 url, content::URLFetcher::GET, this);
216 token_fetcher_->SetRequestContext(request_context_getter_.get()); 217 token_fetcher_->SetRequestContext(request_context_getter_.get());
218 // TODO(jochen): Do cookie audit.
219 token_fetcher_->SetContentURLRequestUserData(
220 new content::ContentURLRequestUserData());
217 token_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 221 token_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
218 token_fetcher_->Start(); 222 token_fetcher_->Start();
219 } 223 }
220 224
221 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { 225 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) {
222 if (cancelled()) { 226 if (cancelled()) {
223 EndImport(); 227 EndImport();
224 return; 228 return;
225 } 229 }
226 230
(...skipping 15 matching lines...) Expand all
242 arraysize(kRandomNumberToken) - 1, 246 arraysize(kRandomNumberToken) - 1,
243 random_string); 247 random_string);
244 conn_string.replace(conn_string.find(kAuthorizationToken), 248 conn_string.replace(conn_string.find(kAuthorizationToken),
245 arraysize(kAuthorizationToken) - 1, 249 arraysize(kAuthorizationToken) - 1,
246 token); 250 token);
247 GURL url(conn_string); 251 GURL url(conn_string);
248 252
249 data_fetcher_ = content::URLFetcher::Create( 253 data_fetcher_ = content::URLFetcher::Create(
250 url, content::URLFetcher::GET, this); 254 url, content::URLFetcher::GET, this);
251 data_fetcher_->SetRequestContext(request_context_getter_.get()); 255 data_fetcher_->SetRequestContext(request_context_getter_.get());
256 // TODO(jochen): Do cookie audit.
257 data_fetcher_->SetContentURLRequestUserData(
258 new content::ContentURLRequestUserData());
252 data_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 259 data_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
253 data_fetcher_->Start(); 260 data_fetcher_->Start();
254 } 261 }
255 262
256 void Toolbar5Importer::GetBookmarksFromServerDataResponse( 263 void Toolbar5Importer::GetBookmarksFromServerDataResponse(
257 const std::string& response) { 264 const std::string& response) {
258 if (cancelled()) { 265 if (cancelled()) {
259 EndImport(); 266 EndImport();
260 return; 267 return;
261 } 268 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 566 }
560 567
561 void Toolbar5Importer::AddBookmarksToChrome( 568 void Toolbar5Importer::AddBookmarksToChrome(
562 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { 569 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) {
563 if (!bookmarks.empty() && !cancelled()) { 570 if (!bookmarks.empty() && !cancelled()) {
564 const string16& first_folder_name = 571 const string16& first_folder_name =
565 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); 572 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR);
566 bridge_->AddBookmarks(bookmarks, first_folder_name); 573 bridge_->AddBookmarks(bookmarks, first_folder_name);
567 } 574 }
568 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698