OLD | NEW |
---|---|
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/help/help_handler.h" | 5 #include "chrome/browser/ui/webui/help/help_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
18 #include "chrome/browser/policy/browser_policy_connector.h" | 18 #include "chrome/browser/policy/browser_policy_connector.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/chrome_pages.h" | 22 #include "chrome/browser/ui/chrome_pages.h" |
23 #include "chrome/browser/ui/send_feedback_experiment.h" | 23 #include "chrome/browser/ui/send_feedback_experiment.h" |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/pref_names.h" | |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
30 #include "content/public/browser/web_ui_data_source.h" | 31 #include "content/public/browser/web_ui_data_source.h" |
31 #include "content/public/common/content_client.h" | 32 #include "content/public/common/content_client.h" |
32 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
34 #include "grit/google_chrome_strings.h" | 35 #include "grit/google_chrome_strings.h" |
35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
36 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
37 #include "v8/include/v8.h" | 38 #include "v8/include/v8.h" |
38 #include "webkit/common/user_agent/user_agent_util.h" | 39 #include "webkit/common/user_agent/user_agent_util.h" |
39 | 40 |
40 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
41 #include "base/files/file_util_proxy.h" | 42 #include "base/files/file_util_proxy.h" |
42 #include "base/i18n/time_formatting.h" | 43 #include "base/i18n/time_formatting.h" |
43 #include "base/prefs/pref_service.h" | 44 #include "base/prefs/pref_service.h" |
44 #include "base/sys_info.h" | 45 #include "base/sys_info.h" |
45 #include "chrome/browser/chromeos/login/user_manager.h" | 46 #include "chrome/browser/chromeos/login/user_manager.h" |
46 #include "chrome/browser/chromeos/settings/cros_settings.h" | 47 #include "chrome/browser/chromeos/settings/cros_settings.h" |
47 #include "chrome/browser/profiles/profile.h" | 48 #include "chrome/browser/profiles/profile.h" |
48 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 49 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
50 #include "chromeos/chromeos_switches.h" | |
51 #include "chromeos/dbus/dbus_thread_manager.h" | |
52 #include "chromeos/dbus/power_manager_client.h" | |
49 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
50 #endif | 54 #endif |
51 | 55 |
52 using base::ListValue; | 56 using base::ListValue; |
53 using content::BrowserThread; | 57 using content::BrowserThread; |
54 | 58 |
55 namespace { | 59 namespace { |
56 | 60 |
57 const char kResourceReportIssue[] = "reportAnIssue"; | 61 const char kResourceReportIssue[] = "reportAnIssue"; |
58 | 62 |
(...skipping 23 matching lines...) Expand all Loading... | |
82 // connect to a network of one of the allowed types. | 86 // connect to a network of one of the allowed types. |
83 string16 GetAllowedConnectionTypesMessage() { | 87 string16 GetAllowedConnectionTypesMessage() { |
84 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { | 88 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { |
85 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); | 89 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); |
86 } else { | 90 } else { |
87 return l10n_util::GetStringUTF16( | 91 return l10n_util::GetStringUTF16( |
88 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); | 92 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); |
89 } | 93 } |
90 } | 94 } |
91 | 95 |
92 bool CanChangeReleaseChannel() { | 96 // Returns true if the device is enterprise managed, false otherwise. |
93 // On non managed machines we have local owner who is the only one to change | 97 bool IsEnterpriseManaged() { |
94 // anything. | 98 return g_browser_process->browser_policy_connector()->IsEnterpriseManaged(); |
95 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) | 99 } |
96 return true; | 100 |
101 // Returns true if current user can change channel, false otherwise. | |
102 bool CanChangeChannel() { | |
103 bool value = false; | |
104 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated, | |
105 &value); | |
106 | |
97 // On a managed machine we delegate this setting to the users of the same | 107 // On a managed machine we delegate this setting to the users of the same |
98 // domain only if the policy value is "domain". | 108 // domain only if the policy value is "domain". |
99 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { | 109 if (IsEnterpriseManaged()) { |
100 bool value = false; | 110 if (!value) |
101 if (!chromeos::CrosSettings::Get()->GetBoolean( | |
102 chromeos::kReleaseChannelDelegated, &value) || !value) | |
103 return false; | 111 return false; |
104 // Get the currently logged in user and strip the domain part only. | 112 // Get the currently logged in user and strip the domain part only. |
105 std::string domain = ""; | 113 std::string domain = ""; |
106 std::string user = chromeos::UserManager::Get()->GetLoggedInUser()->email(); | 114 std::string user = chromeos::UserManager::Get()->GetLoggedInUser()->email(); |
107 size_t at_pos = user.find('@'); | 115 size_t at_pos = user.find('@'); |
108 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 116 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
109 domain = user.substr(user.find('@') + 1); | 117 domain = user.substr(user.find('@') + 1); |
110 return domain == g_browser_process->browser_policy_connector()-> | 118 return domain == g_browser_process->browser_policy_connector()-> |
111 GetEnterpriseDomain(); | 119 GetEnterpriseDomain(); |
120 } else if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | |
121 // On non managed machines we have local owner who is the only one to change | |
122 // anything. Ensure that ReleaseChannelDelegated is false. | |
123 return !value; | |
112 } | 124 } |
113 return false; | 125 return false; |
114 } | 126 } |
115 | 127 |
116 // Pointer to a |StringValue| holding the date of the build date to Chromium | 128 // Pointer to a |StringValue| holding the date of the build date to Chromium |
117 // OS. Because this value is obtained by reading a file, it is cached here to | 129 // OS. Because this value is obtained by reading a file, it is cached here to |
118 // prevent the need to read from the file system multiple times unnecessarily. | 130 // prevent the need to read from the file system multiple times unnecessarily. |
119 Value* g_build_date_string = NULL; | 131 Value* g_build_date_string = NULL; |
120 | 132 |
121 #endif // defined(OS_CHROMEOS) | 133 #endif // defined(OS_CHROMEOS) |
(...skipping 17 matching lines...) Expand all Loading... | |
139 static L10nResources resources[] = { | 151 static L10nResources resources[] = { |
140 { "helpTitle", IDS_HELP_TITLE }, | 152 { "helpTitle", IDS_HELP_TITLE }, |
141 { "aboutTitle", IDS_ABOUT_TAB_TITLE }, | 153 { "aboutTitle", IDS_ABOUT_TAB_TITLE }, |
142 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
143 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, | 155 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, |
144 #else | 156 #else |
145 { "aboutProductTitle", IDS_PRODUCT_NAME }, | 157 { "aboutProductTitle", IDS_PRODUCT_NAME }, |
146 #endif | 158 #endif |
147 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION }, | 159 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION }, |
148 { "relaunch", IDS_RELAUNCH_BUTTON }, | 160 { "relaunch", IDS_RELAUNCH_BUTTON }, |
161 { "relaunch", IDS_RELAUNCH_BUTTON }, | |
Isaac (away)
2013/11/04 08:28:27
Duplicate string?
| |
162 #if defined(OS_CHROMEOS) | |
163 { "relaunchAndPowerwash", IDS_RELAUNCH_AND_POWERWASH_BUTTON }, | |
164 #endif | |
149 { "productName", IDS_PRODUCT_NAME }, | 165 { "productName", IDS_PRODUCT_NAME }, |
150 { "productCopyright", IDS_ABOUT_VERSION_COPYRIGHT }, | 166 { "productCopyright", IDS_ABOUT_VERSION_COPYRIGHT }, |
151 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED }, | 167 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED }, |
152 { "upToDate", IDS_UPGRADE_UP_TO_DATE }, | 168 { "upToDate", IDS_UPGRADE_UP_TO_DATE }, |
153 { "updating", IDS_UPGRADE_UPDATING }, | 169 { "updating", IDS_UPGRADE_UPDATING }, |
170 #if defined(OS_CHROMEOS) | |
171 { "updatingChannelSwitch", IDS_UPGRADE_UPDATING_CHANNEL_SWITCH }, | |
172 #endif | |
154 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, | 173 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, |
174 #if defined(OS_CHROMEOS) | |
175 { "successfulChannelSwitch", IDS_UPGRADE_SUCCESSFUL_CHANNEL_SWITCH }, | |
176 #endif | |
155 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, | 177 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, |
156 { kResourceReportIssue, IDS_REPORT_AN_ISSUE }, | 178 { kResourceReportIssue, IDS_REPORT_AN_ISSUE }, |
157 #if defined(OS_CHROMEOS) | 179 #if defined(OS_CHROMEOS) |
158 { "platform", IDS_PLATFORM_LABEL }, | 180 { "platform", IDS_PLATFORM_LABEL }, |
159 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, | 181 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, |
160 { "showMoreInfo", IDS_SHOW_MORE_INFO }, | 182 { "showMoreInfo", IDS_SHOW_MORE_INFO }, |
161 { "hideMoreInfo", IDS_HIDE_MORE_INFO }, | 183 { "hideMoreInfo", IDS_HIDE_MORE_INFO }, |
162 { "channel", IDS_ABOUT_PAGE_CHANNEL }, | 184 { "channel", IDS_ABOUT_PAGE_CHANNEL }, |
163 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, | 185 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, |
164 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, | 186 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, |
165 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, | 187 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, |
166 { "channel-changed", IDS_ABOUT_PAGE_CHANNEL_CHANGED }, | 188 { "channel-changed", IDS_ABOUT_PAGE_CHANNEL_CHANGED }, |
189 { "currentChannelStable", IDS_ABOUT_PAGE_CURRENT_CHANNEL_STABLE }, | |
190 { "currentChannelBeta", IDS_ABOUT_PAGE_CURRENT_CHANNEL_BETA }, | |
191 { "currentChannelDev", IDS_ABOUT_PAGE_CURRENT_CHANNEL_DEV }, | |
192 { "currentChannel", IDS_ABOUT_PAGE_CURRENT_CHANNEL }, | |
193 { "channelChangeButton", IDS_ABOUT_PAGE_CHANNEL_CHANGE_BUTTON }, | |
194 { "channelChangeDisallowedMessage", | |
195 IDS_ABOUT_PAGE_CHANNEL_CHANGE_DISALLOWED_MESSAGE }, | |
196 { "channelChangePageTitle", IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_TITLE }, | |
197 { "channelChangePagePowerwashTitle", | |
198 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_TITLE }, | |
199 { "channelChangePagePowerwashMessage", | |
200 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_MESSAGE }, | |
201 { "channelChangePageDelayedChangeTitle", | |
202 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_TITLE }, | |
203 { "channelChangePageUnstableTitle", | |
204 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_TITLE }, | |
205 { "channelChangePagePowerwashButton", | |
206 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_BUTTON }, | |
207 { "channelChangePageChangeButton", | |
208 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CHANGE_BUTTON }, | |
209 { "channelChangePageCancelButton", | |
210 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CANCEL_BUTTON }, | |
167 { "webkit", IDS_WEBKIT }, | 211 { "webkit", IDS_WEBKIT }, |
168 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT }, | 212 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT }, |
169 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, | 213 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, |
170 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, | 214 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, |
171 #endif | 215 #endif |
172 #if defined(OS_MACOSX) | 216 #if defined(OS_MACOSX) |
173 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, | 217 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, |
174 { "learnMore", IDS_LEARN_MORE }, | 218 { "learnMore", IDS_LEARN_MORE }, |
175 #endif | 219 #endif |
176 }; | 220 }; |
(...skipping 22 matching lines...) Expand all Loading... | |
199 IDS_ABOUT_VERSION_LICENSE, | 243 IDS_ABOUT_VERSION_LICENSE, |
200 ASCIIToUTF16(chrome::kChromiumProjectURL), | 244 ASCIIToUTF16(chrome::kChromiumProjectURL), |
201 ASCIIToUTF16(chrome::kChromeUICreditsURL)); | 245 ASCIIToUTF16(chrome::kChromeUICreditsURL)); |
202 source->AddString("productLicense", license); | 246 source->AddString("productLicense", license); |
203 | 247 |
204 #if defined(OS_CHROMEOS) | 248 #if defined(OS_CHROMEOS) |
205 string16 os_license = l10n_util::GetStringFUTF16( | 249 string16 os_license = l10n_util::GetStringFUTF16( |
206 IDS_ABOUT_CROS_VERSION_LICENSE, | 250 IDS_ABOUT_CROS_VERSION_LICENSE, |
207 ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); | 251 ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); |
208 source->AddString("productOsLicense", os_license); | 252 source->AddString("productOsLicense", os_license); |
253 | |
254 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); | |
255 source->AddString( | |
256 "channelChangePageDelayedChangeMessage", | |
257 l10n_util::GetStringFUTF16( | |
258 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE, | |
259 product_name)); | |
260 source->AddString( | |
261 "channelChangePageUnstableMessage", | |
262 l10n_util::GetStringFUTF16( | |
263 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE, | |
264 product_name)); | |
265 | |
266 if (CommandLine::ForCurrentProcess()-> | |
267 HasSwitch(chromeos::switches::kDisableNewChannelSwitcherUI)) { | |
268 source->AddBoolean("disableNewChannelSwitcherUI", true); | |
269 } | |
209 #endif | 270 #endif |
210 | 271 |
211 string16 tos = l10n_util::GetStringFUTF16( | 272 string16 tos = l10n_util::GetStringFUTF16( |
212 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL)); | 273 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL)); |
213 source->AddString("productTOS", tos); | 274 source->AddString("productTOS", tos); |
214 | 275 |
215 source->AddString("webkitVersion", webkit_glue::GetWebKitVersion()); | 276 source->AddString("webkitVersion", webkit_glue::GetWebKitVersion()); |
216 | 277 |
217 source->AddString("jsEngine", "V8"); | 278 source->AddString("jsEngine", "V8"); |
218 source->AddString("jsEngineVersion", v8::V8::GetVersion()); | 279 source->AddString("jsEngineVersion", v8::V8::GetVersion()); |
(...skipping 11 matching lines...) Expand all Loading... | |
230 | 291 |
231 web_ui()->RegisterMessageCallback("onPageLoaded", | 292 web_ui()->RegisterMessageCallback("onPageLoaded", |
232 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); | 293 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); |
233 web_ui()->RegisterMessageCallback("relaunchNow", | 294 web_ui()->RegisterMessageCallback("relaunchNow", |
234 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); | 295 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); |
235 web_ui()->RegisterMessageCallback("openFeedbackDialog", | 296 web_ui()->RegisterMessageCallback("openFeedbackDialog", |
236 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); | 297 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); |
237 web_ui()->RegisterMessageCallback("openHelpPage", | 298 web_ui()->RegisterMessageCallback("openHelpPage", |
238 base::Bind(&HelpHandler::OpenHelpPage, base::Unretained(this))); | 299 base::Bind(&HelpHandler::OpenHelpPage, base::Unretained(this))); |
239 #if defined(OS_CHROMEOS) | 300 #if defined(OS_CHROMEOS) |
240 web_ui()->RegisterMessageCallback("setReleaseTrack", | 301 web_ui()->RegisterMessageCallback("setChannel", |
241 base::Bind(&HelpHandler::SetReleaseTrack, base::Unretained(this))); | 302 base::Bind(&HelpHandler::SetChannel, base::Unretained(this))); |
303 web_ui()->RegisterMessageCallback("relaunchAndPowerwash", | |
304 base::Bind(&HelpHandler::RelaunchAndPowerwash, base::Unretained(this))); | |
242 #endif | 305 #endif |
243 #if defined(OS_MACOSX) | 306 #if defined(OS_MACOSX) |
244 web_ui()->RegisterMessageCallback("promoteUpdater", | 307 web_ui()->RegisterMessageCallback("promoteUpdater", |
245 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); | 308 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); |
246 #endif | 309 #endif |
247 } | 310 } |
248 | 311 |
249 void HelpHandler::Observe(int type, const content::NotificationSource& source, | 312 void HelpHandler::Observe(int type, const content::NotificationSource& source, |
250 const content::NotificationDetails& details) { | 313 const content::NotificationDetails& details) { |
251 switch (type) { | 314 switch (type) { |
(...skipping 19 matching lines...) Expand all Loading... | |
271 loader_.GetVersion( | 334 loader_.GetVersion( |
272 chromeos::VersionLoader::VERSION_FULL, | 335 chromeos::VersionLoader::VERSION_FULL, |
273 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)), | 336 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)), |
274 &tracker_); | 337 &tracker_); |
275 loader_.GetFirmware( | 338 loader_.GetFirmware( |
276 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)), | 339 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)), |
277 &tracker_); | 340 &tracker_); |
278 | 341 |
279 web_ui()->CallJavascriptFunction( | 342 web_ui()->CallJavascriptFunction( |
280 "help.HelpPage.updateEnableReleaseChannel", | 343 "help.HelpPage.updateEnableReleaseChannel", |
281 base::FundamentalValue(CanChangeReleaseChannel())); | 344 base::FundamentalValue(CanChangeChannel())); |
282 | 345 |
283 if (g_build_date_string == NULL) { | 346 if (g_build_date_string == NULL) { |
284 // If |g_build_date_string| is |NULL|, the date has not yet been assigned. | 347 // If |g_build_date_string| is |NULL|, the date has not yet been assigned. |
285 // Get the date of the last lsb-release file modification. | 348 // Get the date of the last lsb-release file modification. |
286 base::FileUtilProxy::GetFileInfo( | 349 base::FileUtilProxy::GetFileInfo( |
287 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 350 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
288 base::SysInfo::GetLsbReleaseFilePath(), | 351 base::SysInfo::GetLsbReleaseFilePath(), |
289 base::Bind(&HelpHandler::ProcessLsbFileInfo, | 352 base::Bind(&HelpHandler::ProcessLsbFileInfo, |
290 weak_factory_.GetWeakPtr())); | 353 weak_factory_.GetWeakPtr())); |
291 } else { | 354 } else { |
292 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | 355 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
293 *g_build_date_string); | 356 *g_build_date_string); |
294 } | 357 } |
295 #endif // defined(OS_CHROMEOS) | 358 #endif // defined(OS_CHROMEOS) |
296 | 359 |
297 version_updater_->CheckForUpdate( | 360 version_updater_->CheckForUpdate( |
298 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) | 361 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) |
299 #if defined(OS_MACOSX) | 362 #if defined(OS_MACOSX) |
300 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) | 363 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) |
301 #endif | 364 #endif |
302 ); | 365 ); |
303 | 366 |
304 #if defined(OS_CHROMEOS) | 367 #if defined(OS_CHROMEOS) |
305 version_updater_->GetReleaseChannel( | 368 web_ui()->CallJavascriptFunction( |
306 base::Bind(&HelpHandler::OnReleaseChannel, base::Unretained(this))); | 369 "help.HelpPage.updateIsEnterpriseManaged", |
370 base::FundamentalValue(IsEnterpriseManaged())); | |
371 // First argument to GetChannel() is a flag that indicates whether | |
372 // current channel should be returned (if true) or target channel | |
373 // (otherwise). | |
374 version_updater_->GetChannel(true, | |
375 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | |
376 version_updater_->GetChannel(false, | |
377 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | |
307 #endif | 378 #endif |
308 } | 379 } |
309 | 380 |
310 #if defined(OS_MACOSX) | 381 #if defined(OS_MACOSX) |
311 void HelpHandler::PromoteUpdater(const ListValue* args) { | 382 void HelpHandler::PromoteUpdater(const ListValue* args) { |
312 version_updater_->PromoteUpdater(); | 383 version_updater_->PromoteUpdater(); |
313 } | 384 } |
314 #endif | 385 #endif |
315 | 386 |
316 void HelpHandler::RelaunchNow(const ListValue* args) { | 387 void HelpHandler::RelaunchNow(const ListValue* args) { |
(...skipping 10 matching lines...) Expand all Loading... | |
327 | 398 |
328 void HelpHandler::OpenHelpPage(const base::ListValue* args) { | 399 void HelpHandler::OpenHelpPage(const base::ListValue* args) { |
329 DCHECK(args->empty()); | 400 DCHECK(args->empty()); |
330 Browser* browser = chrome::FindBrowserWithWebContents( | 401 Browser* browser = chrome::FindBrowserWithWebContents( |
331 web_ui()->GetWebContents()); | 402 web_ui()->GetWebContents()); |
332 chrome::ShowHelp(browser, chrome::HELP_SOURCE_WEBUI); | 403 chrome::ShowHelp(browser, chrome::HELP_SOURCE_WEBUI); |
333 } | 404 } |
334 | 405 |
335 #if defined(OS_CHROMEOS) | 406 #if defined(OS_CHROMEOS) |
336 | 407 |
337 void HelpHandler::SetReleaseTrack(const ListValue* args) { | 408 void HelpHandler::SetChannel(const ListValue* args) { |
338 if (!CanChangeReleaseChannel()) { | 409 DCHECK(args->GetSize() == 2); |
410 | |
411 if (!CanChangeChannel()) { | |
339 LOG(WARNING) << "Non-owner tried to change release track."; | 412 LOG(WARNING) << "Non-owner tried to change release track."; |
340 return; | 413 return; |
341 } | 414 } |
342 | 415 |
343 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); | 416 base::string16 channel; |
344 version_updater_->SetReleaseChannel(channel); | 417 bool is_powerwash_allowed; |
345 // On enterprise machines we can only use SetReleaseChannel to store the | 418 if (!args->GetString(0, &channel) || |
346 // user choice in the lsb-release file but we can not modify the policy blob. | 419 !args->GetBoolean(1, &is_powerwash_allowed)) { |
347 // Therefore we only call SetString if the device is locally owned and the | 420 LOG(ERROR) << "Can't parse SetReleaseTrack() args"; |
348 // currently logged in user is the owner. | 421 return; |
422 } | |
423 | |
424 version_updater_->SetChannel(UTF16ToUTF8(channel), is_powerwash_allowed); | |
349 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | 425 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
350 chromeos::CrosSettings::Get()->SetString(chromeos::kReleaseChannel, | |
351 channel); | |
352 // Check for update after switching release channel. | 426 // Check for update after switching release channel. |
353 version_updater_->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus, | 427 version_updater_->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus, |
354 base::Unretained(this))); | 428 base::Unretained(this))); |
355 } | 429 } |
356 } | 430 } |
357 | 431 |
432 void HelpHandler::RelaunchAndPowerwash(const ListValue* args) { | |
433 DCHECK(args->empty()); | |
434 | |
435 if (IsEnterpriseManaged()) | |
436 return; | |
437 | |
438 PrefService* prefs = g_browser_process->local_state(); | |
439 prefs->SetBoolean(prefs::kFactoryResetRequested, true); | |
440 prefs->CommitPendingWrite(); | |
441 | |
442 // Perform sign out. Current chrome process will then terminate, new one will | |
443 // be launched (as if it was a restart). | |
444 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | |
445 } | |
446 | |
358 #endif // defined(OS_CHROMEOS) | 447 #endif // defined(OS_CHROMEOS) |
359 | 448 |
360 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, | 449 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, |
361 int progress, const string16& message) { | 450 int progress, const string16& message) { |
362 // Only UPDATING state should have progress set. | 451 // Only UPDATING state should have progress set. |
363 DCHECK(status == VersionUpdater::UPDATING || progress == 0); | 452 DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
364 | 453 |
365 std::string status_str; | 454 std::string status_str; |
366 switch (status) { | 455 switch (status) { |
367 case VersionUpdater::CHECKING: | 456 case VersionUpdater::CHECKING: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 void HelpHandler::OnOSVersion(const std::string& version) { | 529 void HelpHandler::OnOSVersion(const std::string& version) { |
441 web_ui()->CallJavascriptFunction("help.HelpPage.setOSVersion", | 530 web_ui()->CallJavascriptFunction("help.HelpPage.setOSVersion", |
442 base::StringValue(version)); | 531 base::StringValue(version)); |
443 } | 532 } |
444 | 533 |
445 void HelpHandler::OnOSFirmware(const std::string& firmware) { | 534 void HelpHandler::OnOSFirmware(const std::string& firmware) { |
446 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", | 535 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", |
447 base::StringValue(firmware)); | 536 base::StringValue(firmware)); |
448 } | 537 } |
449 | 538 |
450 void HelpHandler::OnReleaseChannel(const std::string& channel) { | 539 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
451 web_ui()->CallJavascriptFunction( | 540 web_ui()->CallJavascriptFunction( |
452 "help.HelpPage.updateSelectedChannel", base::StringValue(channel)); | 541 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
542 } | |
543 | |
544 void HelpHandler::OnTargetChannel(const std::string& channel) { | |
545 web_ui()->CallJavascriptFunction( | |
546 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | |
453 } | 547 } |
454 | 548 |
455 void HelpHandler::ProcessLsbFileInfo( | 549 void HelpHandler::ProcessLsbFileInfo( |
456 base::PlatformFileError error, const base::PlatformFileInfo& file_info) { | 550 base::PlatformFileError error, const base::PlatformFileInfo& file_info) { |
457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
458 | 552 |
459 // If |g_build_date_string| is not |NULL|, then the file's information has | 553 // If |g_build_date_string| is not |NULL|, then the file's information has |
460 // already been retrieved by another tab. | 554 // already been retrieved by another tab. |
461 if (g_build_date_string == NULL) { | 555 if (g_build_date_string == NULL) { |
462 base::Time time; | 556 base::Time time; |
(...skipping 10 matching lines...) Expand all Loading... | |
473 | 567 |
474 // Note that this string will be internationalized. | 568 // Note that this string will be internationalized. |
475 string16 build_date = base::TimeFormatFriendlyDate(time); | 569 string16 build_date = base::TimeFormatFriendlyDate(time); |
476 g_build_date_string = Value::CreateStringValue(build_date); | 570 g_build_date_string = Value::CreateStringValue(build_date); |
477 } | 571 } |
478 | 572 |
479 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | 573 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
480 *g_build_date_string); | 574 *g_build_date_string); |
481 } | 575 } |
482 #endif // defined(OS_CHROMEOS) | 576 #endif // defined(OS_CHROMEOS) |
OLD | NEW |