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/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/favicon/favicon_service.h" | 18 #include "chrome/browser/favicon/favicon_service.h" |
19 #include "chrome/browser/favicon/favicon_service_factory.h" | 19 #include "chrome/browser/favicon/favicon_service_factory.h" |
20 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
21 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
22 #include "chrome/browser/password_manager/password_store_factory.h" | 22 #include "chrome/browser/password_manager/password_store_factory.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/search_engines/template_url_service_factory.h" | 24 #include "chrome/browser/search_engines/template_url_service_factory.h" |
25 #include "chrome/browser/webdata/web_data_service.h" | |
26 #include "chrome/common/importer/imported_bookmark_entry.h" | 25 #include "chrome/common/importer/imported_bookmark_entry.h" |
27 #include "chrome/common/importer/imported_favicon_usage.h" | 26 #include "chrome/common/importer/imported_favicon_usage.h" |
28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
29 #include "components/bookmarks/browser/bookmark_model.h" | 28 #include "components/bookmarks/browser/bookmark_model.h" |
30 #include "components/password_manager/core/browser/password_store.h" | 29 #include "components/password_manager/core/browser/password_store.h" |
31 #include "components/search_engines/template_url.h" | 30 #include "components/search_engines/template_url.h" |
32 #include "components/search_engines/template_url_service.h" | 31 #include "components/search_engines/template_url_service.h" |
33 | 32 |
| 33 #if defined(OS_WIN) |
| 34 #include "chrome/browser/webdata/password_web_data_service_win.h" |
| 35 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 36 #endif |
| 37 |
34 namespace { | 38 namespace { |
35 | 39 |
36 // Generates a unique folder name. If |folder_name| is not unique, then this | 40 // Generates a unique folder name. If |folder_name| is not unique, then this |
37 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. | 41 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. |
38 base::string16 GenerateUniqueFolderName(BookmarkModel* model, | 42 base::string16 GenerateUniqueFolderName(BookmarkModel* model, |
39 const base::string16& folder_name) { | 43 const base::string16& folder_name) { |
40 // Build a set containing the bookmark bar folder names. | 44 // Build a set containing the bookmark bar folder names. |
41 std::set<base::string16> existing_folder_names; | 45 std::set<base::string16> existing_folder_names; |
42 const BookmarkNode* bookmark_bar = model->bookmark_bar_node(); | 46 const BookmarkNode* bookmark_bar = model->bookmark_bar_node(); |
43 for (int i = 0; i < bookmark_bar->child_count(); ++i) { | 47 for (int i = 0; i < bookmark_bar->child_count(); ++i) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return TemplateURLServiceFactory::GetForProfile(profile_)->loaded(); | 83 return TemplateURLServiceFactory::GetForProfile(profile_)->loaded(); |
80 } | 84 } |
81 | 85 |
82 void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) { | 86 void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) { |
83 PasswordStoreFactory::GetForProfile( | 87 PasswordStoreFactory::GetForProfile( |
84 profile_, Profile::EXPLICIT_ACCESS)->AddLogin(form); | 88 profile_, Profile::EXPLICIT_ACCESS)->AddLogin(form); |
85 } | 89 } |
86 | 90 |
87 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
88 void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) { | 92 void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) { |
89 WebDataService::FromBrowserContext(profile_)->AddIE7Login(info); | 93 WebDataServiceFactory::GetPasswordWebDataForProfile( |
| 94 profile_, Profile::EXPLICIT_ACCESS)->AddIE7Login(info); |
90 } | 95 } |
91 #endif | 96 #endif |
92 | 97 |
93 void ProfileWriter::AddHistoryPage(const history::URLRows& page, | 98 void ProfileWriter::AddHistoryPage(const history::URLRows& page, |
94 history::VisitSource visit_source) { | 99 history::VisitSource visit_source) { |
95 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)-> | 100 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)-> |
96 AddPagesWithDetails(page, visit_source); | 101 AddPagesWithDetails(page, visit_source); |
97 } | 102 } |
98 | 103 |
99 void ProfileWriter::AddHomepage(const GURL& home_page) { | 104 void ProfileWriter::AddHomepage(const GURL& home_page) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 323 |
319 // Only add valid TemplateURLs to the model. | 324 // Only add valid TemplateURLs to the model. |
320 if ((*i)->url_ref().IsValid(model->search_terms_data())) { | 325 if ((*i)->url_ref().IsValid(model->search_terms_data())) { |
321 model->Add(*i); // Takes ownership. | 326 model->Add(*i); // Takes ownership. |
322 *i = NULL; // Prevent the vector from deleting *i later. | 327 *i = NULL; // Prevent the vector from deleting *i later. |
323 } | 328 } |
324 } | 329 } |
325 } | 330 } |
326 | 331 |
327 ProfileWriter::~ProfileWriter() {} | 332 ProfileWriter::~ProfileWriter() {} |
OLD | NEW |