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