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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
| 13 #include "base/metrics/histogram_macros.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/favicon/favicon_service_factory.h" | 21 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 22 #include "chrome/browser/first_run/first_run.h" |
21 #include "chrome/browser/history/history_service_factory.h" | 23 #include "chrome/browser/history/history_service_factory.h" |
22 #include "chrome/browser/password_manager/password_store_factory.h" | 24 #include "chrome/browser/password_manager/password_store_factory.h" |
23 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/search_engines/template_url_service_factory.h" | 26 #include "chrome/browser/search_engines/template_url_service_factory.h" |
25 #include "chrome/browser/web_data_service_factory.h" | 27 #include "chrome/browser/web_data_service_factory.h" |
26 #include "chrome/common/importer/imported_bookmark_entry.h" | 28 #include "chrome/common/importer/imported_bookmark_entry.h" |
27 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
28 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 30 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
29 #include "components/bookmarks/browser/bookmark_model.h" | 31 #include "components/bookmarks/browser/bookmark_model.h" |
30 #include "components/bookmarks/common/bookmark_pref_names.h" | 32 #include "components/bookmarks/common/bookmark_pref_names.h" |
31 #include "components/favicon/core/favicon_service.h" | 33 #include "components/favicon/core/favicon_service.h" |
32 #include "components/history/core/browser/history_service.h" | 34 #include "components/history/core/browser/history_service.h" |
33 #include "components/password_manager/core/browser/password_store.h" | 35 #include "components/password_manager/core/browser/password_store.h" |
34 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
35 #include "components/search_engines/template_url.h" | 37 #include "components/search_engines/template_url.h" |
36 #include "components/search_engines/template_url_service.h" | 38 #include "components/search_engines/template_url_service.h" |
37 | 39 |
38 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
39 #include "chrome/browser/web_data_service_factory.h" | |
40 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" | 41 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" |
41 #endif | 42 #endif |
42 | 43 |
43 using bookmarks::BookmarkModel; | 44 using bookmarks::BookmarkModel; |
44 using bookmarks::BookmarkNode; | 45 using bookmarks::BookmarkNode; |
45 | 46 |
46 namespace { | 47 namespace { |
47 | 48 |
48 // Generates a unique folder name. If |folder_name| is not unique, then this | 49 // Generates a unique folder name. If |folder_name| is not unique, then this |
49 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. | 50 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 WebDataServiceFactory::GetPasswordWebDataForProfile( | 102 WebDataServiceFactory::GetPasswordWebDataForProfile( |
102 profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddIE7Login(info); | 103 profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddIE7Login(info); |
103 } | 104 } |
104 #endif | 105 #endif |
105 | 106 |
106 void ProfileWriter::AddHistoryPage(const history::URLRows& page, | 107 void ProfileWriter::AddHistoryPage(const history::URLRows& page, |
107 history::VisitSource visit_source) { | 108 history::VisitSource visit_source) { |
108 HistoryServiceFactory::GetForProfile(profile_, | 109 HistoryServiceFactory::GetForProfile(profile_, |
109 ServiceAccessType::EXPLICIT_ACCESS) | 110 ServiceAccessType::EXPLICIT_ACCESS) |
110 ->AddPagesWithDetails(page, visit_source); | 111 ->AddPagesWithDetails(page, visit_source); |
| 112 // Measure the size of the history page after AutoImport from IE |
| 113 // on first run. |
| 114 if (first_run::IsChromeFirstRun()) { |
| 115 UMA_HISTOGRAM_COUNTS("Import.ImportedHistorySize.AutoImport", page.size()); |
| 116 } |
111 } | 117 } |
112 | 118 |
113 void ProfileWriter::AddHomepage(const GURL& home_page) { | 119 void ProfileWriter::AddHomepage(const GURL& home_page) { |
114 DCHECK(profile_); | 120 DCHECK(profile_); |
115 | 121 |
116 PrefService* prefs = profile_->GetPrefs(); | 122 PrefService* prefs = profile_->GetPrefs(); |
117 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. | 123 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. |
118 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); | 124 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); |
119 if (pref && !pref->IsManaged()) { | 125 if (pref && !pref->IsManaged()) { |
120 prefs->SetString(prefs::kHomePage, home_page.spec()); | 126 prefs->SetString(prefs::kHomePage, home_page.spec()); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 void ProfileWriter::AddAutofillFormDataEntries( | 348 void ProfileWriter::AddAutofillFormDataEntries( |
343 const std::vector<autofill::AutofillEntry>& autofill_entries) { | 349 const std::vector<autofill::AutofillEntry>& autofill_entries) { |
344 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 350 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
345 WebDataServiceFactory::GetAutofillWebDataForProfile( | 351 WebDataServiceFactory::GetAutofillWebDataForProfile( |
346 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 352 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
347 if (web_data_service.get()) | 353 if (web_data_service.get()) |
348 web_data_service->UpdateAutofillEntries(autofill_entries); | 354 web_data_service->UpdateAutofillEntries(autofill_entries); |
349 } | 355 } |
350 | 356 |
351 ProfileWriter::~ProfileWriter() {} | 357 ProfileWriter::~ProfileWriter() {} |
OLD | NEW |