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

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

Issue 2338213007: Adding JS and C++ handlers for events on new Welcome page. (Closed)
Patch Set: Further comments from anthonyvd Created 4 years, 2 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
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/webui/welcome_ui.h" 5 #include "chrome/browser/ui/webui/welcome_ui.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/browser/ui/webui/welcome_handler.h"
9 #include "chrome/grit/browser_resources.h" 9 #include "chrome/grit/browser_resources.h"
10 #include "chrome/grit/chrome_unscaled_resources.h" 10 #include "chrome/grit/chrome_unscaled_resources.h"
11 #include "chrome/grit/chromium_strings.h" 11 #include "chrome/grit/chromium_strings.h"
12 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "content/public/browser/web_ui_data_source.h" 13 #include "content/public/browser/web_ui_data_source.h"
14 #include "net/base/url_util.h"
14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/resources/grit/webui_resources.h" 16 #include "ui/resources/grit/webui_resources.h"
16 17
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) 18 WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
26 : content::WebUIController(web_ui) { 19 : content::WebUIController(web_ui) {
27 // TODO(tmartino): Create WelcomeHandler, and add here. 20 web_ui->AddMessageHandler(new WelcomeHandler(web_ui));
28 21
29 content::WebUIDataSource* html_source = 22 content::WebUIDataSource* html_source =
30 content::WebUIDataSource::Create(url.host()); 23 content::WebUIDataSource::Create(url.host());
31 24
32 // Check URL for variations. 25 // Check URL for variations.
33 bool is_everywhere_variant = url.path() == kEverywhereVariantPath; 26 std::string value;
27 bool is_everywhere_variant =
28 (net::GetValueForKeyInQuery(url, "variant", &value) &&
29 value == "everywhere");
34 30
35 int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN 31 int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN
36 : IDS_WELCOME_HEADER; 32 : IDS_WELCOME_HEADER;
37 html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id)); 33 html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id));
38 34
39 // The subheader describes the browser as being "by Google", so we only show 35 // 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. 36 // it in the "Welcome to Chrome" variant, and only on branded builds.
41 #if defined(GOOGLE_CHROME_BUILD) 37 #if defined(GOOGLE_CHROME_BUILD)
42 base::string16 subheader = 38 base::string16 subheader =
43 is_everywhere_variant ? base::string16() 39 is_everywhere_variant ? base::string16()
(...skipping 10 matching lines...) Expand all
54 html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128); 50 html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
55 html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256); 51 html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256);
56 html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO); 52 html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO);
57 html_source->SetDefaultResource(IDR_WELCOME_HTML); 53 html_source->SetDefaultResource(IDR_WELCOME_HTML);
58 54
59 Profile* profile = Profile::FromWebUI(web_ui); 55 Profile* profile = Profile::FromWebUI(web_ui);
60 content::WebUIDataSource::Add(profile, html_source); 56 content::WebUIDataSource::Add(profile, html_source);
61 } 57 }
62 58
63 WelcomeUI::~WelcomeUI() {} 59 WelcomeUI::~WelcomeUI() {}
OLDNEW
« chrome/browser/ui/webui/welcome_handler.cc ('K') | « chrome/browser/ui/webui/welcome_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698