| 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" |
| 25 #include "chrome/browser/shell_integration.h" |
| 24 #endif | 26 #endif |
| 25 | 27 |
| 26 StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { | 28 StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { |
| 27 #if defined(OS_WIN) | |
| 28 // Windows 10 has unique onboarding policies and content. | |
| 29 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { | |
| 30 // TODO(tmartino): * Add a function, GetWin10SystemState, which gathers | |
| 31 // system state relevant to Win10 Onboarding and returns | |
| 32 // a struct. | |
| 33 // * Add a function, CheckWin10OnboardingTabPolicy, which | |
| 34 // takes such a struct as input and returns StartupTabs. | |
| 35 return StartupTabs(); | |
| 36 } | |
| 37 #endif | |
| 38 | |
| 39 if (!profile) | 29 if (!profile) |
| 40 return StartupTabs(); | 30 return StartupTabs(); |
| 41 | 31 |
| 32 bool is_first_run = first_run::IsChromeFirstRun(); |
| 42 PrefService* prefs = profile->GetPrefs(); | 33 PrefService* prefs = profile->GetPrefs(); |
| 43 bool has_seen_welcome_page = | 34 bool has_seen_welcome_page = |
| 44 prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage); | 35 prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage); |
| 45 SigninManagerBase* signin_manager = | 36 SigninManagerBase* signin_manager = |
| 46 SigninManagerFactory::GetForProfile(profile); | 37 SigninManagerFactory::GetForProfile(profile); |
| 47 bool is_signed_in = signin_manager && signin_manager->IsAuthenticated(); | 38 bool is_signed_in = signin_manager && signin_manager->IsAuthenticated(); |
| 48 return CheckStandardOnboardingTabPolicy(first_run::IsChromeFirstRun(), | 39 |
| 49 has_seen_welcome_page, is_signed_in); | 40 #if defined(OS_WIN) |
| 41 // Windows 10 has unique onboarding policies and content. |
| 42 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { |
| 43 PrefService* local_state = g_browser_process->local_state(); |
| 44 bool has_seen_win10_promo = |
| 45 local_state && local_state->GetBoolean(prefs::kHasSeenWin10PromoPage); |
| 46 bool is_default_browser = |
| 47 g_browser_process->CachedDefaultWebClientState() == |
| 48 shell_integration::IS_DEFAULT; |
| 49 return CheckWin10OnboardingTabPolicy(is_first_run, has_seen_welcome_page, |
| 50 has_seen_win10_promo, is_signed_in, |
| 51 is_default_browser); |
| 52 } |
| 53 #endif |
| 54 |
| 55 return CheckStandardOnboardingTabPolicy(is_first_run, has_seen_welcome_page, |
| 56 is_signed_in); |
| 50 } | 57 } |
| 51 | 58 |
| 52 StartupTabs StartupTabProviderImpl::GetDistributionFirstRunTabs( | 59 StartupTabs StartupTabProviderImpl::GetDistributionFirstRunTabs( |
| 53 StartupBrowserCreator* browser_creator) const { | 60 StartupBrowserCreator* browser_creator) const { |
| 54 if (!browser_creator) | 61 if (!browser_creator) |
| 55 return StartupTabs(); | 62 return StartupTabs(); |
| 56 StartupTabs tabs = CheckMasterPrefsTabPolicy( | 63 StartupTabs tabs = CheckMasterPrefsTabPolicy( |
| 57 first_run::IsChromeFirstRun(), browser_creator->first_run_tabs_); | 64 first_run::IsChromeFirstRun(), browser_creator->first_run_tabs_); |
| 58 browser_creator->first_run_tabs_.clear(); | 65 browser_creator->first_run_tabs_.clear(); |
| 59 return tabs; | 66 return tabs; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 StartupTabs StartupTabProviderImpl::CheckStandardOnboardingTabPolicy( | 101 StartupTabs StartupTabProviderImpl::CheckStandardOnboardingTabPolicy( |
| 95 bool is_first_run, | 102 bool is_first_run, |
| 96 bool has_seen_welcome_page, | 103 bool has_seen_welcome_page, |
| 97 bool is_signed_in) { | 104 bool is_signed_in) { |
| 98 StartupTabs tabs; | 105 StartupTabs tabs; |
| 99 if (!has_seen_welcome_page && !is_signed_in) | 106 if (!has_seen_welcome_page && !is_signed_in) |
| 100 tabs.emplace_back(GetWelcomePageUrl(!is_first_run), false); | 107 tabs.emplace_back(GetWelcomePageUrl(!is_first_run), false); |
| 101 return tabs; | 108 return tabs; |
| 102 } | 109 } |
| 103 | 110 |
| 111 #if defined(OS_WIN) |
| 112 // static |
| 113 StartupTabs StartupTabProviderImpl::CheckWin10OnboardingTabPolicy( |
| 114 bool is_first_run, |
| 115 bool has_seen_welcome_page, |
| 116 bool has_seen_win10_promo, |
| 117 bool is_signed_in, |
| 118 bool is_default_browser) { |
| 119 StartupTabs tabs; |
| 120 if (!has_seen_win10_promo && !is_default_browser) |
| 121 tabs.emplace_back(GetWin10WelcomePageUrl(!is_first_run), false); |
| 122 else if (!has_seen_welcome_page && !is_signed_in) |
| 123 tabs.emplace_back(GetWelcomePageUrl(!is_first_run), false); |
| 124 return tabs; |
| 125 } |
| 126 #endif |
| 127 |
| 104 // static | 128 // static |
| 105 StartupTabs StartupTabProviderImpl::CheckMasterPrefsTabPolicy( | 129 StartupTabs StartupTabProviderImpl::CheckMasterPrefsTabPolicy( |
| 106 bool is_first_run, | 130 bool is_first_run, |
| 107 const std::vector<GURL>& first_run_tabs) { | 131 const std::vector<GURL>& first_run_tabs) { |
| 108 // Constants: Magic words used by Master Preferences files in place of a URL | 132 // Constants: Magic words used by Master Preferences files in place of a URL |
| 109 // host to indicate that internal pages should appear on first run. | 133 // host to indicate that internal pages should appear on first run. |
| 110 static constexpr char kNewTabUrlHost[] = "new_tab_page"; | 134 static constexpr char kNewTabUrlHost[] = "new_tab_page"; |
| 111 static constexpr char kWelcomePageUrlHost[] = "welcome_page"; | 135 static constexpr char kWelcomePageUrlHost[] = "welcome_page"; |
| 112 | 136 |
| 113 StartupTabs tabs; | 137 StartupTabs tabs; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 186 } |
| 163 | 187 |
| 164 // static | 188 // static |
| 165 GURL StartupTabProviderImpl::GetWelcomePageUrl(bool use_later_run_variant) { | 189 GURL StartupTabProviderImpl::GetWelcomePageUrl(bool use_later_run_variant) { |
| 166 GURL url(chrome::kChromeUIWelcomeURL); | 190 GURL url(chrome::kChromeUIWelcomeURL); |
| 167 return use_later_run_variant | 191 return use_later_run_variant |
| 168 ? net::AppendQueryParameter(url, "variant", "everywhere") | 192 ? net::AppendQueryParameter(url, "variant", "everywhere") |
| 169 : url; | 193 : url; |
| 170 } | 194 } |
| 171 | 195 |
| 196 #if defined(OS_WIN) |
| 197 // static |
| 198 GURL StartupTabProviderImpl::GetWin10WelcomePageUrl( |
| 199 bool use_later_run_variant) { |
| 200 GURL url(chrome::kChromeUIWelcomeWin10URL); |
| 201 return use_later_run_variant |
| 202 ? net::AppendQueryParameter(url, "text", "faster") |
| 203 : url; |
| 204 } |
| 205 #endif |
| 206 |
| 172 // static | 207 // static |
| 173 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { | 208 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { |
| 174 return GURL( | 209 return GURL( |
| 175 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage)); | 210 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage)); |
| 176 } | 211 } |
| OLD | NEW |