Chromium Code Reviews| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 IDS_WIN10_WELCOME_PIN_LABEL); | 86 IDS_WIN10_WELCOME_PIN_LABEL); |
| 86 } | 87 } |
| 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 | 95 |
| 95 Profile* profile = Profile::FromWebUI(web_ui); | 96 // Remember that the Win10 promo page has been shown. |
| 96 | 97 g_browser_process->local_state()->SetBoolean(prefs::kHasSeenWin10PromoPage, |
| 97 // Store that this profile has been shown the Win10 promo page. | 98 true); |
| 98 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWin10PromoPage, true); | |
| 99 | 99 |
| 100 // Determine which variation to show. | 100 // Determine which variation to show. |
| 101 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster"); | 101 bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster"); |
| 102 bool is_inline_style = ShouldShowInlineStyleVariant(url); | 102 bool is_inline_style = ShouldShowInlineStyleVariant(url); |
| 103 | 103 |
| 104 web_ui->AddMessageHandler( | 104 web_ui->AddMessageHandler( |
| 105 base::MakeUnique<WelcomeWin10Handler>(is_inline_style)); | 105 base::MakeUnique<WelcomeWin10Handler>(is_inline_style)); |
| 106 | 106 |
| 107 content::WebUIDataSource* html_source = | 107 content::WebUIDataSource* html_source = |
| 108 content::WebUIDataSource::Create(url.host()); | 108 content::WebUIDataSource::Create(url.host()); |
| 109 | 109 |
| 110 AddLocalizedStrings(html_source, is_first_run); | 110 AddLocalizedStrings(html_source, is_first_run); |
| 111 | 111 |
| 112 if (is_inline_style) { | 112 if (is_inline_style) { |
| 113 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_INLINE_CSS); | 113 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_INLINE_CSS); |
| 114 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_INLINE_JS); | 114 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_INLINE_JS); |
| 115 html_source->SetDefaultResource(IDR_WELCOME_WIN10_INLINE_HTML); | 115 html_source->SetDefaultResource(IDR_WELCOME_WIN10_INLINE_HTML); |
| 116 } else { | 116 } else { |
| 117 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_SECTIONED_CSS); | 117 html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_SECTIONED_CSS); |
| 118 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_SECTIONED_JS); | 118 html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_SECTIONED_JS); |
| 119 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML); | 119 html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML); |
| 120 } | 120 } |
| 121 | 121 |
| 122 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_64); | 122 html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_64); |
| 123 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_128); | 123 html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_128); |
| 124 | 124 |
| 125 Profile* profile = Profile::FromWebUI(web_ui); | |
|
Peter Kasting
2017/01/26 21:14:32
Nit: Or just inline this
Patrick Monette
2017/01/26 22:09:13
Done.
| |
| 125 content::WebUIDataSource::Add(profile, html_source); | 126 content::WebUIDataSource::Add(profile, html_source); |
| 126 } | 127 } |
| 127 | 128 |
| 128 WelcomeWin10UI::~WelcomeWin10UI() = default; | 129 WelcomeWin10UI::~WelcomeWin10UI() = default; |
| OLD | NEW |