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

Side by Side Diff: chrome/browser/ui/webui/settings/about_handler.cc

Issue 2538043006: Settings: About: Fix cros channel info. (Closed)
Patch Set: . Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/about_handler.h" 5 #include "chrome/browser/ui/webui/settings/about_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 base::string16 tos = l10n_util::GetStringFUTF16( 291 base::string16 tos = l10n_util::GetStringFUTF16(
292 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL)); 292 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL));
293 html_source->AddString("aboutProductTos", tos); 293 html_source->AddString("aboutProductTos", tos);
294 #endif 294 #endif
295 295
296 #if defined(OS_CHROMEOS) 296 #if defined(OS_CHROMEOS)
297 base::string16 os_license = l10n_util::GetStringFUTF16( 297 base::string16 os_license = l10n_util::GetStringFUTF16(
298 IDS_ABOUT_CROS_VERSION_LICENSE, 298 IDS_ABOUT_CROS_VERSION_LICENSE,
299 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); 299 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL));
300 html_source->AddString("aboutProductOsLicense", os_license); 300 html_source->AddString("aboutProductOsLicense", os_license);
301
302 html_source->AddBoolean("aboutCanChangeChannel", CanChangeChannel(profile));
stevenjb 2016/12/02 23:04:59 The primary problem is that the result of CanChang
dpapad 2016/12/02 23:27:12 I guess in the old C++ handler, we call CanChangeC
303 html_source->AddBoolean("aboutEnterpriseManaged", IsEnterpriseManaged()); 301 html_source->AddBoolean("aboutEnterpriseManaged", IsEnterpriseManaged());
304 302
305 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); 303 base::Time build_time = base::SysInfo::GetLsbReleaseTime();
306 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); 304 base::string16 build_date = base::TimeFormatFriendlyDate(build_time);
307 html_source->AddString("aboutBuildDate", build_date); 305 html_source->AddString("aboutBuildDate", build_date);
308 306
309 base::CommandLine::StringType command_line = 307 base::CommandLine::StringType command_line =
310 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); 308 base::CommandLine::ForCurrentProcess()->GetCommandLineString();
311 html_source->AddString("aboutCommandLine", command_line); 309 html_source->AddString("aboutCommandLine", command_line);
312 310
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 base::Bind(&AboutHandler::HandleGetVersionInfo, base::Unretained(this))); 343 base::Bind(&AboutHandler::HandleGetVersionInfo, base::Unretained(this)));
346 web_ui()->RegisterMessageCallback( 344 web_ui()->RegisterMessageCallback(
347 "getRegulatoryInfo", base::Bind(&AboutHandler::HandleGetRegulatoryInfo, 345 "getRegulatoryInfo", base::Bind(&AboutHandler::HandleGetRegulatoryInfo,
348 base::Unretained(this))); 346 base::Unretained(this)));
349 web_ui()->RegisterMessageCallback( 347 web_ui()->RegisterMessageCallback(
350 "getCurrentChannel", base::Bind(&AboutHandler::HandleGetCurrentChannel, 348 "getCurrentChannel", base::Bind(&AboutHandler::HandleGetCurrentChannel,
351 base::Unretained(this))); 349 base::Unretained(this)));
352 web_ui()->RegisterMessageCallback( 350 web_ui()->RegisterMessageCallback(
353 "getTargetChannel", base::Bind(&AboutHandler::HandleGetTargetChannel, 351 "getTargetChannel", base::Bind(&AboutHandler::HandleGetTargetChannel,
354 base::Unretained(this))); 352 base::Unretained(this)));
353 web_ui()->RegisterMessageCallback(
354 "getCanChangeChannel",
dpapad 2016/12/02 23:27:12 Nit: Maybe rename to just |canChangeChannel|? |get
stevenjb 2016/12/06 20:38:03 I decided this would all be a bit cleaner with a s
355 base::Bind(&AboutHandler::HandleGetCanChangeChannel,
356 base::Unretained(this)));
355 #endif 357 #endif
356 #if defined(OS_MACOSX) 358 #if defined(OS_MACOSX)
357 web_ui()->RegisterMessageCallback( 359 web_ui()->RegisterMessageCallback(
358 "promoteUpdater", 360 "promoteUpdater",
359 base::Bind(&AboutHandler::PromoteUpdater, base::Unretained(this))); 361 base::Bind(&AboutHandler::PromoteUpdater, base::Unretained(this)));
360 #endif 362 #endif
361 363
362 #if defined(OS_CHROMEOS) 364 #if defined(OS_CHROMEOS)
363 // Handler for the product label image, which will be shown if available. 365 // Handler for the product label image, which will be shown if available.
364 content::URLDataSource::Add(Profile::FromWebUI(web_ui()), 366 content::URLDataSource::Add(Profile::FromWebUI(web_ui()),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 void AboutHandler::OnGetChannelReady(std::string callback_id, 551 void AboutHandler::OnGetChannelReady(std::string callback_id,
550 const std::string& channel) { 552 const std::string& channel) {
551 ResolveJavascriptCallback(base::StringValue(callback_id), 553 ResolveJavascriptCallback(base::StringValue(callback_id),
552 base::StringValue(channel)); 554 base::StringValue(channel));
553 } 555 }
554 556
555 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) { 557 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) {
556 RequestUpdate(); 558 RequestUpdate();
557 } 559 }
558 560
561 void AboutHandler::HandleGetCanChangeChannel(const base::ListValue* args) {
562 CHECK_EQ(1U, args->GetSize());
563 std::string callback_id;
564 CHECK(args->GetString(0, &callback_id));
565
566 bool can_change_channel = CanChangeChannel(Profile::FromWebUI(web_ui()));
567
568 ResolveJavascriptCallback(base::StringValue(callback_id),
569 base::FundamentalValue(can_change_channel));
dpapad 2016/12/02 23:27:12 Nit (optional) ResolveJavascriptCallback( bas
stevenjb 2016/12/06 20:38:02 Done.
570 }
571
559 #endif // defined(OS_CHROMEOS) 572 #endif // defined(OS_CHROMEOS)
560 573
561 void AboutHandler::RequestUpdate() { 574 void AboutHandler::RequestUpdate() {
562 version_updater_->CheckForUpdate( 575 version_updater_->CheckForUpdate(
563 base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)), 576 base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
564 #if defined(OS_MACOSX) 577 #if defined(OS_MACOSX)
565 base::Bind(&AboutHandler::SetPromotionState, base::Unretained(this))); 578 base::Bind(&AboutHandler::SetPromotionState, base::Unretained(this)));
566 #else 579 #else
567 VersionUpdater::PromoteCallback()); 580 VersionUpdater::PromoteCallback());
568 #endif // OS_MACOSX 581 #endif // OS_MACOSX
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 std::string url = 661 std::string url =
649 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; 662 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
650 regulatory_info->SetString("url", url); 663 regulatory_info->SetString("url", url);
651 664
652 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info); 665 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info);
653 } 666 }
654 667
655 #endif // defined(OS_CHROMEOS) 668 #endif // defined(OS_CHROMEOS)
656 669
657 } // namespace settings 670 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698