tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 5 | #include "chrome/browser/ui/webui/welcome/welcome_ui.h" |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 6 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 7 | #include "base/metrics/histogram_macros.h" |
Hector Carmona | c98557a99 | 2018-06-27 17:51:43 | [diff] [blame] | 8 | #include "build/build_config.h" |
David Roger | f53a075 | 2018-06-18 14:46:48 | [diff] [blame] | 9 | #include "chrome/browser/signin/account_consistency_mode_manager.h" |
Dan Beam | 18cd597 | 2019-02-07 03:54:29 | [diff] [blame] | 10 | #include "chrome/browser/ui/webui/dark_mode_handler.h" |
Lei Zhang | 0a1c1c7 | 2018-12-13 20:41:33 | [diff] [blame] | 11 | #include "chrome/browser/ui/webui/localized_string.h" |
Hector Carmona | 207744f | 2018-10-25 23:49:54 | [diff] [blame] | 12 | #include "chrome/browser/ui/webui/welcome/nux/bookmark_handler.h" |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 13 | #include "chrome/browser/ui/webui/welcome/nux/constants.h" |
| 14 | #include "chrome/browser/ui/webui/welcome/nux/email_handler.h" |
| 15 | #include "chrome/browser/ui/webui/welcome/nux/google_apps_handler.h" |
John Lee | eba5909 | 2019-02-05 23:44:58 | [diff] [blame] | 16 | #include "chrome/browser/ui/webui/welcome/nux/ntp_background_handler.h" |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 17 | #include "chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h" |
Scott Chen | c74ed76 | 2018-09-21 00:23:16 | [diff] [blame] | 18 | #include "chrome/browser/ui/webui/welcome/nux_helper.h" |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 19 | #include "chrome/browser/ui/webui/welcome/welcome_handler.h" |
tmartino | 6254f47 | 2016-11-21 01:22:56 | [diff] [blame] | 20 | #include "chrome/common/pref_names.h" |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 21 | #include "chrome/grit/browser_resources.h" |
| 22 | #include "chrome/grit/chrome_unscaled_resources.h" |
| 23 | #include "chrome/grit/chromium_strings.h" |
| 24 | #include "chrome/grit/generated_resources.h" |
dpapad | b1f8e9a | 2018-10-18 21:36:08 | [diff] [blame] | 25 | #include "chrome/grit/onboarding_welcome_resources.h" |
| 26 | #include "chrome/grit/onboarding_welcome_resources_map.h" |
tmartino | 6254f47 | 2016-11-21 01:22:56 | [diff] [blame] | 27 | #include "components/prefs/pref_service.h" |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 28 | #include "components/strings/grit/components_strings.h" |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 29 | #include "content/public/browser/web_contents.h" |
tmartino | 7f0818b | 2016-09-27 23:39:07 | [diff] [blame] | 30 | #include "net/base/url_util.h" |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 31 | #include "ui/base/l10n/l10n_util.h" |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 32 | |
Scott Chen | e841488 | 2018-10-30 03:14:35 | [diff] [blame] | 33 | #if defined(OS_WIN) |
| 34 | #include "base/win/windows_version.h" |
| 35 | #endif |
| 36 | |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 37 | namespace { |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 38 | const bool kIsBranded = |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 39 | #if defined(GOOGLE_CHROME_BUILD) |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 40 | true; |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 41 | #else |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 42 | false; |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 43 | #endif |
Scott Chen | 532ec2c | 2018-09-26 21:50:05 | [diff] [blame] | 44 | } // namespace |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 45 | |
John Lee | 6eb43ae | 2019-02-28 21:25:26 | [diff] [blame] | 46 | bool HandleRequestCallback( |
| 47 | base::WeakPtr<WelcomeUI> weak_ptr, |
| 48 | const std::string& path, |
| 49 | const content::WebUIDataSource::GotDataCallback& callback) { |
| 50 | if (!base::StartsWith(path, "preview-background.jpg", |
| 51 | base::CompareCase::SENSITIVE)) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | std::string index_param = path.substr(path.find_first_of("?") + 1); |
| 56 | int background_index = -1; |
| 57 | if (!base::StringToInt(index_param, &background_index) || |
| 58 | background_index < 0) { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | if (weak_ptr) { |
| 63 | weak_ptr->CreateBackgroundFetcher(background_index, callback); |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | return false; |
| 68 | } |
| 69 | |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 70 | void AddOnboardingStrings(content::WebUIDataSource* html_source) { |
| 71 | static constexpr LocalizedString kLocalizedStrings[] = { |
| 72 | // Shared strings. |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 73 | {"acceptText", IDS_WELCOME_ACCEPT_BUTTON}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 74 | {"bookmarkAdded", IDS_ONBOARDING_WELCOME_BOOKMARK_ADDED}, |
Hector Carmona | 6d77928 | 2018-10-30 23:48:40 | [diff] [blame] | 75 | {"bookmarksAdded", IDS_ONBOARDING_WELCOME_BOOKMARKS_ADDED}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 76 | {"bookmarkRemoved", IDS_ONBOARDING_WELCOME_BOOKMARK_REMOVED}, |
Hector Carmona | 6d77928 | 2018-10-30 23:48:40 | [diff] [blame] | 77 | {"bookmarksRemoved", IDS_ONBOARDING_WELCOME_BOOKMARKS_REMOVED}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 78 | {"bookmarkReplaced", IDS_ONBOARDING_WELCOME_BOOKMARK_REPLACED}, |
Scott Chen | ebfdce73 | 2018-10-26 02:34:26 | [diff] [blame] | 79 | {"getStarted", IDS_ONBOARDING_WELCOME_GET_STARTED}, |
| 80 | {"headerText", IDS_WELCOME_HEADER}, |
| 81 | {"next", IDS_ONBOARDING_WELCOME_NEXT}, |
| 82 | {"noThanks", IDS_NO_THANKS}, |
| 83 | {"skip", IDS_ONBOARDING_WELCOME_SKIP}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 84 | |
| 85 | // Sign-in view strings. |
| 86 | {"signInHeader", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_HEADER}, |
| 87 | {"signInSubHeader", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SUB_HEADER}, |
| 88 | {"signIn", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SIGNIN}, |
| 89 | |
| 90 | // Email provider module strings. |
Scott Chen | ebfdce73 | 2018-10-26 02:34:26 | [diff] [blame] | 91 | {"emailProviderTitle", IDS_ONBOARDING_WELCOME_NUX_EMAIL_TITLE}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 92 | |
| 93 | // Google apps module strings. |
| 94 | {"googleAppsDescription", |
| 95 | IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_DESCRIPTION}, |
| 96 | |
John Lee | 0c3ede53 | 2019-01-30 02:58:50 | [diff] [blame] | 97 | // New Tab Page background module strings. |
| 98 | {"ntpBackgroundDescription", |
| 99 | IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_DESCRIPTION}, |
John Lee | cea68d4 | 2019-02-12 20:02:57 | [diff] [blame] | 100 | {"ntpBackgroundDefault", |
| 101 | IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_DEFAULT_TITLE}, |
John Lee | 10f1987 | 2019-03-11 21:28:50 | [diff] [blame] | 102 | {"ntpBackgroundPreviewUpdated", |
| 103 | IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_PREVIEW_UPDATED}, |
John Lee | b5d871e | 2019-03-12 03:30:18 | [diff] [blame^] | 104 | {"ntpBackgroundReset", IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_RESET}, |
John Lee | 0c3ede53 | 2019-01-30 02:58:50 | [diff] [blame] | 105 | |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 106 | // Set as default module strings. |
| 107 | {"setDefaultHeader", IDS_ONBOARDING_WELCOME_NUX_SET_AS_DEFAULT_HEADER}, |
| 108 | {"setDefaultSubHeader", |
| 109 | IDS_ONBOARDING_WELCOME_NUX_SET_AS_DEFAULT_SUB_HEADER}, |
| 110 | {"setDefaultSkip", IDS_ONBOARDING_WELCOME_NUX_SET_AS_DEFAULT_SKIP}, |
| 111 | {"setDefaultConfirm", |
| 112 | IDS_ONBOARDING_WELCOME_NUX_SET_AS_DEFAULT_SET_AS_DEFAULT}, |
Scott Chen | 618035d | 2018-10-24 00:48:15 | [diff] [blame] | 113 | |
| 114 | // Landing view strings. |
| 115 | {"landingTitle", IDS_ONBOARDING_WELCOME_LANDING_TITLE}, |
| 116 | {"landingDescription", IDS_ONBOARDING_WELCOME_LANDING_DESCRIPTION}, |
| 117 | {"landingNewUser", IDS_ONBOARDING_WELCOME_LANDING_NEW_USER}, |
| 118 | {"landingExistingUser", IDS_ONBOARDING_WELCOME_LANDING_EXISTING_USER}, |
| 119 | |
| 120 | // Email interstitial strings. |
| 121 | {"emailInterstitialTitle", |
| 122 | IDS_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_TITLE}, |
| 123 | {"emailInterstitialContinue", |
| 124 | IDS_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_CONTINUE}, |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 125 | }; |
Lei Zhang | 0a1c1c7 | 2018-12-13 20:41:33 | [diff] [blame] | 126 | AddLocalizedStringsBulk(html_source, kLocalizedStrings, |
| 127 | base::size(kLocalizedStrings)); |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 128 | } |
| 129 | |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 130 | WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) |
John Lee | 6eb43ae | 2019-02-28 21:25:26 | [diff] [blame] | 131 | : content::WebUIController(web_ui), weak_ptr_factory_(this) { |
tmartino | 7f0818b | 2016-09-27 23:39:07 | [diff] [blame] | 132 | Profile* profile = Profile::FromWebUI(web_ui); |
| 133 | |
| 134 | // This page is not shown to incognito or guest profiles. If one should end up |
| 135 | // here, we return, causing a 404-like page. |
| 136 | if (!profile || |
| 137 | profile->GetProfileType() != Profile::ProfileType::REGULAR_PROFILE) { |
| 138 | return; |
| 139 | } |
| 140 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 141 | StorePageSeen(profile); |
tmartino | 6254f47 | 2016-11-21 01:22:56 | [diff] [blame] | 142 | |
Jinho Bang | 7ab7a4e | 2018-01-15 14:36:07 | [diff] [blame] | 143 | web_ui->AddMessageHandler(std::make_unique<WelcomeHandler>(web_ui)); |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 144 | |
| 145 | content::WebUIDataSource* html_source = |
| 146 | content::WebUIDataSource::Create(url.host()); |
| 147 | |
Dan Beam | 18cd597 | 2019-02-07 03:54:29 | [diff] [blame] | 148 | DarkModeHandler::Initialize(web_ui, html_source); |
| 149 | |
David Roger | f53a075 | 2018-06-18 14:46:48 | [diff] [blame] | 150 | bool is_dice = |
| 151 | AccountConsistencyModeManager::IsDiceEnabledForProfile(profile); |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 152 | |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 153 | // There are multiple possible configurations that affects the layout, but |
| 154 | // first add resources that are shared across all layouts. |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 155 | html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128); |
| 156 | html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256); |
Scott Chen | a126445 | 2017-11-14 13:32:08 | [diff] [blame] | 157 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 158 | if (nux::IsNuxOnboardingEnabled(profile)) { |
Scott Chen | c74ed76 | 2018-09-21 00:23:16 | [diff] [blame] | 159 | // Add Onboarding welcome strings. |
Scott Chen | 395516b | 2018-10-23 00:05:48 | [diff] [blame] | 160 | AddOnboardingStrings(html_source); |
Scott Chen | c74ed76 | 2018-09-21 00:23:16 | [diff] [blame] | 161 | |
dpapad | b1f8e9a | 2018-10-18 21:36:08 | [diff] [blame] | 162 | // Add all Onboarding resources. |
| 163 | for (size_t i = 0; i < kOnboardingWelcomeResourcesSize; ++i) { |
| 164 | html_source->AddResourcePath(kOnboardingWelcomeResources[i].name, |
| 165 | kOnboardingWelcomeResources[i].value); |
| 166 | } |
Scott Chen | aac2e18 | 2018-10-23 01:49:44 | [diff] [blame] | 167 | |
| 168 | // chrome://welcome |
Scott Chen | c74ed76 | 2018-09-21 00:23:16 | [diff] [blame] | 169 | html_source->SetDefaultResource( |
| 170 | IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_HTML); |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 171 | |
Scott Chen | aac2e18 | 2018-10-23 01:49:44 | [diff] [blame] | 172 | // chrome://welcome/email-interstitial |
| 173 | html_source->AddResourcePath( |
| 174 | "email-interstitial", |
| 175 | IDR_WELCOME_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_HTML); |
| 176 | |
Scott Chen | e841488 | 2018-10-30 03:14:35 | [diff] [blame] | 177 | #if defined(OS_WIN) |
| 178 | html_source->AddBoolean( |
| 179 | "is_win10", base::win::GetVersion() >= base::win::VERSION_WIN10); |
| 180 | #endif |
| 181 | |
Hector Carmona | 207744f | 2018-10-25 23:49:54 | [diff] [blame] | 182 | // Add the shared bookmark handler for onboarding modules. |
| 183 | web_ui->AddMessageHandler( |
| 184 | std::make_unique<nux::BookmarkHandler>(profile->GetPrefs())); |
Hector Carmona | 207744f | 2018-10-25 23:49:54 | [diff] [blame] | 185 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 186 | // Add email provider bookmarking onboarding module. |
Scott Chen | 3bb4c57836 | 2018-10-31 00:23:31 | [diff] [blame] | 187 | web_ui->AddMessageHandler(std::make_unique<nux::EmailHandler>()); |
Hector Carmona | 207744f | 2018-10-25 23:49:54 | [diff] [blame] | 188 | nux::EmailHandler::AddSources(html_source); |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 189 | |
| 190 | // Add google apps bookmarking onboarding module. |
Scott Chen | 3bb4c57836 | 2018-10-31 00:23:31 | [diff] [blame] | 191 | web_ui->AddMessageHandler(std::make_unique<nux::GoogleAppsHandler>()); |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 192 | |
John Lee | eba5909 | 2019-02-05 23:44:58 | [diff] [blame] | 193 | // Add NTP custom background onboarding module. |
| 194 | web_ui->AddMessageHandler(std::make_unique<nux::NtpBackgroundHandler>()); |
| 195 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 196 | // Add set-as-default onboarding module. |
| 197 | web_ui->AddMessageHandler(std::make_unique<nux::SetAsDefaultHandler>()); |
Scott Chen | 0085824 | 2018-11-01 23:40:47 | [diff] [blame] | 198 | |
| 199 | html_source->AddString( |
Scott Chen | 7243c1a | 2018-11-06 01:33:41 | [diff] [blame] | 200 | "newUserModules", |
Scott Chen | 0085824 | 2018-11-01 23:40:47 | [diff] [blame] | 201 | nux::GetNuxOnboardingModules(profile).FindKey("new-user")->GetString()); |
Scott Chen | 7243c1a | 2018-11-06 01:33:41 | [diff] [blame] | 202 | html_source->AddString("returningUserModules", |
Scott Chen | 0085824 | 2018-11-01 23:40:47 | [diff] [blame] | 203 | nux::GetNuxOnboardingModules(profile) |
| 204 | .FindKey("returning-user") |
| 205 | ->GetString()); |
Scott Chen | 7243c1a | 2018-11-06 01:33:41 | [diff] [blame] | 206 | html_source->AddBoolean("showEmailInterstitial", |
| 207 | nux::GetNuxOnboardingModules(profile) |
| 208 | .FindKey("show-email-interstitial") |
| 209 | ->GetBool()); |
John Lee | 6eb43ae | 2019-02-28 21:25:26 | [diff] [blame] | 210 | html_source->SetRequestFilter(base::BindRepeating( |
| 211 | &HandleRequestCallback, weak_ptr_factory_.GetWeakPtr())); |
Scott Chen | c74ed76 | 2018-09-21 00:23:16 | [diff] [blame] | 212 | } else if (kIsBranded && is_dice) { |
| 213 | // Use special layout if the application is branded and DICE is enabled. |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 214 | html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER); |
Thomas Tangl | 441b0678 | 2018-09-27 19:37:07 | [diff] [blame] | 215 | html_source->AddLocalizedString("acceptText", |
| 216 | IDS_PROFILES_DICE_SIGNIN_BUTTON); |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 217 | html_source->AddLocalizedString("secondHeaderText", |
| 218 | IDS_DICE_WELCOME_SECOND_HEADER); |
| 219 | html_source->AddLocalizedString("descriptionText", |
| 220 | IDS_DICE_WELCOME_DESCRIPTION); |
| 221 | html_source->AddLocalizedString("declineText", |
| 222 | IDS_DICE_WELCOME_DECLINE_BUTTON); |
Mihai Sardarescu | 631f3b47 | 2018-05-04 15:08:15 | [diff] [blame] | 223 | html_source->AddResourcePath("welcome_browser_proxy.html", |
| 224 | IDR_DICE_WELCOME_BROWSER_PROXY_HTML); |
| 225 | html_source->AddResourcePath("welcome_browser_proxy.js", |
| 226 | IDR_DICE_WELCOME_BROWSER_PROXY_JS); |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 227 | html_source->AddResourcePath("welcome_app.html", IDR_DICE_WELCOME_APP_HTML); |
| 228 | html_source->AddResourcePath("welcome_app.js", IDR_DICE_WELCOME_APP_JS); |
Scott Chen | a126445 | 2017-11-14 13:32:08 | [diff] [blame] | 229 | html_source->AddResourcePath("welcome.css", IDR_DICE_WELCOME_CSS); |
| 230 | html_source->SetDefaultResource(IDR_DICE_WELCOME_HTML); |
| 231 | } else { |
Mihai Sardarescu | 631f3b47 | 2018-05-04 15:08:15 | [diff] [blame] | 232 | // Use default layout for non-DICE or unbranded build. |
| 233 | std::string value; |
| 234 | bool is_everywhere_variant = |
| 235 | (net::GetValueForKeyInQuery(url, "variant", &value) && |
| 236 | value == "everywhere"); |
| 237 | |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 238 | if (kIsBranded) { |
| 239 | base::string16 subheader = |
| 240 | is_everywhere_variant |
| 241 | ? base::string16() |
| 242 | : l10n_util::GetStringUTF16(IDS_WELCOME_SUBHEADER); |
| 243 | html_source->AddString("subheaderText", subheader); |
| 244 | } |
| 245 | |
| 246 | int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN |
| 247 | : IDS_WELCOME_HEADER; |
| 248 | html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id)); |
Thomas Tangl | 441b0678 | 2018-09-27 19:37:07 | [diff] [blame] | 249 | html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON); |
Scott Chen | c670667 | 2017-11-17 17:40:27 | [diff] [blame] | 250 | html_source->AddLocalizedString("descriptionText", IDS_WELCOME_DESCRIPTION); |
| 251 | html_source->AddLocalizedString("declineText", IDS_WELCOME_DECLINE_BUTTON); |
Scott Chen | a126445 | 2017-11-14 13:32:08 | [diff] [blame] | 252 | html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS); |
| 253 | html_source->AddResourcePath("welcome.css", IDR_WELCOME_CSS); |
| 254 | html_source->SetDefaultResource(IDR_WELCOME_HTML); |
| 255 | } |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 256 | |
tmartino | e3f9c38e | 2016-09-13 14:05:32 | [diff] [blame] | 257 | content::WebUIDataSource::Add(profile, html_source); |
| 258 | } |
| 259 | |
| 260 | WelcomeUI::~WelcomeUI() {} |
Hector Carmona | 8f2c3cb | 2018-07-12 21:07:58 | [diff] [blame] | 261 | |
John Lee | 6eb43ae | 2019-02-28 21:25:26 | [diff] [blame] | 262 | void WelcomeUI::CreateBackgroundFetcher( |
| 263 | size_t background_index, |
| 264 | const content::WebUIDataSource::GotDataCallback& callback) { |
| 265 | background_fetcher_ = |
| 266 | std::make_unique<nux::NtpBackgroundFetcher>(background_index, callback); |
| 267 | } |
| 268 | |
Scott Chen | f68c9b2 | 2018-10-12 02:15:25 | [diff] [blame] | 269 | void WelcomeUI::StorePageSeen(Profile* profile) { |
Hector Carmona | 8f2c3cb | 2018-07-12 21:07:58 | [diff] [blame] | 270 | // Store that this profile has been shown the Welcome page. |
| 271 | profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 272 | } |