| Index: chrome/browser/ui/webui/welcome_win10_ui.cc
|
| diff --git a/chrome/browser/ui/webui/welcome_win10_ui.cc b/chrome/browser/ui/webui/welcome_win10_ui.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bf8c85032098fe9f57f383b9b9c010b4eb4ce22c
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/welcome_win10_ui.cc
|
| @@ -0,0 +1,108 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/webui/welcome_win10_ui.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/webui/welcome_win10_handler.h"
|
| +#include "chrome/common/url_constants.h"
|
| +#include "chrome/grit/browser_resources.h"
|
| +#include "chrome/grit/chrome_unscaled_resources.h"
|
| +#include "chrome/grit/chromium_strings.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| +#include "chrome/grit/theme_resources.h"
|
| +#include "content/public/browser/web_ui_data_source.h"
|
| +#include "net/base/url_util.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace {
|
| +
|
| +// Helper function to check the presence of a key/value inside the query in the
|
| +// |url|.
|
| +bool UrlContainsKeyValueInQuery(const GURL& url,
|
| + const std::string& key,
|
| + const std::string& expected_value) {
|
| + std::string value;
|
| + return net::GetValueForKeyInQuery(url, key, &value) &&
|
| + value == expected_value;
|
| +}
|
| +
|
| +// Adds all the needed localized strings to |html_source|, depending on
|
| +// the value of |is_first_run|.
|
| +void AddLocalizedStrings(content::WebUIDataSource* html_source,
|
| + bool is_first_run) {
|
| + // Only show the "Welcome to Chrome" text on first run.
|
| + int welcome_header_id = is_first_run
|
| + ? IDS_WIN10_WELCOME_HEADER
|
| + : IDS_WIN10_WELCOME_HEADER_AFTER_FIRST_RUN;
|
| + html_source->AddLocalizedString("headerText", welcome_header_id);
|
| +
|
| + html_source->AddLocalizedString("continueText", IDS_WIN10_WELCOME_CONTINUE);
|
| +
|
| + // Default browser strings.
|
| + html_source->AddLocalizedString("defaultBrowserSubheaderText",
|
| + IDS_WIN10_WELCOME_MAKE_DEFAULT_SUBHEADING);
|
| + html_source->AddLocalizedString("openSettingsText",
|
| + IDS_WIN10_WELCOME_OPEN_SETTINGS);
|
| + html_source->AddLocalizedString("clickEdgeText",
|
| + IDS_WIN10_WELCOME_CLICK_EDGE);
|
| + html_source->AddLocalizedString("clickSelectChrome",
|
| + IDS_WIN10_WELCOME_SELECT);
|
| + html_source->AddLocalizedString("webBrowserLabel",
|
| + IDS_WIN10_WELCOME_BROWSER_LABEL);
|
| + html_source->AddLocalizedString("microsoftEdgeLabel",
|
| + IDS_WIN10_WELCOME_EDGE_LABEL);
|
| +
|
| + // Taskbar pin strings.
|
| + html_source->AddLocalizedString("pinSubheaderText",
|
| + IDS_WIN10_WELCOME_PIN_SUBHEADING);
|
| + html_source->AddLocalizedString("rightClickText",
|
| + IDS_WIN10_WELCOME_RIGHT_CLICK_TASKBAR);
|
| + html_source->AddLocalizedString("pinInstructionText",
|
| + IDS_WIN10_WELCOME_PIN_INSTRUCTION);
|
| + html_source->AddLocalizedString("pinToTaskbarLabel",
|
| + IDS_WIN10_WELCOME_PIN_LABEL);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url)
|
| + : content::WebUIController(web_ui) {
|
| + static const char kCssFilePath[] = "welcome.css";
|
| + static const char kJsFilePath[] = "welcome.js";
|
| +
|
| + web_ui->AddMessageHandler(new WelcomeWin10Handler());
|
| +
|
| + content::WebUIDataSource* html_source =
|
| + content::WebUIDataSource::Create(url.host());
|
| +
|
| + // Determine which variation to show.
|
| + bool is_first_run = !UrlContainsKeyValueInQuery(url, "text", "faster");
|
| + bool is_inline_style = UrlContainsKeyValueInQuery(url, "style", "inline");
|
| +
|
| + AddLocalizedStrings(html_source, is_first_run);
|
| +
|
| + if (is_inline_style) {
|
| + html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_INLINE_CSS);
|
| + html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_INLINE_JS);
|
| + html_source->SetDefaultResource(IDR_WELCOME_WIN10_INLINE_HTML);
|
| + } else {
|
| + html_source->AddResourcePath(kCssFilePath, IDR_WELCOME_WIN10_SECTIONED_CSS);
|
| + html_source->AddResourcePath(kJsFilePath, IDR_WELCOME_WIN10_SECTIONED_JS);
|
| + html_source->SetDefaultResource(IDR_WELCOME_WIN10_SECTIONED_HTML);
|
| + }
|
| +
|
| + // Logo images of all scales.
|
| + html_source->AddResourcePath("logo-small.png", IDR_PRODUCT_LOGO_32);
|
| + html_source->AddResourcePath("logo-small2x.png", IDR_PRODUCT_LOGO_64);
|
| + html_source->AddResourcePath("logo-large.png", IDR_PRODUCT_LOGO_64);
|
| + html_source->AddResourcePath("logo-large2x.png", IDR_PRODUCT_LOGO_128);
|
| +
|
| + content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
|
| +}
|
| +
|
| +WelcomeWin10UI::~WelcomeWin10UI() = default;
|
|
|