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/bind_helpers.h" | |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/message_loop.h" | |
13 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
14 #include "base/path_service.h" | 16 #include "base/path_service.h" |
15 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
16 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/time.h" | |
17 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
18 #include "build/build_config.h" | 21 #include "build/build_config.h" |
19 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/updater/extension_updater.h" | 24 #include "chrome/browser/extensions/updater/extension_updater.h" |
22 #include "chrome/browser/first_run/first_run_dialog.h" | 25 #include "chrome/browser/first_run/first_run_dialog.h" |
23 #include "chrome/browser/first_run/first_run_import_observer.h" | 26 #include "chrome/browser/first_run/first_run_import_observer.h" |
24 #include "chrome/browser/first_run/first_run_internal.h" | 27 #include "chrome/browser/first_run/first_run_internal.h" |
25 #include "chrome/browser/google/google_util.h" | 28 #include "chrome/browser/google/google_util.h" |
26 #include "chrome/browser/importer/external_process_importer_host.h" | 29 #include "chrome/browser/importer/external_process_importer_host.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
54 #include "content/public/browser/notification_types.h" | 57 #include "content/public/browser/notification_types.h" |
55 #include "content/public/browser/user_metrics.h" | 58 #include "content/public/browser/user_metrics.h" |
56 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
57 #include "google_apis/gaia/gaia_auth_util.h" | 60 #include "google_apis/gaia/gaia_auth_util.h" |
58 #include "googleurl/src/gurl.h" | 61 #include "googleurl/src/gurl.h" |
59 | 62 |
60 using content::UserMetricsAction; | 63 using content::UserMetricsAction; |
61 | 64 |
62 namespace { | 65 namespace { |
63 | 66 |
67 // How long to delay showing the first run bubble (in milliseconds). | |
68 const int kFirstRunBubbleDelayMs = 200; | |
69 | |
64 // Flags for functions of similar name. | 70 // Flags for functions of similar name. |
65 bool should_show_welcome_page_ = false; | 71 bool should_show_welcome_page_ = false; |
66 bool should_do_autofill_personal_data_manager_first_run_ = false; | 72 bool should_do_autofill_personal_data_manager_first_run_ = false; |
67 | 73 |
68 // Flags indicating whether a first-run profile auto import was performed, and | 74 // Flags indicating whether a first-run profile auto import was performed, and |
69 // whether the importer process exited successfully. | 75 // whether the importer process exited successfully. |
70 bool did_perform_profile_import = false; | 76 bool did_perform_profile_import = false; |
71 bool profile_import_exited_successfully = false; | 77 bool profile_import_exited_successfully = false; |
72 | 78 |
73 // Helper class that performs delayed first-run tasks that need more of the | 79 // Helper class that performs delayed first-run tasks that need more of the |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 // Suppress the first run bubble if a global error bubble is pending. | 573 // Suppress the first run bubble if a global error bubble is pending. |
568 GlobalErrorService* global_error_service = | 574 GlobalErrorService* global_error_service = |
569 GlobalErrorServiceFactory::GetForProfile(browser->profile()); | 575 GlobalErrorServiceFactory::GetForProfile(browser->profile()); |
570 if (global_error_service->GetFirstGlobalErrorWithBubbleView() != NULL) | 576 if (global_error_service->GetFirstGlobalErrorWithBubbleView() != NULL) |
571 return; | 577 return; |
572 | 578 |
573 // Reset the preference and notifications to avoid showing the bubble again. | 579 // Reset the preference and notifications to avoid showing the bubble again. |
574 prefs->SetInteger(prefs::kShowFirstRunBubbleOption, | 580 prefs->SetInteger(prefs::kShowFirstRunBubbleOption, |
575 FIRST_RUN_BUBBLE_DONT_SHOW); | 581 FIRST_RUN_BUBBLE_DONT_SHOW); |
576 | 582 |
577 // Show the bubble now and destroy this bubble launcher. | 583 // Show the bubble soon. |
578 browser->ShowFirstRunBubble(); | 584 base::MessageLoop::current()->PostDelayedTask( |
585 FROM_HERE, | |
586 base::Bind( | |
587 &Browser::ShowFirstRunBubble, | |
588 base::Unretained(browser)), | |
grt (UTC plus 2)
2013/04/10 15:14:06
this will be crashy since the browser window could
macourteau
2013/04/10 20:54:26
Thanks for the suggestion - helped a lot. I've mer
| |
589 base::TimeDelta::FromMilliseconds(kFirstRunBubbleDelayMs)); | |
590 | |
591 // Destroy this bubble launcher. | |
579 delete this; | 592 delete this; |
580 } | 593 } |
581 | 594 |
582 void SetMasterPrefsPathForTesting(const base::FilePath& master_prefs) { | 595 void SetMasterPrefsPathForTesting(const base::FilePath& master_prefs) { |
583 internal::master_prefs_path_for_testing.Get() = master_prefs; | 596 internal::master_prefs_path_for_testing.Get() = master_prefs; |
584 } | 597 } |
585 | 598 |
586 ProcessMasterPreferencesResult ProcessMasterPreferences( | 599 ProcessMasterPreferencesResult ProcessMasterPreferences( |
587 const base::FilePath& user_data_dir, | 600 const base::FilePath& user_data_dir, |
588 MasterPrefs* out_prefs) { | 601 MasterPrefs* out_prefs) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 internal::DoPostImportPlatformSpecificTasks(); | 760 internal::DoPostImportPlatformSpecificTasks(); |
748 } | 761 } |
749 | 762 |
750 bool DidPerformProfileImport(bool* exited_successfully) { | 763 bool DidPerformProfileImport(bool* exited_successfully) { |
751 if (exited_successfully) | 764 if (exited_successfully) |
752 *exited_successfully = profile_import_exited_successfully; | 765 *exited_successfully = profile_import_exited_successfully; |
753 return did_perform_profile_import; | 766 return did_perform_profile_import; |
754 } | 767 } |
755 | 768 |
756 } // namespace first_run | 769 } // namespace first_run |
OLD | NEW |