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

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

Issue 10832222: Added a timezone policy and pyauto tests for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase and update policy id. 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 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 DictionaryValue* args, 1309 DictionaryValue* args,
1308 IPC::Message* reply_message) { 1310 IPC::Message* reply_message) {
1309 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 1311 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
1310 base::Time time(base::Time::Now()); 1312 base::Time time(base::Time::Now());
1311 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean( 1313 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean(
1312 prefs::kUse24HourClock); 1314 prefs::kUse24HourClock);
1313 base::HourClockType hour_clock_type = 1315 base::HourClockType hour_clock_type =
1314 use_24hour_clock ? base::k24HourClock : base::k12HourClock; 1316 use_24hour_clock ? base::k24HourClock : base::k12HourClock;
1315 string16 display_time = base::TimeFormatTimeOfDayWithHourClockType( 1317 string16 display_time = base::TimeFormatTimeOfDayWithHourClockType(
1316 time, hour_clock_type, base::kDropAmPm); 1318 time, hour_clock_type, base::kDropAmPm);
1317 icu::UnicodeString unicode; 1319 string16 timezone =
1318 chromeos::system::TimezoneSettings::GetInstance()->GetTimezone().getID( 1320 chromeos::system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID();
1319 unicode);
1320 std::string timezone;
1321 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &timezone);
1322 return_value->SetString("display_time", display_time); 1321 return_value->SetString("display_time", display_time);
1323 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time)); 1322 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time));
1324 return_value->SetString("timezone", timezone); 1323 return_value->SetString("timezone", timezone);
1325 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 1324 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
1326 } 1325 }
1327 1326
1328 void TestingAutomationProvider::GetTimeInfo(DictionaryValue* args, 1327 void TestingAutomationProvider::GetTimeInfo(DictionaryValue* args,
1329 IPC::Message* reply_message) { 1328 IPC::Message* reply_message) {
1330 GetTimeInfo(NULL, args, reply_message); 1329 GetTimeInfo(NULL, args, reply_message);
1331 } 1330 }
1332 1331
1333 void TestingAutomationProvider::SetTimezone(DictionaryValue* args, 1332 void TestingAutomationProvider::SetTimezone(DictionaryValue* args,
1334 IPC::Message* reply_message) { 1333 IPC::Message* reply_message) {
1334 AutomationJSONReply reply(this, reply_message);
1335 std::string timezone_id; 1335 std::string timezone_id;
1336 if (!args->GetString("timezone", &timezone_id)) { 1336 if (!args->GetString("timezone", &timezone_id)) {
1337 AutomationJSONReply(this, reply_message).SendError( 1337 reply.SendError("Invalid or missing args.");
1338 "Invalid or missing args.");
1339 return; 1338 return;
1340 } 1339 }
1341 1340 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
1342 icu::TimeZone* timezone = 1341 settings->SetString(chromeos::kSystemTimezone, timezone_id);
1343 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id)); 1342 reply.SendSuccess(NULL);
1344 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone);
1345 delete timezone;
1346 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
1347 } 1343 }
1348 1344
1349 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, 1345 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args,
1350 IPC::Message* reply_message) { 1346 IPC::Message* reply_message) {
1351 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); 1347 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
1352 DBusThreadManager::Get()->GetUpdateEngineClient() 1348 DBusThreadManager::Get()->GetUpdateEngineClient()
1353 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply)); 1349 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply));
1354 } 1350 }
1355 1351
1356 void TestingAutomationProvider::UpdateCheck( 1352 void TestingAutomationProvider::UpdateCheck(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 1412 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
1417 if (!audio_handler) { 1413 if (!audio_handler) {
1418 reply.SendError("AudioHandler not initialized."); 1414 reply.SendError("AudioHandler not initialized.");
1419 return; 1415 return;
1420 } 1416 }
1421 audio_handler->SetMuted(mute); 1417 audio_handler->SetMuted(mute);
1422 reply.SendSuccess(NULL); 1418 reply.SendSuccess(NULL);
1423 } 1419 }
1424 1420
1425 void TestingAutomationProvider::OpenCrosh(DictionaryValue* args, 1421 void TestingAutomationProvider::OpenCrosh(DictionaryValue* args,
1426 IPC::Message* reply_message) { 1422 IPC::Message* reply_message) {
1427 new NavigationNotificationObserver( 1423 new NavigationNotificationObserver(
1428 NULL, this, reply_message, 1, false, true); 1424 NULL, this, reply_message, 1, false, true);
1429 ash::Shell::GetInstance()->delegate()->OpenCrosh(); 1425 ash::Shell::GetInstance()->delegate()->OpenCrosh();
1430 } 1426 }
1431 1427
1432 void TestingAutomationProvider::CaptureProfilePhoto( 1428 void TestingAutomationProvider::CaptureProfilePhoto(
1433 Browser* browser, 1429 Browser* browser,
1434 DictionaryValue* args, 1430 DictionaryValue* args,
1435 IPC::Message* reply_message) { 1431 IPC::Message* reply_message) {
1436 chromeos::TakePhotoDialog* take_photo_dialog = 1432 chromeos::TakePhotoDialog* take_photo_dialog =
(...skipping 14 matching lines...) Expand all
1451 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1447 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1452 AddObserver(power_manager_observer_); 1448 AddObserver(power_manager_observer_);
1453 } 1449 }
1454 1450
1455 void TestingAutomationProvider::RemoveChromeosObservers() { 1451 void TestingAutomationProvider::RemoveChromeosObservers() {
1456 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1452 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1457 RemoveObserver(power_manager_observer_); 1453 RemoveObserver(power_manager_observer_);
1458 delete power_manager_observer_; 1454 delete power_manager_observer_;
1459 power_manager_observer_ = NULL; 1455 power_manager_observer_ = NULL;
1460 } 1456 }
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