Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 "content/public/browser/web_ui_data_source.h" | |
| 10 #include "grit/browser_resources.h" | |
| 11 #include "grit/chrome_unscaled_resources.h" | |
| 12 #include "grit/chromium_strings.h" | |
| 13 #include "grit/generated_resources.h" | |
| 14 #include "grit/webui_resources.h" | |
| 15 #include "ui/base/l10n/l10n_util.h" | |
| 16 | |
| 17 // A URL ending in /1 indicates that we should modify the page to use the | |
| 18 // "Take Chrome Everywhere" text. | |
| 19 const char* kEverywhereVariantPath = "/1"; | |
| 20 | |
| 21 WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) | |
| 22 : content::WebUIController(web_ui) { | |
| 23 // TODO(tmartino): Create WelcomeHandler. | |
| 24 // web_ui->AddMessageHandler(new WelcomeHandler()); | |
| 25 | |
| 26 content::WebUIDataSource* html_source = | |
| 27 content::WebUIDataSource::Create(url.host()); | |
| 28 | |
| 29 // Check URL for variations. | |
| 30 bool is_everywhere_variant = url.path().compare(kEverywhereVariantPath) == 0; | |
| 31 | |
| 32 int header_id = is_everywhere_variant ? IDS_WELCOME_UI_EVERYWHERE_HEADER | |
| 33 : IDS_WELCOME_UI_WELCOME_HEADER; | |
| 34 html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id)); | |
| 35 | |
| 36 // The subheader describes the browser as being "by Google", so we only show | |
| 37 // it in the "Welcome to Chrome" variant, and only on branded builds. | |
| 38 base::string16 subheader = base::string16(); | |
| 39 | |
| 40 #if defined(GOOGLE_CHROME_BUILD) | |
| 41 if (!is_everywhere_variant) | |
| 42 subheader = l10n_util::GetStringUTF16(IDS_WELCOME_UI_SUBHEADER); | |
| 43 #endif | |
| 44 html_source->AddString("subheaderText", subheader); | |
| 45 | |
| 46 html_source->AddLocalizedString("descriptionText", | |
| 47 IDS_WELCOME_UI_DESCRIPTION); | |
| 48 html_source->AddLocalizedString("acceptText", IDS_WELCOME_UI_ACCEPT_BUTTON); | |
| 49 html_source->AddLocalizedString("declineText", IDS_WELCOME_UI_DECLINE_BUTTON); | |
| 50 | |
| 51 html_source->AddResourcePath("welcome.css", IDR_WELCOME_CSS); | |
| 52 html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS); | |
| 53 html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128); | |
|
Moe
2016/08/22 20:40:52
I'm not sure whether this is the right resource to
| |
| 54 html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO); | |
| 55 html_source->SetDefaultResource(IDR_WELCOME_HTML); | |
| 56 | |
| 57 Profile* profile = Profile::FromWebUI(web_ui); | |
| 58 content::WebUIDataSource::Add(profile, html_source); | |
| 59 } | |
| 60 | |
| 61 WelcomeUI::~WelcomeUI() {} | |
| OLD | NEW |