| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/welcome_ui_android.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/strings/string16.h" | |
| 10 #include "base/strings/stringprintf.h" | |
| 11 #include "base/strings/utf_string_conversions.h" | |
| 12 #include "chrome/browser/android/accessibility_util.h" | |
| 13 #include "chrome/browser/android/tab_android.h" | |
| 14 #include "chrome/browser/browser_process.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | |
| 16 #include "chrome/browser/ui/webui/welcome_handler_android.h" | |
| 17 #include "chrome/common/url_constants.h" | |
| 18 #include "chrome/grit/chromium_strings.h" | |
| 19 #include "chrome/grit/generated_resources.h" | |
| 20 #include "chrome/grit/google_chrome_strings.h" | |
| 21 #include "content/public/browser/web_ui.h" | |
| 22 #include "content/public/browser/web_ui_data_source.h" | |
| 23 #include "grit/browser_resources.h" | |
| 24 #include "ui/base/l10n/l10n_util.h" | |
| 25 | |
| 26 const char kProductTourBaseURL[] = | |
| 27 "http://www.google.com/intl/%s/chrome/browser/mobile/tour/android.html"; | |
| 28 | |
| 29 const char kPrivacyNoticeBaseURL[] = | |
| 30 "http://www.google.com/chrome/intl/%s/privacy.html"; | |
| 31 | |
| 32 WelcomeUI::WelcomeUI(content::WebUI* web_ui) | |
| 33 : content::WebUIController(web_ui) { | |
| 34 // Set up the chrome://welcome source. | |
| 35 content::WebUIDataSource* html_source = | |
| 36 content::WebUIDataSource::Create(chrome::kChromeUIWelcomeHost); | |
| 37 | |
| 38 // Localized strings. | |
| 39 html_source->AddLocalizedString("title", | |
| 40 IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE); | |
| 41 html_source->AddLocalizedString("takeATour", IDS_FIRSTRUN_TAKE_TOUR); | |
| 42 html_source->AddLocalizedString("firstRunSignedInTitle", | |
| 43 IDS_FIRSTRUN_SIGNED_IN_TITLE); | |
| 44 html_source->AddLocalizedString("firstRunSignedInDescription", | |
| 45 IDS_FIRSTRUN_SIGNED_IN_DESCRIPTION); | |
| 46 html_source->AddLocalizedString("settings", IDS_FIRSTRUN_SETTINGS_LINK); | |
| 47 | |
| 48 std::string locale = g_browser_process->GetApplicationLocale(); | |
| 49 std::string product_tour_url = base::StringPrintf( | |
| 50 kProductTourBaseURL, locale.c_str()); | |
| 51 | |
| 52 if (chrome::android::AccessibilityUtil::IsAccessibilityEnabled()) | |
| 53 product_tour_url += "?talkback"; | |
| 54 | |
| 55 html_source->AddString("productTourUrl", product_tour_url); | |
| 56 | |
| 57 TabAndroid* tab = TabAndroid::FromWebContents(web_ui->GetWebContents()); | |
| 58 bool tos_visible = tab && tab->ShouldWelcomePageLinkToTermsOfService(); | |
| 59 html_source->AddBoolean("tosVisible", tos_visible); | |
| 60 | |
| 61 base::string16 tos_html; | |
| 62 if (tos_visible) { | |
| 63 std::string privacy_notice_url = | |
| 64 base::StringPrintf(kPrivacyNoticeBaseURL, locale.c_str()); | |
| 65 tos_html = l10n_util::GetStringFUTF16( | |
| 66 IDS_FIRSTRUN_TOS_EXPLANATION, base::UTF8ToUTF16(privacy_notice_url)); | |
| 67 } | |
| 68 html_source->AddString("tosHtml", tos_html); | |
| 69 | |
| 70 // Add required resources. | |
| 71 html_source->SetJsonPath("strings.js"); | |
| 72 html_source->SetDefaultResource(IDR_ABOUT_WELCOME_HTML); | |
| 73 | |
| 74 Profile* profile = Profile::FromWebUI(web_ui); | |
| 75 content::WebUIDataSource::Add(profile, html_source); | |
| 76 | |
| 77 // Add message handlers. | |
| 78 web_ui->AddMessageHandler(new WelcomeHandler()); | |
| 79 } | |
| 80 | |
| 81 WelcomeUI::~WelcomeUI() { | |
| 82 } | |
| OLD | NEW |