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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/lazy_instance.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/updater/extension_updater.h" | 18 #include "chrome/browser/extensions/updater/extension_updater.h" |
18 #include "chrome/browser/first_run/first_run_dialog.h" | 19 #include "chrome/browser/first_run/first_run_dialog.h" |
19 #include "chrome/browser/first_run/first_run_import_observer.h" | 20 #include "chrome/browser/first_run/first_run_import_observer.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return importer_observer.import_result(); | 207 return importer_observer.import_result(); |
207 } | 208 } |
208 | 209 |
209 } // namespace | 210 } // namespace |
210 | 211 |
211 namespace first_run { | 212 namespace first_run { |
212 namespace internal { | 213 namespace internal { |
213 | 214 |
214 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; | 215 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; |
215 | 216 |
216 installer::MasterPreferences* LoadMasterPrefs(FilePath* master_prefs_path) | 217 static base::LazyInstance<FilePath> master_prefs_path_for_testing |
217 { | 218 = LAZY_INSTANCE_INITIALIZER; |
218 *master_prefs_path = FilePath(MasterPrefsPath()); | 219 |
| 220 installer::MasterPreferences* LoadMasterPrefs(FilePath* master_prefs_path) { |
| 221 if (!master_prefs_path_for_testing.Get().empty()) |
| 222 *master_prefs_path = master_prefs_path_for_testing.Get(); |
| 223 else |
| 224 *master_prefs_path = FilePath(MasterPrefsPath()); |
219 if (master_prefs_path->empty()) | 225 if (master_prefs_path->empty()) |
220 return NULL; | 226 return NULL; |
221 installer::MasterPreferences* install_prefs = | 227 installer::MasterPreferences* install_prefs = |
222 new installer::MasterPreferences(*master_prefs_path); | 228 new installer::MasterPreferences(*master_prefs_path); |
223 if (!install_prefs->read_from_file()) { | 229 if (!install_prefs->read_from_file()) { |
224 delete install_prefs; | 230 delete install_prefs; |
225 return NULL; | 231 return NULL; |
226 } | 232 } |
227 | 233 |
228 return install_prefs; | 234 return install_prefs; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 546 |
541 // Reset the preference and notifications to avoid showing the bubble again. | 547 // Reset the preference and notifications to avoid showing the bubble again. |
542 prefs->SetInteger(prefs::kShowFirstRunBubbleOption, | 548 prefs->SetInteger(prefs::kShowFirstRunBubbleOption, |
543 FIRST_RUN_BUBBLE_DONT_SHOW); | 549 FIRST_RUN_BUBBLE_DONT_SHOW); |
544 | 550 |
545 // Show the bubble now and destroy this bubble launcher. | 551 // Show the bubble now and destroy this bubble launcher. |
546 browser->ShowFirstRunBubble(); | 552 browser->ShowFirstRunBubble(); |
547 delete this; | 553 delete this; |
548 } | 554 } |
549 | 555 |
| 556 void SetMasterPrefsPathForTesting(const FilePath& master_prefs) { |
| 557 internal::master_prefs_path_for_testing.Get() = master_prefs; |
| 558 } |
| 559 |
550 ProcessMasterPreferencesResult ProcessMasterPreferences( | 560 ProcessMasterPreferencesResult ProcessMasterPreferences( |
551 const FilePath& user_data_dir, | 561 const FilePath& user_data_dir, |
552 MasterPrefs* out_prefs) { | 562 MasterPrefs* out_prefs) { |
553 DCHECK(!user_data_dir.empty()); | 563 DCHECK(!user_data_dir.empty()); |
554 | 564 |
555 #if defined(OS_CHROMEOS) | 565 #if defined(OS_CHROMEOS) |
556 // Chrome OS has its own out-of-box-experience code. Create the sentinel to | 566 // Chrome OS has its own out-of-box-experience code. Create the sentinel to |
557 // mark the fact that we've run once but skip the full first-run flow. | 567 // mark the fact that we've run once but skip the full first-run flow. |
558 CreateSentinel(); | 568 CreateSentinel(); |
559 return SKIP_FIRST_RUN_TASKS; | 569 return SKIP_FIRST_RUN_TASKS; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 if (template_url && template_url->GetDefaultSearchProvider()) | 712 if (template_url && template_url->GetDefaultSearchProvider()) |
703 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 713 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
704 SetShowWelcomePagePref(); | 714 SetShowWelcomePagePref(); |
705 SetPersonalDataManagerFirstRunPref(); | 715 SetPersonalDataManagerFirstRunPref(); |
706 #endif // !defined(USE_AURA) | 716 #endif // !defined(USE_AURA) |
707 | 717 |
708 internal::DoPostImportPlatformSpecificTasks(); | 718 internal::DoPostImportPlatformSpecificTasks(); |
709 } | 719 } |
710 | 720 |
711 } // namespace first_run | 721 } // namespace first_run |
OLD | NEW |