OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/url_fetcher.h" | 20 #include "content/public/common/url_fetcher.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "net/base/load_flags.h" |
22 | 23 |
23 using content::BrowserThread; | 24 using content::BrowserThread; |
24 | 25 |
25 // Toolbar5Importer | 26 // Toolbar5Importer |
26 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply"; | 27 const char Toolbar5Importer::kXmlApiReplyXmlTag[] = "xml_api_reply"; |
27 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks"; | 28 const char Toolbar5Importer::kBookmarksXmlTag[] = "bookmarks"; |
28 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark"; | 29 const char Toolbar5Importer::kBookmarkXmlTag[] = "bookmark"; |
29 const char Toolbar5Importer::kTitleXmlTag[] = "title"; | 30 const char Toolbar5Importer::kTitleXmlTag[] = "title"; |
30 const char Toolbar5Importer::kUrlXmlTag[] = "url"; | 31 const char Toolbar5Importer::kUrlXmlTag[] = "url"; |
31 const char Toolbar5Importer::kTimestampXmlTag[] = "timestamp"; | 32 const char Toolbar5Importer::kTimestampXmlTag[] = "timestamp"; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // Retrieve authorization token from the network. | 207 // Retrieve authorization token from the network. |
207 std::string url_string(kT5AuthorizationTokenUrl); | 208 std::string url_string(kT5AuthorizationTokenUrl); |
208 url_string.replace(url_string.find(kRandomNumberToken), | 209 url_string.replace(url_string.find(kRandomNumberToken), |
209 arraysize(kRandomNumberToken) - 1, | 210 arraysize(kRandomNumberToken) - 1, |
210 random_string); | 211 random_string); |
211 GURL url(url_string); | 212 GURL url(url_string); |
212 | 213 |
213 token_fetcher_ = content::URLFetcher::Create( | 214 token_fetcher_ = content::URLFetcher::Create( |
214 url, content::URLFetcher::GET, this); | 215 url, content::URLFetcher::GET, this); |
215 token_fetcher_->SetRequestContext(request_context_getter_.get()); | 216 token_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 217 token_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
216 token_fetcher_->Start(); | 218 token_fetcher_->Start(); |
217 } | 219 } |
218 | 220 |
219 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { | 221 void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { |
220 if (cancelled()) { | 222 if (cancelled()) { |
221 EndImport(); | 223 EndImport(); |
222 return; | 224 return; |
223 } | 225 } |
224 | 226 |
225 state_ = GET_BOOKMARKS; | 227 state_ = GET_BOOKMARKS; |
(...skipping 14 matching lines...) Expand all Loading... |
240 arraysize(kRandomNumberToken) - 1, | 242 arraysize(kRandomNumberToken) - 1, |
241 random_string); | 243 random_string); |
242 conn_string.replace(conn_string.find(kAuthorizationToken), | 244 conn_string.replace(conn_string.find(kAuthorizationToken), |
243 arraysize(kAuthorizationToken) - 1, | 245 arraysize(kAuthorizationToken) - 1, |
244 token); | 246 token); |
245 GURL url(conn_string); | 247 GURL url(conn_string); |
246 | 248 |
247 data_fetcher_ = content::URLFetcher::Create( | 249 data_fetcher_ = content::URLFetcher::Create( |
248 url, content::URLFetcher::GET, this); | 250 url, content::URLFetcher::GET, this); |
249 data_fetcher_->SetRequestContext(request_context_getter_.get()); | 251 data_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 252 data_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
250 data_fetcher_->Start(); | 253 data_fetcher_->Start(); |
251 } | 254 } |
252 | 255 |
253 void Toolbar5Importer::GetBookmarksFromServerDataResponse( | 256 void Toolbar5Importer::GetBookmarksFromServerDataResponse( |
254 const std::string& response) { | 257 const std::string& response) { |
255 if (cancelled()) { | 258 if (cancelled()) { |
256 EndImport(); | 259 EndImport(); |
257 return; | 260 return; |
258 } | 261 } |
259 | 262 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 559 } |
557 | 560 |
558 void Toolbar5Importer::AddBookmarksToChrome( | 561 void Toolbar5Importer::AddBookmarksToChrome( |
559 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { | 562 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { |
560 if (!bookmarks.empty() && !cancelled()) { | 563 if (!bookmarks.empty() && !cancelled()) { |
561 const string16& first_folder_name = | 564 const string16& first_folder_name = |
562 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); | 565 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); |
563 bridge_->AddBookmarks(bookmarks, first_folder_name); | 566 bridge_->AddBookmarks(bookmarks, first_folder_name); |
564 } | 567 } |
565 } | 568 } |
OLD | NEW |