| OLD | NEW |
| (Empty) | |
| 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 |
| 5 #include "chrome/browser/ui/webui/welcome_ui.h" |
| 6 |
| 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/common/url_constants.h" |
| 9 #include "chrome/grit/browser_resources.h" |
| 10 #include "chrome/grit/chrome_unscaled_resources.h" |
| 11 #include "chrome/grit/chromium_strings.h" |
| 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "content/public/browser/web_ui_data_source.h" |
| 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/resources/grit/webui_resources.h" |
| 16 |
| 17 namespace { |
| 18 |
| 19 // A URL ending in /1 indicates that we should modify the page to use the |
| 20 // "Take Chrome Everywhere" text. |
| 21 const char* kEverywhereVariantPath = "/1"; |
| 22 |
| 23 } // namespace |
| 24 |
| 25 WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) |
| 26 : content::WebUIController(web_ui) { |
| 27 // TODO(tmartino): Create WelcomeHandler, and add here. |
| 28 |
| 29 content::WebUIDataSource* html_source = |
| 30 content::WebUIDataSource::Create(url.host()); |
| 31 |
| 32 // Check URL for variations. |
| 33 bool is_everywhere_variant = url.path() == kEverywhereVariantPath; |
| 34 |
| 35 int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN |
| 36 : IDS_WELCOME_HEADER; |
| 37 html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id)); |
| 38 |
| 39 // The subheader describes the browser as being "by Google", so we only show |
| 40 // it in the "Welcome to Chrome" variant, and only on branded builds. |
| 41 #if defined(GOOGLE_CHROME_BUILD) |
| 42 base::string16 subheader = |
| 43 is_everywhere_variant ? base::string16() |
| 44 : l10n_util::GetStringUTF16(IDS_WELCOME_SUBHEADER); |
| 45 html_source->AddString("subheaderText", subheader); |
| 46 #endif |
| 47 |
| 48 html_source->AddLocalizedString("descriptionText", IDS_WELCOME_DESCRIPTION); |
| 49 html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON); |
| 50 html_source->AddLocalizedString("declineText", IDS_WELCOME_DECLINE_BUTTON); |
| 51 |
| 52 html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS); |
| 53 html_source->AddResourcePath("welcome.css", IDR_WELCOME_CSS); |
| 54 html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128); |
| 55 html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256); |
| 56 html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO); |
| 57 html_source->SetDefaultResource(IDR_WELCOME_HTML); |
| 58 |
| 59 Profile* profile = Profile::FromWebUI(web_ui); |
| 60 content::WebUIDataSource::Add(profile, html_source); |
| 61 } |
| 62 |
| 63 WelcomeUI::~WelcomeUI() {} |
| OLD | NEW |