OLD | NEW |
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 "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/startup/startup_features.h" | 13 #include "chrome/browser/ui/startup/startup_features.h" |
13 #include "chrome/browser/ui/webui/welcome_win10_handler.h" | 14 #include "chrome/browser/ui/webui/welcome_win10_handler.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
16 #include "chrome/grit/browser_resources.h" | 17 #include "chrome/grit/browser_resources.h" |
17 #include "chrome/grit/chrome_unscaled_resources.h" | 18 #include "chrome/grit/chrome_unscaled_resources.h" |
18 #include "chrome/grit/chromium_strings.h" | 19 #include "chrome/grit/chromium_strings.h" |
19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
20 #include "chrome/grit/theme_resources.h" | 21 #include "chrome/grit/theme_resources.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 } // namespace | 89 } // namespace |
89 | 90 |
90 WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url) | 91 WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url) |
91 : content::WebUIController(web_ui) { | 92 : content::WebUIController(web_ui) { |
92 static const char kCssFilePath[] = "welcome.css"; | 93 static const char kCssFilePath[] = "welcome.css"; |
93 static const char kJsFilePath[] = "welcome.js"; | 94 static const char kJsFilePath[] = "welcome.js"; |
94 static const char kDefaultFilePath[] = "default.webp"; | 95 static const char kDefaultFilePath[] = "default.webp"; |
95 static const char kPinFilePath[] = "pin.webp"; | 96 static const char kPinFilePath[] = "pin.webp"; |
96 | 97 |
97 Profile* profile = Profile::FromWebUI(web_ui); | 98 // Remember that the Win10 promo page has been shown. |
98 | 99 g_browser_process->local_state()->SetBoolean(prefs::kHasSeenWin10PromoPage, |
99 // Store that this profile has been shown the Win10 promo page. | 100 true); |
100 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWin10PromoPage, true); | |
101 | 101 |
102 // Determine which variation to show. | 102 // Determine which variation to show. |
103 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster"); | 103 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster"); |
104 bool is_inline_style = ShouldShowInlineStyleVariant(url); | 104 bool is_inline_style = ShouldShowInlineStyleVariant(url); |
105 | 105 |
106 web_ui->AddMessageHandler( | 106 web_ui->AddMessageHandler( |
107 base::MakeUnique<WelcomeWin10Handler>(is_inline_style)); | 107 base::MakeUnique<WelcomeWin10Handler>(is_inline_style)); |
108 | 108 |
109 content::WebUIDataSource* html_source = | 109 content::WebUIDataSource* html_source = |
110 content::WebUIDataSource::Create(url.host()); | 110 content::WebUIDataSource::Create(url.host()); |
(...skipping 14 matching lines...) Expand all Loading... |
125 html_source->AddResourcePath(kDefaultFilePath, | 125 html_source->AddResourcePath(kDefaultFilePath, |
126 IDR_WELCOME_WIN10_DEFAULT_LARGE_WEBP); | 126 IDR_WELCOME_WIN10_DEFAULT_LARGE_WEBP); |
127 html_source->AddResourcePath(kPinFilePath, | 127 html_source->AddResourcePath(kPinFilePath, |
128 IDR_WELCOME_WIN10_PIN_LARGE_WEBP); | 128 IDR_WELCOME_WIN10_PIN_LARGE_WEBP); |
129 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML); | 129 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML); |
130 } | 130 } |
131 | 131 |
132 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_64); | 132 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_64); |
133 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_128); | 133 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_128); |
134 | 134 |
135 content::WebUIDataSource::Add(profile, html_source); | 135 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); |
136 } | 136 } |
137 | 137 |
138 WelcomeWin10UI::~WelcomeWin10UI() = default; | 138 WelcomeWin10UI::~WelcomeWin10UI() = default; |
OLD | NEW |