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/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "ui/base/l10n/l10n_util.h" | 69 #include "ui/base/l10n/l10n_util.h" |
69 #include "url/gurl.h" | 70 #include "url/gurl.h" |
70 | 71 |
71 using base::UserMetricsAction; | 72 using base::UserMetricsAction; |
72 | 73 |
73 namespace { | 74 namespace { |
74 | 75 |
75 // A bitfield formed from values in AutoImportState to record the state of | 76 // A bitfield formed from values in AutoImportState to record the state of |
76 // AutoImport. This is used in testing to verify import startup actions that | 77 // AutoImport. This is used in testing to verify import startup actions that |
77 // occur before an observer can be registered in the test. | 78 // occur before an observer can be registered in the test. |
78 uint16 g_auto_import_state = first_run::AUTO_IMPORT_NONE; | 79 uint16_t g_auto_import_state = first_run::AUTO_IMPORT_NONE; |
79 | 80 |
80 // Flags for functions of similar name. | 81 // Flags for functions of similar name. |
81 bool g_should_show_welcome_page = false; | 82 bool g_should_show_welcome_page = false; |
82 bool g_should_do_autofill_personal_data_manager_first_run = false; | 83 bool g_should_do_autofill_personal_data_manager_first_run = false; |
83 | 84 |
84 // This class acts as an observer for the ImporterProgressObserver::ImportEnded | 85 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
85 // callback. When the import process is started, certain errors may cause | 86 // callback. When the import process is started, certain errors may cause |
86 // ImportEnded() to be called synchronously, but the typical case is that | 87 // ImportEnded() to be called synchronously, but the typical case is that |
87 // ImportEnded() is called asynchronously. Thus we have to handle both cases. | 88 // ImportEnded() is called asynchronously. Thus we have to handle both cases. |
88 class ImportEndedObserver : public importer::ImporterProgressObserver { | 89 class ImportEndedObserver : public importer::ImporterProgressObserver { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 user_prefs->ClearPref(pref_path); | 230 user_prefs->ClearPref(pref_path); |
230 } | 231 } |
231 | 232 |
232 // Launches the import, via |importer_host|, from |source_profile| into | 233 // Launches the import, via |importer_host|, from |source_profile| into |
233 // |target_profile| for the items specified in the |items_to_import| bitfield. | 234 // |target_profile| for the items specified in the |items_to_import| bitfield. |
234 // This may be done in a separate process depending on the platform, but it will | 235 // This may be done in a separate process depending on the platform, but it will |
235 // always block until done. | 236 // always block until done. |
236 void ImportFromSourceProfile(ExternalProcessImporterHost* importer_host, | 237 void ImportFromSourceProfile(ExternalProcessImporterHost* importer_host, |
237 const importer::SourceProfile& source_profile, | 238 const importer::SourceProfile& source_profile, |
238 Profile* target_profile, | 239 Profile* target_profile, |
239 uint16 items_to_import) { | 240 uint16_t items_to_import) { |
240 ImportEndedObserver observer; | 241 ImportEndedObserver observer; |
241 importer_host->set_observer(&observer); | 242 importer_host->set_observer(&observer); |
242 importer_host->StartImportSettings(source_profile, | 243 importer_host->StartImportSettings(source_profile, |
243 target_profile, | 244 target_profile, |
244 items_to_import, | 245 items_to_import, |
245 new ProfileWriter(target_profile)); | 246 new ProfileWriter(target_profile)); |
246 // If the import process has not errored out, block on it. | 247 // If the import process has not errored out, block on it. |
247 if (!observer.ended()) { | 248 if (!observer.ended()) { |
248 base::RunLoop loop; | 249 base::RunLoop loop; |
249 observer.set_callback_for_import_end(loop.QuitClosure()); | 250 observer.set_callback_for_import_end(loop.QuitClosure()); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 TemplateURLService* template_url = | 823 TemplateURLService* template_url = |
823 TemplateURLServiceFactory::GetForProfile(profile); | 824 TemplateURLServiceFactory::GetForProfile(profile); |
824 if (template_url && template_url->GetDefaultSearchProvider()) | 825 if (template_url && template_url->GetDefaultSearchProvider()) |
825 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 826 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
826 SetShouldShowWelcomePage(); | 827 SetShouldShowWelcomePage(); |
827 SetShouldDoPersonalDataManagerFirstRun(); | 828 SetShouldDoPersonalDataManagerFirstRun(); |
828 | 829 |
829 internal::DoPostImportPlatformSpecificTasks(profile); | 830 internal::DoPostImportPlatformSpecificTasks(profile); |
830 } | 831 } |
831 | 832 |
832 uint16 auto_import_state() { | 833 uint16_t auto_import_state() { |
833 return g_auto_import_state; | 834 return g_auto_import_state; |
834 } | 835 } |
835 | 836 |
836 } // namespace first_run | 837 } // namespace first_run |
OLD | NEW |