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

Side by Side Diff: chrome/browser/automation/testing_automation_provider_chromeos.cc

Issue 10827050: Added a timezone policy and pyauto tests for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments. Created 8 years, 4 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
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/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/chromeos/login/login_display_host.h" 27 #include "chrome/browser/chromeos/login/login_display_host.h"
28 #include "chrome/browser/chromeos/login/network_screen.h" 28 #include "chrome/browser/chromeos/login/network_screen.h"
29 #include "chrome/browser/chromeos/login/screen_locker.h" 29 #include "chrome/browser/chromeos/login/screen_locker.h"
30 #include "chrome/browser/chromeos/login/update_screen.h" 30 #include "chrome/browser/chromeos/login/update_screen.h"
31 #include "chrome/browser/chromeos/login/user_image_screen.h" 31 #include "chrome/browser/chromeos/login/user_image_screen.h"
32 #include "chrome/browser/chromeos/login/webui_login_display.h" 32 #include "chrome/browser/chromeos/login/webui_login_display.h"
33 #include "chrome/browser/chromeos/login/webui_login_display_host.h" 33 #include "chrome/browser/chromeos/login/webui_login_display_host.h"
34 #include "chrome/browser/chromeos/login/wizard_controller.h" 34 #include "chrome/browser/chromeos/login/wizard_controller.h"
35 #include "chrome/browser/chromeos/options/take_photo_dialog.h" 35 #include "chrome/browser/chromeos/options/take_photo_dialog.h"
36 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" 36 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h"
37 #include "chrome/browser/chromeos/settings/cros_settings.h"
38 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
37 #include "chrome/browser/chromeos/system/timezone_settings.h" 39 #include "chrome/browser/chromeos/system/timezone_settings.h"
38 #include "chrome/browser/policy/browser_policy_connector.h" 40 #include "chrome/browser/policy/browser_policy_connector.h"
39 #include "chrome/browser/policy/cloud_policy_cache_base.h" 41 #include "chrome/browser/policy/cloud_policy_cache_base.h"
40 #include "chrome/browser/policy/cloud_policy_data_store.h" 42 #include "chrome/browser/policy/cloud_policy_data_store.h"
41 #include "chrome/browser/policy/cloud_policy_subsystem.h" 43 #include "chrome/browser/policy/cloud_policy_subsystem.h"
42 #include "chrome/browser/policy/enterprise_install_attributes.h" 44 #include "chrome/browser/policy/enterprise_install_attributes.h"
43 #include "chrome/browser/prefs/pref_service.h" 45 #include "chrome/browser/prefs/pref_service.h"
44 #include "chrome/browser/ui/browser.h" 46 #include "chrome/browser/ui/browser.h"
45 #include "chrome/browser/ui/browser_window.h" 47 #include "chrome/browser/ui/browser_window.h"
46 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 48 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 DictionaryValue* args, 1317 DictionaryValue* args,
1316 IPC::Message* reply_message) { 1318 IPC::Message* reply_message) {
1317 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 1319 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
1318 base::Time time(base::Time::Now()); 1320 base::Time time(base::Time::Now());
1319 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean( 1321 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean(
1320 prefs::kUse24HourClock); 1322 prefs::kUse24HourClock);
1321 base::HourClockType hour_clock_type = 1323 base::HourClockType hour_clock_type =
1322 use_24hour_clock ? base::k24HourClock : base::k12HourClock; 1324 use_24hour_clock ? base::k24HourClock : base::k12HourClock;
1323 string16 display_time = base::TimeFormatTimeOfDayWithHourClockType( 1325 string16 display_time = base::TimeFormatTimeOfDayWithHourClockType(
1324 time, hour_clock_type, base::kDropAmPm); 1326 time, hour_clock_type, base::kDropAmPm);
1325 icu::UnicodeString unicode; 1327 string16 timezone =
1326 chromeos::system::TimezoneSettings::GetInstance()->GetTimezone().getID( 1328 chromeos::system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID();
1327 unicode);
1328 std::string timezone;
1329 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &timezone);
1330 return_value->SetString("display_time", display_time); 1329 return_value->SetString("display_time", display_time);
1331 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time)); 1330 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time));
1332 return_value->SetString("timezone", timezone); 1331 return_value->SetString("timezone", timezone);
1333 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 1332 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
1334 } 1333 }
1335 1334
1336 void TestingAutomationProvider::GetTimeInfo(DictionaryValue* args, 1335 void TestingAutomationProvider::GetTimeInfo(DictionaryValue* args,
1337 IPC::Message* reply_message) { 1336 IPC::Message* reply_message) {
1338 GetTimeInfo(NULL, args, reply_message); 1337 GetTimeInfo(NULL, args, reply_message);
1339 } 1338 }
1340 1339
1341 void TestingAutomationProvider::SetTimezone(DictionaryValue* args, 1340 void TestingAutomationProvider::SetTimezone(DictionaryValue* args,
1342 IPC::Message* reply_message) { 1341 IPC::Message* reply_message) {
1342 AutomationJSONReply reply(this, reply_message);
1343 std::string timezone_id; 1343 std::string timezone_id;
1344 if (!args->GetString("timezone", &timezone_id)) { 1344 if (!args->GetString("timezone", &timezone_id)) {
1345 AutomationJSONReply(this, reply_message).SendError( 1345 reply.SendError("Invalid or missing args.");
1346 "Invalid or missing args.");
1347 return; 1346 return;
1348 } 1347 }
1349 1348 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
1350 icu::TimeZone* timezone = 1349 settings->SetString(chromeos::kSystemTimezone, timezone_id);
1351 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id)); 1350 reply.SendSuccess(NULL);
1352 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone);
1353 delete timezone;
1354 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
1355 } 1351 }
1356 1352
1357 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, 1353 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args,
1358 IPC::Message* reply_message) { 1354 IPC::Message* reply_message) {
1359 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); 1355 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
1360 DBusThreadManager::Get()->GetUpdateEngineClient() 1356 DBusThreadManager::Get()->GetUpdateEngineClient()
1361 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply)); 1357 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply));
1362 } 1358 }
1363 1359
1364 void TestingAutomationProvider::UpdateCheck( 1360 void TestingAutomationProvider::UpdateCheck(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 1420 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
1425 if (!audio_handler) { 1421 if (!audio_handler) {
1426 reply.SendError("AudioHandler not initialized."); 1422 reply.SendError("AudioHandler not initialized.");
1427 return; 1423 return;
1428 } 1424 }
1429 audio_handler->SetMuted(mute); 1425 audio_handler->SetMuted(mute);
1430 reply.SendSuccess(NULL); 1426 reply.SendSuccess(NULL);
1431 } 1427 }
1432 1428
1433 void TestingAutomationProvider::OpenCrosh(DictionaryValue* args, 1429 void TestingAutomationProvider::OpenCrosh(DictionaryValue* args,
1434 IPC::Message* reply_message) { 1430 IPC::Message* reply_message) {
1435 new NavigationNotificationObserver( 1431 new NavigationNotificationObserver(
1436 NULL, this, reply_message, 1, false, true); 1432 NULL, this, reply_message, 1, false, true);
1437 ash::Shell::GetInstance()->delegate()->OpenCrosh(); 1433 ash::Shell::GetInstance()->delegate()->OpenCrosh();
1438 } 1434 }
1439 1435
1440 void TestingAutomationProvider::CaptureProfilePhoto( 1436 void TestingAutomationProvider::CaptureProfilePhoto(
1441 Browser* browser, 1437 Browser* browser,
1442 DictionaryValue* args, 1438 DictionaryValue* args,
1443 IPC::Message* reply_message) { 1439 IPC::Message* reply_message) {
1444 chromeos::TakePhotoDialog* take_photo_dialog = 1440 chromeos::TakePhotoDialog* take_photo_dialog =
(...skipping 14 matching lines...) Expand all
1459 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1455 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1460 AddObserver(power_manager_observer_); 1456 AddObserver(power_manager_observer_);
1461 } 1457 }
1462 1458
1463 void TestingAutomationProvider::RemoveChromeosObservers() { 1459 void TestingAutomationProvider::RemoveChromeosObservers() {
1464 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1460 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1465 RemoveObserver(power_manager_observer_); 1461 RemoveObserver(power_manager_observer_);
1466 delete power_manager_observer_; 1462 delete power_manager_observer_;
1467 power_manager_observer_ = NULL; 1463 power_manager_observer_ = NULL;
1468 } 1464 }
OLDNEW
« no previous file with comments | « chrome/app/policy/policy_templates.json ('k') | chrome/browser/chromeos/settings/cros_settings_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698