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

Unified Diff: chrome/browser/ui/webui/welcome_ui.cc

Issue 2252063002: Adding client code for new desktop First Run Experience. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing build issues after rebasing Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/welcome_ui.cc
diff --git a/chrome/browser/ui/webui/welcome_ui.cc b/chrome/browser/ui/webui/welcome_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..079002b974a21e63fde052e3b2409ac4a0d5afdf
--- /dev/null
+++ b/chrome/browser/ui/webui/welcome_ui.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 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_ui.h"
+
+#include "chrome/browser/profiles/profile.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 "content/public/browser/web_ui_data_source.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/resources/grit/webui_resources.h"
+
+// A URL ending in /1 indicates that we should modify the page to use the
+// "Take Chrome Everywhere" text.
+const char* kEverywhereVariantPath = "/1";
+
+WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
+ : content::WebUIController(web_ui) {
+ // TODO(tmartino): Create WelcomeHandler.
+ // web_ui->AddMessageHandler(new WelcomeHandler());
michaelpg 2016/09/06 22:21:57 don't leave commented-out code in (even with TODO.
tmartino 2016/09/07 23:06:42 Done
+
+ content::WebUIDataSource* html_source =
+ content::WebUIDataSource::Create(url.host());
+
+ // Check URL for variations.
+ bool is_everywhere_variant = url.path().compare(kEverywhereVariantPath) == 0;
+
+ int header_id = is_everywhere_variant ? IDS_WELCOME_UI_EVERYWHERE_HEADER
+ : IDS_WELCOME_UI_WELCOME_HEADER;
+ html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id));
+
+ // The subheader describes the browser as being "by Google", so we only show
+ // it in the "Welcome to Chrome" variant, and only on branded builds.
+ base::string16 subheader = base::string16();
michaelpg 2016/09/06 22:21:56 this is equivalent to base::string16 subheade
tmartino 2016/09/07 23:06:43 N/A anymore, but yes.
+
+#if defined(GOOGLE_CHROME_BUILD)
+ if (!is_everywhere_variant)
+ subheader = l10n_util::GetStringUTF16(IDS_WELCOME_UI_SUBHEADER);
+#endif
+ html_source->AddString("subheaderText", subheader);
michaelpg 2016/09/06 22:21:57 if you can limit the use of subheaderText to Googl
tmartino 2016/09/07 23:06:43 Done
+
+ html_source->AddLocalizedString("descriptionText",
+ IDS_WELCOME_UI_DESCRIPTION);
+ html_source->AddLocalizedString("acceptText", IDS_WELCOME_UI_ACCEPT_BUTTON);
+ html_source->AddLocalizedString("declineText", IDS_WELCOME_UI_DECLINE_BUTTON);
+
+ html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS);
+ html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
+ html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256);
+ html_source->AddResourcePath("watermark.svg", IDR_WEBUI_IMAGES_GOOGLE_LOGO);
+ html_source->SetDefaultResource(IDR_WELCOME_HTML);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, html_source);
+}
+
+WelcomeUI::~WelcomeUI() {}

Powered by Google App Engine
This is Rietveld 408576698