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

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

Issue 2578843002: Implement Win 10 onboarding content logic (Closed)
Patch Set: Fixed comments Created 4 years 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
« no previous file with comments | « chrome/browser/ui/startup/startup_tab_provider_unittest.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_win10_ui.h" 5 #include "chrome/browser/ui/webui/welcome_win10_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/startup/startup_features.h" 11 #include "chrome/browser/ui/startup/startup_features.h"
12 #include "chrome/browser/ui/webui/welcome_win10_handler.h" 12 #include "chrome/browser/ui/webui/welcome_win10_handler.h"
13 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/browser_resources.h" 15 #include "chrome/grit/browser_resources.h"
15 #include "chrome/grit/chrome_unscaled_resources.h" 16 #include "chrome/grit/chrome_unscaled_resources.h"
16 #include "chrome/grit/chromium_strings.h" 17 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "chrome/grit/theme_resources.h" 19 #include "chrome/grit/theme_resources.h"
20 #include "components/prefs/pref_service.h"
19 #include "content/public/browser/web_ui_data_source.h" 21 #include "content/public/browser/web_ui_data_source.h"
20 #include "net/base/url_util.h" 22 #include "net/base/url_util.h"
21 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
22 #include "url/gurl.h" 24 #include "url/gurl.h"
23 25
24 namespace { 26 namespace {
25 27
26 // Helper function to check the presence of a key/value inside the query in the 28 // Helper function to check the presence of a key/value inside the query in the
27 // |url|. 29 // |url|.
28 bool UrlContainsKeyValueInQuery(const GURL& url, 30 bool UrlContainsKeyValueInQuery(const GURL& url,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 IDS_WIN10_WELCOME_PIN_LABEL); 84 IDS_WIN10_WELCOME_PIN_LABEL);
83 } 85 }
84 86
85 } // namespace 87 } // namespace
86 88
87 WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url) 89 WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url)
88 : content::WebUIController(web_ui) { 90 : content::WebUIController(web_ui) {
89 static const char kCssFilePath[] = "welcome.css"; 91 static const char kCssFilePath[] = "welcome.css";
90 static const char kJsFilePath[] = "welcome.js"; 92 static const char kJsFilePath[] = "welcome.js";
91 93
94 Profile* profile = Profile::FromWebUI(web_ui);
95
96 // Store that this profile has been shown the Win10 promo page.
97 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWin10PromoPage, true);
98
92 // Determine which variation to show. 99 // Determine which variation to show.
93 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster"); 100 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster");
94 bool is_inline_style = ShouldShowInlineStyleVariant(url); 101 bool is_inline_style = ShouldShowInlineStyleVariant(url);
95 102
96 web_ui->AddMessageHandler(new WelcomeWin10Handler(is_inline_style)); 103 web_ui->AddMessageHandler(new WelcomeWin10Handler(is_inline_style));
97 104
98 content::WebUIDataSource* html_source = 105 content::WebUIDataSource* html_source =
99 content::WebUIDataSource::Create(url.host()); 106 content::WebUIDataSource::Create(url.host());
100 107
101 AddLocalizedStrings(html_source, is_first_run); 108 AddLocalizedStrings(html_source, is_first_run);
102 109
103 if (is_inline_style) { 110 if (is_inline_style) {
104 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_INLINE_CSS); 111 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_INLINE_CSS);
105 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_INLINE_JS); 112 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_INLINE_JS);
106 html_source->SetDefaultResource(IDR_WELCOME_WIN10_INLINE_HTML); 113 html_source->SetDefaultResource(IDR_WELCOME_WIN10_INLINE_HTML);
107 } else { 114 } else {
108 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_SECTIONED_CSS); 115 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_SECTIONED_CSS);
109 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_SECTIONED_JS); 116 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_SECTIONED_JS);
110 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML); 117 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML);
111 } 118 }
112 119
113 // Logo images of all scales. 120 // Logo images of all scales.
114 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_32); 121 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_32);
115 html_source->AddResourcePath("logo-small2x.png", IDR_PRODUCT_LOGO_64); 122 html_source->AddResourcePath("logo-small2x.png", IDR_PRODUCT_LOGO_64);
116 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_64); 123 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_64);
117 html_source->AddResourcePath("logo-large2x.png", IDR_PRODUCT_LOGO_128); 124 html_source->AddResourcePath("logo-large2x.png", IDR_PRODUCT_LOGO_128);
118 125
119 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); 126 content::WebUIDataSource::Add(profile, html_source);
120 } 127 }
121 128
122 WelcomeWin10UI::~WelcomeWin10UI() = default; 129 WelcomeWin10UI::~WelcomeWin10UI() = default;
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_tab_provider_unittest.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698