OLD | NEW |
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" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ = content::URLFetcher::Create( |
217 url, content::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; |
227 } | 227 } |
(...skipping 16 matching lines...) Expand all Loading... |
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_ = content::URLFetcher::Create( |
254 url, content::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(); |
264 return; | 264 return; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |