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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc

Issue 277083004: Added browser and OS credits link to EULA page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/chromeos/login/eula_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/login/help_app_launcher.h" 10 #include "chrome/browser/chromeos/login/help_app_launcher.h"
11 #include "chrome/browser/chromeos/login/helper.h"
12 #include "chrome/browser/chromeos/login/login_web_dialog.h"
10 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" 13 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
11 #include "chrome/browser/chromeos/login/webui_login_display.h" 14 #include "chrome/browser/chromeos/login/webui_login_display.h"
12 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 15 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
13 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/public/browser/web_contents.h"
14 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
15 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
16 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/locale_settings.h"
22 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 #include "url/gurl.h"
18 25
19 namespace { 26 namespace {
20 27
21 const char kJsScreenPath[] = "login.EulaScreen"; 28 const char kJsScreenPath[] = "login.EulaScreen";
22 29
30 // Helper class to tweak display details of credits pages in the context
31 // of OOBE/EULA step.
32 class CreditsWebDialog : public chromeos::LoginWebDialog {
33 public:
34 CreditsWebDialog(Profile* profile,
35 gfx::NativeWindow parent_window,
36 int title_id,
37 const GURL& url)
38 : chromeos::LoginWebDialog(profile, NULL, parent_window,
39 l10n_util::GetStringUTF16(title_id),
40 url,
41 chromeos::LoginWebDialog::STYLE_BUBBLE) {
42 }
43
44 virtual void OnLoadingStateChanged(content::WebContents* source) OVERRIDE {
45 chromeos::LoginWebDialog::OnLoadingStateChanged(source);
46 // Remove visual elements that we can handle in EULA page.
47 bool is_loading = source->IsLoading();
48 if (!is_loading && source->GetWebUI()) {
49 source->GetWebUI()->CallJavascriptFunction(
50 "(function HideElements() {\n"
xiyuan 2014/05/13 00:28:41 nit: "\n" is not needed here and other places.
xiyuan 2014/05/13 00:28:41 nit: HideElement -> hideElement. Actually, we don
zel 2014/05/13 20:19:23 Done.
51 " function injectStyles(rule) {\n"
52 " var css = rule,\n"
xiyuan 2014/05/13 00:28:41 , -> ;
zel 2014/05/13 20:19:23 Done.
53 " head = document.head ||\n"
xiyuan 2014/05/13 00:28:41 nit: var head = ...
zel 2014/05/13 20:19:23 Done.
54 " document.getElementsByTagName('head')[0],\n"
55 " style = document.createElement('style');\n"
xiyuan 2014/05/13 00:28:41 nit: var style = ...
zel 2014/05/13 20:19:23 Done.
56 " style.type = 'text/css';\n"
57 " if (style.styleSheet){\n"
58 " style.styleSheet.cssText = css;\n"
59 " } else {\n"
60 " style.appendChild(document.createTextNode(css));\n"
61 " }\n"
62 " head.appendChild(style);\n"
63 " }\n"
64 " injectStyles('#print-link { display: none; }');\n"
65 " injectStyles('.homepage { display: none; }');\n"
xiyuan 2014/05/13 00:28:41 Since we are modifying about_os_credits.html to ad
zel 2014/05/13 20:19:23 Done.
66 "})");
67 }
68 }
69
70 private:
71 DISALLOW_COPY_AND_ASSIGN(CreditsWebDialog);
72 };
73
74
75 void ShowCreditsDialog(Profile* profile,
76 gfx::NativeWindow parent_window,
77 int title_id,
78 const GURL& credits_url) {
79 CreditsWebDialog* dialog = new CreditsWebDialog(profile,
80 parent_window,
81 title_id,
82 credits_url);
83 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
84 dialog->SetDialogSize(l10n_util::GetLocalizedContentsWidthInPixels(
85 IDS_CREDITS_APP_DIALOG_WIDTH_PIXELS),
86 l10n_util::GetLocalizedContentsWidthInPixels(
87 IDS_CREDITS_APP_DIALOG_HEIGHT_PIXELS));
88 dialog->Show();
89 // The dialog object will be deleted on dialog close.
90 }
91
23 } // namespace 92 } // namespace
24 93
25 namespace chromeos { 94 namespace chromeos {
26 95
27 EulaScreenHandler::EulaScreenHandler(CoreOobeActor* core_oobe_actor) 96 EulaScreenHandler::EulaScreenHandler(CoreOobeActor* core_oobe_actor)
28 : BaseScreenHandler(kJsScreenPath), 97 : BaseScreenHandler(kJsScreenPath),
29 delegate_(NULL), 98 delegate_(NULL),
30 core_oobe_actor_(core_oobe_actor), 99 core_oobe_actor_(core_oobe_actor),
31 show_on_init_(false) { 100 show_on_init_(false) {
32 } 101 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING); 144 builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING);
76 #if defined(ENABLE_RLZ) 145 #if defined(ENABLE_RLZ)
77 builder->AddF("eulaRlzDesc", 146 builder->AddF("eulaRlzDesc",
78 IDS_EULA_RLZ_DESCRIPTION, 147 IDS_EULA_RLZ_DESCRIPTION,
79 IDS_SHORT_PRODUCT_NAME, 148 IDS_SHORT_PRODUCT_NAME,
80 IDS_PRODUCT_NAME); 149 IDS_PRODUCT_NAME);
81 builder->AddF("eulaRlzEnable", 150 builder->AddF("eulaRlzEnable",
82 IDS_EULA_RLZ_ENABLE, 151 IDS_EULA_RLZ_ENABLE,
83 IDS_SHORT_PRODUCT_OS_NAME); 152 IDS_SHORT_PRODUCT_OS_NAME);
84 #endif 153 #endif
154
155
xiyuan 2014/05/13 00:28:41 nit: keep only one empty line.
zel 2014/05/13 20:19:23 Done.
156 builder->Add("chromeCreditsLink", IDS_ABOUT_VERSION_LICENSE_EULA);
157 builder->Add("chromeosCreditsLink", IDS_ABOUT_CROS_VERSION_LICENSE_EULA);
85 } 158 }
86 159
87 void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) { 160 void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
88 #if defined(ENABLE_RLZ) 161 #if defined(ENABLE_RLZ)
89 dict->SetString("rlzEnabled", "enabled"); 162 dict->SetString("rlzEnabled", "enabled");
90 #else 163 #else
91 dict->SetString("rlzEnabled", "disabled"); 164 dict->SetString("rlzEnabled", "disabled");
92 #endif 165 #endif
93 } 166 }
94 167
(...skipping 10 matching lines...) Expand all
105 178
106 if (show_on_init_) { 179 if (show_on_init_) {
107 Show(); 180 Show();
108 show_on_init_ = false; 181 show_on_init_ = false;
109 } 182 }
110 } 183 }
111 184
112 void EulaScreenHandler::RegisterMessages() { 185 void EulaScreenHandler::RegisterMessages() {
113 AddCallback("eulaOnExit", &EulaScreenHandler::HandleOnExit); 186 AddCallback("eulaOnExit", &EulaScreenHandler::HandleOnExit);
114 AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore); 187 AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore);
188 AddCallback("eulaOnChromeOSCredits",
189 &EulaScreenHandler::HandleOnChromeOSCredits);
190 AddCallback("eulaOnChromeCredits",
191 &EulaScreenHandler::HandleOnChromeCredits);
192 AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore);
115 AddCallback("eulaOnInstallationSettingsPopupOpened", 193 AddCallback("eulaOnInstallationSettingsPopupOpened",
116 &EulaScreenHandler::HandleOnInstallationSettingsPopupOpened); 194 &EulaScreenHandler::HandleOnInstallationSettingsPopupOpened);
117 } 195 }
118 196
119 void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) { 197 void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
120 core_oobe_actor_->SetTpmPassword(tpm_password); 198 core_oobe_actor_->SetTpmPassword(tpm_password);
121 } 199 }
122 200
123 void EulaScreenHandler::HandleOnExit(bool accepted, bool usage_stats_enabled) { 201 void EulaScreenHandler::HandleOnExit(bool accepted, bool usage_stats_enabled) {
124 if (delegate_) 202 if (delegate_)
125 delegate_->OnExit(accepted, usage_stats_enabled); 203 delegate_->OnExit(accepted, usage_stats_enabled);
126 } 204 }
127 205
128 void EulaScreenHandler::HandleOnLearnMore() { 206 void EulaScreenHandler::HandleOnLearnMore() {
129 if (!help_app_.get()) 207 if (!help_app_.get())
130 help_app_ = new HelpAppLauncher(GetNativeWindow()); 208 help_app_ = new HelpAppLauncher(GetNativeWindow());
131 help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE); 209 help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE);
132 } 210 }
133 211
212 void EulaScreenHandler::HandleOnChromeOSCredits() {
213 ShowCreditsDialog(
214 Profile::FromBrowserContext(
215 web_ui()->GetWebContents()->GetBrowserContext()),
216 GetNativeWindow(),
217 IDS_ABOUT_CROS_VERSION_LICENSE_EULA,
218 GURL(chrome::kChromeUIOSCreditsURL));
219 }
220
221 void EulaScreenHandler::HandleOnChromeCredits() {
222 ShowCreditsDialog(
223 Profile::FromBrowserContext(
224 web_ui()->GetWebContents()->GetBrowserContext()),
225 GetNativeWindow(),
226 IDS_ABOUT_VERSION_LICENSE_EULA,
227 GURL(chrome::kChromeUICreditsURL));
228 }
229
134 void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened() { 230 void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened() {
135 if (delegate_) 231 if (delegate_)
136 delegate_->InitiatePasswordFetch(); 232 delegate_->InitiatePasswordFetch();
137 } 233 }
138 234
139 } // namespace chromeos 235 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698