| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 static const char* kGoogleDomainSecureCookieId = "SID="; | 36 static const char* kGoogleDomainSecureCookieId = "SID="; |
| 37 | 37 |
| 38 bool toolbar_importer_utils::IsGoogleGAIACookieInstalled() { | 38 bool toolbar_importer_utils::IsGoogleGAIACookieInstalled() { |
| 39 net::CookieStore* store = | 39 net::CookieStore* store = |
| 40 Profile::GetDefaultRequestContext()->GetCookieStore(); | 40 Profile::GetDefaultRequestContext()->GetCookieStore(); |
| 41 GURL url(kGoogleDomainUrl); | 41 GURL url(kGoogleDomainUrl); |
| 42 net::CookieOptions options; | 42 net::CookieOptions options; |
| 43 options.set_include_httponly(); // The SID cookie might be httponly. | 43 options.set_include_httponly(); // The SID cookie might be httponly. |
| 44 std::string cookies = store->GetCookiesWithOptions(url, options); | 44 std::string cookies = store->GetCookiesWithOptions(url, options); |
| 45 std::vector<std::string> cookie_list; | 45 std::vector<std::string> cookie_list; |
| 46 SplitString(cookies, kSplitStringToken, &cookie_list); | 46 base::SplitString(cookies, kSplitStringToken, &cookie_list); |
| 47 for (std::vector<std::string>::iterator current = cookie_list.begin(); | 47 for (std::vector<std::string>::iterator current = cookie_list.begin(); |
| 48 current != cookie_list.end(); | 48 current != cookie_list.end(); |
| 49 ++current) { | 49 ++current) { |
| 50 size_t position = (*current).find(kGoogleDomainSecureCookieId); | 50 size_t position = (*current).find(kGoogleDomainSecureCookieId); |
| 51 if (0 == position) | 51 if (0 == position) |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 // If this is the first run then we place favorites with no labels | 574 // If this is the first run then we place favorites with no labels |
| 575 // in the title bar. Else they are placed in the "Google Toolbar" folder. | 575 // in the title bar. Else they are placed in the "Google Toolbar" folder. |
| 576 if (!FirstRun::IsChromeFirstRun() || !label_vector[index].empty()) { | 576 if (!FirstRun::IsChromeFirstRun() || !label_vector[index].empty()) { |
| 577 (*bookmark_folders)[index].push_back(UTF16ToWide(bookmark_group_string)); | 577 (*bookmark_folders)[index].push_back(UTF16ToWide(bookmark_group_string)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 // If the label and is in the form "xxx:yyy:zzz" this was created from an | 580 // If the label and is in the form "xxx:yyy:zzz" this was created from an |
| 581 // IE or Firefox folder. We undo the label creation and recreate the | 581 // IE or Firefox folder. We undo the label creation and recreate the |
| 582 // correct folder. | 582 // correct folder. |
| 583 std::vector<std::wstring> folder_names; | 583 std::vector<std::wstring> folder_names; |
| 584 SplitString(label_vector[index], L':', &folder_names); | 584 base::SplitString(label_vector[index], L':', &folder_names); |
| 585 (*bookmark_folders)[index].insert((*bookmark_folders)[index].end(), | 585 (*bookmark_folders)[index].insert((*bookmark_folders)[index].end(), |
| 586 folder_names.begin(), folder_names.end()); | 586 folder_names.begin(), folder_names.end()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| 591 | 591 |
| 592 // Bookmark creation | 592 // Bookmark creation |
| 593 void Toolbar5Importer::AddBookmarksToChrome( | 593 void Toolbar5Importer::AddBookmarksToChrome( |
| 594 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { | 594 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { |
| 595 if (!bookmarks.empty() && !cancelled()) { | 595 if (!bookmarks.empty() && !cancelled()) { |
| 596 const std::wstring& first_folder_name = | 596 const std::wstring& first_folder_name = |
| 597 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); | 597 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); |
| 598 int options = ProfileWriter::ADD_IF_UNIQUE | | 598 int options = ProfileWriter::ADD_IF_UNIQUE | |
| 599 (import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0); | 599 (import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0); |
| 600 bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options); | 600 bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options); |
| 601 } | 601 } |
| 602 } | 602 } |
| OLD | NEW |