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

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

Issue 2538043006: Settings: About: Fix cros channel info. (Closed)
Patch Set: Fix non cros tests 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 base::string16 tos = l10n_util::GetStringFUTF16( 301 base::string16 tos = l10n_util::GetStringFUTF16(
302 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL)); 302 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL));
303 html_source->AddString("aboutProductTos", tos); 303 html_source->AddString("aboutProductTos", tos);
304 #endif 304 #endif
305 305
306 #if defined(OS_CHROMEOS) 306 #if defined(OS_CHROMEOS)
307 base::string16 os_license = l10n_util::GetStringFUTF16( 307 base::string16 os_license = l10n_util::GetStringFUTF16(
308 IDS_ABOUT_CROS_VERSION_LICENSE, 308 IDS_ABOUT_CROS_VERSION_LICENSE,
309 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); 309 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL));
310 html_source->AddString("aboutProductOsLicense", os_license); 310 html_source->AddString("aboutProductOsLicense", os_license);
311
312 html_source->AddBoolean("aboutCanChangeChannel", CanChangeChannel(profile));
313 html_source->AddBoolean("aboutEnterpriseManaged", IsEnterpriseManaged()); 311 html_source->AddBoolean("aboutEnterpriseManaged", IsEnterpriseManaged());
314 312
315 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); 313 base::Time build_time = base::SysInfo::GetLsbReleaseTime();
316 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); 314 base::string16 build_date = base::TimeFormatFriendlyDate(build_time);
317 html_source->AddString("aboutBuildDate", build_date); 315 html_source->AddString("aboutBuildDate", build_date);
318 316
319 base::CommandLine::StringType command_line = 317 base::CommandLine::StringType command_line =
320 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); 318 base::CommandLine::ForCurrentProcess()->GetCommandLineString();
321 html_source->AddString("aboutCommandLine", command_line); 319 html_source->AddString("aboutCommandLine", command_line);
322 320
(...skipping 27 matching lines...) Expand all
350 "requestUpdate", 348 "requestUpdate",
351 base::Bind(&AboutHandler::HandleRequestUpdate, base::Unretained(this))); 349 base::Bind(&AboutHandler::HandleRequestUpdate, base::Unretained(this)));
352 350
353 web_ui()->RegisterMessageCallback( 351 web_ui()->RegisterMessageCallback(
354 "getVersionInfo", 352 "getVersionInfo",
355 base::Bind(&AboutHandler::HandleGetVersionInfo, base::Unretained(this))); 353 base::Bind(&AboutHandler::HandleGetVersionInfo, base::Unretained(this)));
356 web_ui()->RegisterMessageCallback( 354 web_ui()->RegisterMessageCallback(
357 "getRegulatoryInfo", base::Bind(&AboutHandler::HandleGetRegulatoryInfo, 355 "getRegulatoryInfo", base::Bind(&AboutHandler::HandleGetRegulatoryInfo,
358 base::Unretained(this))); 356 base::Unretained(this)));
359 web_ui()->RegisterMessageCallback( 357 web_ui()->RegisterMessageCallback(
360 "getCurrentChannel", base::Bind(&AboutHandler::HandleGetCurrentChannel, 358 "getChannelInfo", base::Bind(&AboutHandler::HandleGetChannelInfo,
361 base::Unretained(this))); 359 base::Unretained(this)));
362 web_ui()->RegisterMessageCallback(
363 "getTargetChannel", base::Bind(&AboutHandler::HandleGetTargetChannel,
364 base::Unretained(this)));
365 #endif 360 #endif
366 #if defined(OS_MACOSX) 361 #if defined(OS_MACOSX)
367 web_ui()->RegisterMessageCallback( 362 web_ui()->RegisterMessageCallback(
368 "promoteUpdater", 363 "promoteUpdater",
369 base::Bind(&AboutHandler::PromoteUpdater, base::Unretained(this))); 364 base::Bind(&AboutHandler::PromoteUpdater, base::Unretained(this)));
370 #endif 365 #endif
371 366
372 #if defined(OS_CHROMEOS) 367 #if defined(OS_CHROMEOS)
373 // Handler for the product label image, which will be shown if available. 368 // Handler for the product label image, which will be shown if available.
374 content::URLDataSource::Add(Profile::FromWebUI(web_ui()), 369 content::URLDataSource::Add(Profile::FromWebUI(web_ui()),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 std::string callback_id; 508 std::string callback_id;
514 CHECK(args->GetString(0, &callback_id)); 509 CHECK(args->GetString(0, &callback_id));
515 510
516 base::PostTaskAndReplyWithResult( 511 base::PostTaskAndReplyWithResult(
517 content::BrowserThread::GetBlockingPool(), FROM_HERE, 512 content::BrowserThread::GetBlockingPool(), FROM_HERE,
518 base::Bind(&FindRegulatoryLabelDir), 513 base::Bind(&FindRegulatoryLabelDir),
519 base::Bind(&AboutHandler::OnRegulatoryLabelDirFound, 514 base::Bind(&AboutHandler::OnRegulatoryLabelDirFound,
520 weak_factory_.GetWeakPtr(), callback_id)); 515 weak_factory_.GetWeakPtr(), callback_id));
521 } 516 }
522 517
523 void AboutHandler::HandleGetCurrentChannel(const base::ListValue* args) { 518 void AboutHandler::HandleGetChannelInfo(const base::ListValue* args) {
524 CHECK_EQ(1U, args->GetSize());
525 std::string callback_id;
526 CHECK(args->GetString(0, &callback_id));
527 // First argument to GetChannel() is a flag that indicates whether
528 // current channel should be returned (if true) or target channel
529 // (otherwise).
530 version_updater_->GetChannel(
531 true, base::Bind(&AboutHandler::OnGetChannelReady,
532 weak_factory_.GetWeakPtr(), callback_id));
533 }
534
535 void AboutHandler::HandleGetTargetChannel(const base::ListValue* args) {
536 CHECK_EQ(1U, args->GetSize()); 519 CHECK_EQ(1U, args->GetSize());
537 std::string callback_id; 520 std::string callback_id;
538 CHECK(args->GetString(0, &callback_id)); 521 CHECK(args->GetString(0, &callback_id));
539 version_updater_->GetChannel( 522 version_updater_->GetChannel(
540 false, base::Bind(&AboutHandler::OnGetChannelReady, 523 true /* get current channel */,
541 weak_factory_.GetWeakPtr(), callback_id)); 524 base::Bind(&AboutHandler::OnGetCurrentChannel, weak_factory_.GetWeakPtr(),
525 callback_id));
542 } 526 }
543 527
544 void AboutHandler::OnGetChannelReady(std::string callback_id, 528 void AboutHandler::OnGetCurrentChannel(std::string callback_id,
545 const std::string& channel) { 529 const std::string& current_channel) {
546 ResolveJavascriptCallback(base::StringValue(callback_id), 530 version_updater_->GetChannel(
547 base::StringValue(channel)); 531 false /* get target channel */,
532 base::Bind(&AboutHandler::OnGetTargetChannel, weak_factory_.GetWeakPtr(),
533 callback_id, current_channel));
534 }
535
536 void AboutHandler::OnGetTargetChannel(std::string callback_id,
537 const std::string& current_channel,
538 const std::string& target_channel) {
539 std::unique_ptr<base::DictionaryValue> channel_info(
540 new base::DictionaryValue);
541 channel_info->SetString("currentChannel", current_channel);
542 channel_info->SetString("targetChannel", target_channel);
543 channel_info->SetBoolean("canChangeChannel",
544 CanChangeChannel(Profile::FromWebUI(web_ui())));
545
546 ResolveJavascriptCallback(base::StringValue(callback_id), *channel_info);
548 } 547 }
549 548
550 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) { 549 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) {
551 RequestUpdate(); 550 RequestUpdate();
552 } 551 }
553 552
554 #endif // defined(OS_CHROMEOS) 553 #endif // defined(OS_CHROMEOS)
555 554
556 void AboutHandler::RequestUpdate() { 555 void AboutHandler::RequestUpdate() {
557 version_updater_->CheckForUpdate( 556 version_updater_->CheckForUpdate(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 std::string url = 642 std::string url =
644 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; 643 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
645 regulatory_info->SetString("url", url); 644 regulatory_info->SetString("url", url);
646 645
647 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info); 646 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info);
648 } 647 }
649 648
650 #endif // defined(OS_CHROMEOS) 649 #endif // defined(OS_CHROMEOS)
651 650
652 } // namespace settings 651 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.h ('k') | chrome/test/data/webui/settings/about_page_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698