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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
39 #include "chrome/browser/shell_integration.h" | 39 #include "chrome/browser/shell_integration.h" |
40 #include "chrome/browser/signin/signin_manager_factory.h" | 40 #include "chrome/browser/signin/signin_manager_factory.h" |
41 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
42 #include "chrome/browser/ui/browser_finder.h" | 42 #include "chrome/browser/ui/browser_finder.h" |
43 #include "chrome/browser/ui/chrome_pages.h" | 43 #include "chrome/browser/ui/chrome_pages.h" |
44 #include "chrome/browser/ui/global_error/global_error_service.h" | 44 #include "chrome/browser/ui/global_error/global_error_service.h" |
45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
46 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 46 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
47 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 47 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
48 #include "chrome/common/channel_info.h" | |
49 #include "chrome/common/chrome_constants.h" | 48 #include "chrome/common/chrome_constants.h" |
50 #include "chrome/common/chrome_paths.h" | 49 #include "chrome/common/chrome_paths.h" |
51 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
52 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
54 #include "chrome/grit/locale_settings.h" | 53 #include "chrome/grit/locale_settings.h" |
55 #include "chrome/installer/util/master_preferences.h" | 54 #include "chrome/installer/util/master_preferences.h" |
56 #include "chrome/installer/util/master_preferences_constants.h" | 55 #include "chrome/installer/util/master_preferences_constants.h" |
57 #include "chrome/installer/util/util_constants.h" | 56 #include "chrome/installer/util/util_constants.h" |
58 #include "components/pref_registry/pref_registry_syncable.h" | 57 #include "components/pref_registry/pref_registry_syncable.h" |
59 #include "components/prefs/pref_service.h" | 58 #include "components/prefs/pref_service.h" |
60 #include "components/search_engines/template_url_service.h" | 59 #include "components/search_engines/template_url_service.h" |
61 #include "components/signin/core/browser/signin_manager.h" | 60 #include "components/signin/core/browser/signin_manager.h" |
62 #include "components/signin/core/browser/signin_tracker.h" | 61 #include "components/signin/core/browser/signin_tracker.h" |
63 #include "components/version_info/version_info.h" | |
64 #include "content/public/browser/navigation_entry.h" | 62 #include "content/public/browser/navigation_entry.h" |
65 #include "content/public/browser/notification_observer.h" | 63 #include "content/public/browser/notification_observer.h" |
66 #include "content/public/browser/notification_registrar.h" | 64 #include "content/public/browser/notification_registrar.h" |
67 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
68 #include "content/public/browser/notification_types.h" | 66 #include "content/public/browser/notification_types.h" |
69 #include "content/public/browser/user_metrics.h" | 67 #include "content/public/browser/user_metrics.h" |
70 #include "content/public/browser/web_contents.h" | 68 #include "content/public/browser/web_contents.h" |
71 #include "extensions/browser/extension_system.h" | 69 #include "extensions/browser/extension_system.h" |
72 #include "extensions/common/one_shot_event.h" | 70 #include "extensions/common/one_shot_event.h" |
73 #include "google_apis/gaia/gaia_auth_util.h" | 71 #include "google_apis/gaia/gaia_auth_util.h" |
74 #include "ui/base/l10n/l10n_util.h" | 72 #include "ui/base/l10n/l10n_util.h" |
75 #include "url/gurl.h" | 73 #include "url/gurl.h" |
76 | 74 |
77 namespace content { | 75 namespace content { |
78 class BrowserContext; | 76 class BrowserContext; |
79 } | 77 } |
80 | 78 |
81 using base::UserMetricsAction; | 79 using base::UserMetricsAction; |
82 | 80 |
83 namespace { | 81 namespace { |
84 | 82 |
83 const bool kDefaultMetricsReportingState = true; | |
84 | |
85 // A bitfield formed from values in AutoImportState to record the state of | 85 // A bitfield formed from values in AutoImportState to record the state of |
86 // AutoImport. This is used in testing to verify import startup actions that | 86 // AutoImport. This is used in testing to verify import startup actions that |
87 // occur before an observer can be registered in the test. | 87 // occur before an observer can be registered in the test. |
88 uint16_t g_auto_import_state = first_run::AUTO_IMPORT_NONE; | 88 uint16_t g_auto_import_state = first_run::AUTO_IMPORT_NONE; |
89 | 89 |
90 // Flags for functions of similar name. | 90 // Flags for functions of similar name. |
91 bool g_should_show_welcome_page = false; | 91 bool g_should_show_welcome_page = false; |
92 bool g_should_do_autofill_personal_data_manager_first_run = false; | 92 bool g_should_do_autofill_personal_data_manager_first_run = false; |
93 | 93 |
94 // This class acts as an observer for the ImporterProgressObserver::ImportEnded | 94 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 return internal::g_first_run == internal::FIRST_RUN_TRUE; | 647 return internal::g_first_run == internal::FIRST_RUN_TRUE; |
648 } | 648 } |
649 | 649 |
650 #if defined(OS_MACOSX) | 650 #if defined(OS_MACOSX) |
651 bool IsFirstRunSuppressed(const base::CommandLine& command_line) { | 651 bool IsFirstRunSuppressed(const base::CommandLine& command_line) { |
652 return command_line.HasSwitch(switches::kNoFirstRun); | 652 return command_line.HasSwitch(switches::kNoFirstRun); |
653 } | 653 } |
654 #endif | 654 #endif |
655 | 655 |
656 bool IsMetricsReportingOptIn() { | 656 bool IsMetricsReportingOptIn() { |
657 #if defined(OS_CHROMEOS) | 657 // If default is true then it corresponds to opt-out and false corresponds to |
658 return false; | 658 // opt-in. |
659 #elif defined(OS_ANDROID) | 659 return !kDefaultMetricsReportingState; |
sky
2016/08/26 00:00:57
The negative is always confusing. Is the reason yo
gayane -on leave until 09-2017
2016/08/26 00:22:34
Done.
| |
660 #error This file shouldn not be compiled on Android. | |
661 #elif defined(OS_MACOSX) | |
662 return chrome::GetChannel() != version_info::Channel::CANARY; | |
663 #elif defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) | |
664 // Treat BSD and SOLARIS like Linux to not break those builds, although these | |
665 // platforms are not officially supported by Chrome. | |
666 return true; | |
667 #elif defined(OS_WIN) | |
668 // TODO(jwd): Get this data directly from the download page. | |
669 // Metrics reporting for Windows is initially enabled on the download page. If | |
670 // it's opt-in or out can change without changes to Chrome. We should get this | |
671 // information directly from the download page for it to be accurate. | |
672 return chrome::GetChannel() == version_info::Channel::STABLE; | |
673 #else | |
674 #error Unsupported platform. | |
675 #endif | |
676 } | 660 } |
677 | 661 |
678 void CreateSentinelIfNeeded() { | 662 void CreateSentinelIfNeeded() { |
679 if (IsChromeFirstRun()) | 663 if (IsChromeFirstRun()) |
680 internal::CreateSentinel(); | 664 internal::CreateSentinel(); |
681 } | 665 } |
682 | 666 |
683 std::string GetPingDelayPrefName() { | 667 std::string GetPingDelayPrefName() { |
684 return base::StringPrintf("%s.%s", | 668 return base::StringPrintf("%s.%s", |
685 installer::master_preferences::kDistroDict, | 669 installer::master_preferences::kDistroDict, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
858 SetShouldDoPersonalDataManagerFirstRun(); | 842 SetShouldDoPersonalDataManagerFirstRun(); |
859 | 843 |
860 internal::DoPostImportPlatformSpecificTasks(profile); | 844 internal::DoPostImportPlatformSpecificTasks(profile); |
861 } | 845 } |
862 | 846 |
863 uint16_t auto_import_state() { | 847 uint16_t auto_import_state() { |
864 return g_auto_import_state; | 848 return g_auto_import_state; |
865 } | 849 } |
866 | 850 |
867 } // namespace first_run | 851 } // namespace first_run |
OLD | NEW |