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

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

Issue 10554008: Move content::URLFetcher static functions to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win link error Created 8 years, 6 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 "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/common/url_fetcher.h"
20 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
21 #include "net/base/load_flags.h" 20 #include "net/base/load_flags.h"
21 #include "net/url_request/url_fetcher.h"
22 #include "third_party/libxml/chromium/libxml_utils.h" 22 #include "third_party/libxml/chromium/libxml_utils.h"
23 23
24 using content::BrowserThread; 24 using content::BrowserThread;
25 25
26 // Toolbar5Importer 26 // Toolbar5Importer
27 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply"; 27 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply";
28 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks"; 28 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks";
29 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark"; 29 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark";
30 const char Toolbar5Importer::kTitleXmlTag[] = "title"; 30 const char Toolbar5Importer::kTitleXmlTag[] = "title";
31 const char Toolbar5Importer::kUrlXmlTag[] = "url"; 31 const char Toolbar5Importer::kUrlXmlTag[] = "url";
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // Retrieve authorization token from the network. 207 // Retrieve authorization token from the network.
208 std::string url_string(kT5AuthorizationTokenUrl); 208 std::string url_string(kT5AuthorizationTokenUrl);
209 url_string.replace(url_string.find(kRandomNumberToken), 209 url_string.replace(url_string.find(kRandomNumberToken),
210 arraysize(kRandomNumberToken) - 1, 210 arraysize(kRandomNumberToken) - 1,
211 random_string); 211 random_string);
212 GURL url(url_string); 212 GURL url(url_string);
213 213
214 // Because the importer is started as the result of a user action which 214 // Because the importer is started as the result of a user action which
215 // explicitly requires authentication, sending cookies here is reasonable. 215 // explicitly requires authentication, sending cookies here is reasonable.
216 token_fetcher_ = content::URLFetcher::Create( 216 token_fetcher_ = net::URLFetcher::Create(
217 url, net::URLFetcher::GET, this); 217 url, net::URLFetcher::GET, this);
218 token_fetcher_->SetRequestContext(request_context_getter_.get()); 218 token_fetcher_->SetRequestContext(request_context_getter_.get());
219 token_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 219 token_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
220 token_fetcher_->Start(); 220 token_fetcher_->Start();
221 } 221 }
222 222
223 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { 223 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) {
224 if (cancelled()) { 224 if (cancelled()) {
225 EndImport(); 225 EndImport();
226 return; 226 return;
(...skipping 16 matching lines...) Expand all
243 conn_string.replace(conn_string.find(kRandomNumberToken), 243 conn_string.replace(conn_string.find(kRandomNumberToken),
244 arraysize(kRandomNumberToken) - 1, 244 arraysize(kRandomNumberToken) - 1,
245 random_string); 245 random_string);
246 conn_string.replace(conn_string.find(kAuthorizationToken), 246 conn_string.replace(conn_string.find(kAuthorizationToken),
247 arraysize(kAuthorizationToken) - 1, 247 arraysize(kAuthorizationToken) - 1,
248 token); 248 token);
249 GURL url(conn_string); 249 GURL url(conn_string);
250 250
251 // Because the importer is started as the result of a user action which 251 // Because the importer is started as the result of a user action which
252 // explicitly requires authentication, sending cookies here is reasonable. 252 // explicitly requires authentication, sending cookies here is reasonable.
253 data_fetcher_ = content::URLFetcher::Create( 253 data_fetcher_ = net::URLFetcher::Create(
254 url, net::URLFetcher::GET, this); 254 url, net::URLFetcher::GET, this);
255 data_fetcher_->SetRequestContext(request_context_getter_.get()); 255 data_fetcher_->SetRequestContext(request_context_getter_.get());
256 data_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 256 data_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
257 data_fetcher_->Start(); 257 data_fetcher_->Start();
258 } 258 }
259 259
260 void Toolbar5Importer::GetBookmarksFromServerDataResponse( 260 void Toolbar5Importer::GetBookmarksFromServerDataResponse(
261 const std::string& response) { 261 const std::string& response) {
262 if (cancelled()) { 262 if (cancelled()) {
263 EndImport(); 263 EndImport();
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 563 }
564 564
565 void Toolbar5Importer::AddBookmarksToChrome( 565 void Toolbar5Importer::AddBookmarksToChrome(
566 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { 566 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) {
567 if (!bookmarks.empty() && !cancelled()) { 567 if (!bookmarks.empty() && !cancelled()) {
568 const string16& first_folder_name = 568 const string16& first_folder_name =
569 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); 569 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR);
570 bridge_->AddBookmarks(bookmarks, first_folder_name); 570 bridge_->AddBookmarks(bookmarks, first_folder_name);
571 } 571 }
572 } 572 }
OLDNEW
« no previous file with comments | « chrome/browser/google/google_url_tracker_unittest.cc ('k') | chrome/browser/intents/cws_intents_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698