Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/ui/webui/welcome_ui.cc

Issue 2252063002: Adding client code for new desktop First Run Experience. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing michaelpg comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // 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";
michaelpg 2016/09/09 05:36:26 wrap in an anonymous namespace to prevent global v
20
21 WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
22 : content::WebUIController(web_ui) {
23 // TODO(tmartino): Create WelcomeHandler, and add here.
24
25 content::WebUIDataSource* html_source =
26 content::WebUIDataSource::Create(url.host());
27
28 // Check URL for variations.
29 bool is_everywhere_variant = url.path().compare(kEverywhereVariantPath) == 0;
michaelpg 2016/09/09 05:36:26 just use operator==
30
31 int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN
32 : IDS_WELCOME_HEADER;
33 html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id));
34
35 // The subheader describes the browser as being "by Google", so we only show
36 // it in the "Welcome to Chrome" variant, and only on branded builds.
37 #if defined(GOOGLE_CHROME_BUILD)
38 base::string16 subheader =
39 is_everywhere_variant ? base::string16()
40 : l10n_util::GetStringUTF16(IDS_WELCOME_SUBHEADER);
41 html_source->AddString("subheaderText", subheader);
42 #endif
43
44 html_source->AddLocalizedString("descriptionText", IDS_WELCOME_DESCRIPTION);
45 html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON);
46 html_source->AddLocalizedString("declineText", IDS_WELCOME_DECLINE_BUTTON);
47
48 html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS);
49 html_source->AddResourcePath("welcome.css", IDR_WELCOME_CSS);
50 html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
51 html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256);
52 html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO);
53 html_source->SetDefaultResource(IDR_WELCOME_HTML);
54
55 Profile* profile = Profile::FromWebUI(web_ui);
56 content::WebUIDataSource::Add(profile, html_source);
57 }
58
59 WelcomeUI::~WelcomeUI() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698