OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/startup/startup_tab_provider.h" | 5 #include "chrome/browser/ui/startup/startup_tab_provider.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/first_run/first_run.h" | 8 #include "chrome/browser/first_run/first_run.h" |
9 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" | 9 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" |
10 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" | 10 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" |
11 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
12 #include "chrome/browser/ui/chrome_pages.h" | 12 #include "chrome/browser/ui/chrome_pages.h" |
13 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 13 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "chrome/grit/locale_settings.h" | 16 #include "chrome/grit/locale_settings.h" |
17 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
18 #include "components/signin/core/browser/signin_manager.h" | 18 #include "components/signin/core/browser/signin_manager.h" |
19 #include "net/base/url_util.h" | 19 #include "net/base/url_util.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 | 21 |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/shell_integration.h" | 25 #include "chrome/browser/shell_integration.h" |
26 #endif | 26 #endif |
27 | 27 |
28 namespace { | |
29 | |
30 // The set default browser operation can be disabled by the browser distribution | |
31 // (e.g. SxS Canary), or by enterprise policy. In these cases, the Win 10 promo | |
32 // page should not be displayed. | |
33 bool IsSetDefaultBrowserAllowed(PrefService* local_state) { | |
34 bool disabled_by_enterprise_policy = | |
35 local_state && | |
36 local_state->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled) && | |
37 !local_state->GetBoolean(prefs::kDefaultBrowserSettingEnabled); | |
38 bool allowed_by_distribution = shell_integration::CanSetAsDefaultBrowser(); | |
Peter Kasting
2017/01/11 01:06:09
Nit: I'd just inline this below
Patrick Monette
2017/01/11 16:41:20
I inlined the whole function below.
| |
39 return !disabled_by_enterprise_policy && allowed_by_distribution; | |
40 } | |
41 | |
42 } // namespace | |
43 | |
28 StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { | 44 StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { |
29 if (!profile) | 45 if (!profile) |
30 return StartupTabs(); | 46 return StartupTabs(); |
31 | 47 |
32 bool is_first_run = first_run::IsChromeFirstRun(); | 48 bool is_first_run = first_run::IsChromeFirstRun(); |
33 PrefService* prefs = profile->GetPrefs(); | 49 PrefService* prefs = profile->GetPrefs(); |
34 bool has_seen_welcome_page = | 50 bool has_seen_welcome_page = |
35 prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage); | 51 prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage); |
36 SigninManagerBase* signin_manager = | 52 SigninManagerBase* signin_manager = |
37 SigninManagerFactory::GetForProfile(profile); | 53 SigninManagerFactory::GetForProfile(profile); |
38 bool is_signed_in = signin_manager && signin_manager->IsAuthenticated(); | 54 bool is_signed_in = signin_manager && signin_manager->IsAuthenticated(); |
39 | 55 |
40 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
41 // Windows 10 has unique onboarding policies and content. | 57 // Windows 10 has unique onboarding policies and content. |
42 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { | 58 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { |
43 PrefService* local_state = g_browser_process->local_state(); | 59 PrefService* local_state = g_browser_process->local_state(); |
44 bool has_seen_win10_promo = | 60 bool has_seen_win10_promo = |
45 local_state && local_state->GetBoolean(prefs::kHasSeenWin10PromoPage); | 61 local_state && local_state->GetBoolean(prefs::kHasSeenWin10PromoPage); |
62 bool set_default_browser_allowed = IsSetDefaultBrowserAllowed(local_state); | |
Peter Kasting
2017/01/11 01:06:09
Nit: I'd just inline this below, or else I'd inlin
Patrick Monette
2017/01/11 16:41:20
Done.
| |
46 bool is_default_browser = | 63 bool is_default_browser = |
47 g_browser_process->CachedDefaultWebClientState() == | 64 g_browser_process->CachedDefaultWebClientState() == |
48 shell_integration::IS_DEFAULT; | 65 shell_integration::IS_DEFAULT; |
49 return CheckWin10OnboardingTabPolicy(is_first_run, has_seen_welcome_page, | 66 return CheckWin10OnboardingTabPolicy( |
50 has_seen_win10_promo, is_signed_in, | 67 is_first_run, has_seen_welcome_page, has_seen_win10_promo, is_signed_in, |
51 is_default_browser); | 68 set_default_browser_allowed, is_default_browser); |
52 } | 69 } |
53 #endif | 70 #endif |
54 | 71 |
55 return CheckStandardOnboardingTabPolicy(is_first_run, has_seen_welcome_page, | 72 return CheckStandardOnboardingTabPolicy(is_first_run, has_seen_welcome_page, |
56 is_signed_in); | 73 is_signed_in); |
57 } | 74 } |
58 | 75 |
59 StartupTabs StartupTabProviderImpl::GetDistributionFirstRunTabs( | 76 StartupTabs StartupTabProviderImpl::GetDistributionFirstRunTabs( |
60 StartupBrowserCreator* browser_creator) const { | 77 StartupBrowserCreator* browser_creator) const { |
61 if (!browser_creator) | 78 if (!browser_creator) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 return tabs; | 125 return tabs; |
109 } | 126 } |
110 | 127 |
111 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
112 // static | 129 // static |
113 StartupTabs StartupTabProviderImpl::CheckWin10OnboardingTabPolicy( | 130 StartupTabs StartupTabProviderImpl::CheckWin10OnboardingTabPolicy( |
114 bool is_first_run, | 131 bool is_first_run, |
115 bool has_seen_welcome_page, | 132 bool has_seen_welcome_page, |
116 bool has_seen_win10_promo, | 133 bool has_seen_win10_promo, |
117 bool is_signed_in, | 134 bool is_signed_in, |
135 bool set_default_browser_allowed, | |
118 bool is_default_browser) { | 136 bool is_default_browser) { |
119 StartupTabs tabs; | 137 StartupTabs tabs; |
120 if (!has_seen_win10_promo && !is_default_browser) | 138 if (set_default_browser_allowed && !has_seen_win10_promo && |
139 !is_default_browser) | |
121 tabs.emplace_back(GetWin10WelcomePageUrl(!is_first_run), false); | 140 tabs.emplace_back(GetWin10WelcomePageUrl(!is_first_run), false); |
122 else if (!has_seen_welcome_page && !is_signed_in) | 141 else if (!has_seen_welcome_page && !is_signed_in) |
123 tabs.emplace_back(GetWelcomePageUrl(!is_first_run), false); | 142 tabs.emplace_back(GetWelcomePageUrl(!is_first_run), false); |
124 return tabs; | 143 return tabs; |
125 } | 144 } |
126 #endif | 145 #endif |
127 | 146 |
128 // static | 147 // static |
129 StartupTabs StartupTabProviderImpl::CheckMasterPrefsTabPolicy( | 148 StartupTabs StartupTabProviderImpl::CheckMasterPrefsTabPolicy( |
130 bool is_first_run, | 149 bool is_first_run, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 ? net::AppendQueryParameter(url, "text", "faster") | 221 ? net::AppendQueryParameter(url, "text", "faster") |
203 : url; | 222 : url; |
204 } | 223 } |
205 #endif | 224 #endif |
206 | 225 |
207 // static | 226 // static |
208 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { | 227 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { |
209 return GURL( | 228 return GURL( |
210 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage)); | 229 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage)); |
211 } | 230 } |
OLD | NEW |