1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/automation/testing_automation_provider.h"
#include "ash/new_window_delegate.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "base/prefs/pref_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/automation/automation_provider_json.h"
#include "chrome/browser/automation/automation_provider_observers.h"
#include "chrome/browser/automation/automation_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/login/default_user_images.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/login_display.h"
#include "chrome/browser/chromeos/login/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/screens/eula_screen.h"
#include "chrome/browser/chromeos/login/screens/network_screen.h"
#include "chrome/browser/chromeos/login/screens/update_screen.h"
#include "chrome/browser/chromeos/login/screens/user_image_screen.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/net/proxy_config_handler.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/common/pref_names.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/dbus/update_engine_client.h"
#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/settings/timezone_settings.h"
#include "content/public/browser/web_contents.h"
#include "policy/policy_constants.h"
#include "ui/views/widget/widget.h"
using chromeos::DBusThreadManager;
using chromeos::ExistingUserController;
using chromeos::UpdateEngineClient;
using chromeos::User;
using chromeos::UserManager;
using chromeos::WizardController;
namespace {
void UpdateCheckCallback(AutomationJSONReply* reply,
UpdateEngineClient::UpdateCheckResult result) {
if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS)
reply->SendSuccess(NULL);
else
reply->SendError("update check failed");
delete reply;
}
} // namespace
#if defined(OS_CHROMEOS)
void TestingAutomationProvider::PowerChanged(
const power_manager::PowerSupplyProperties& proto) {
power_supply_properties_ = proto;
}
#endif
void TestingAutomationProvider::AcceptOOBENetworkScreen(
base::DictionaryValue* args,
IPC::Message* reply_message) {
WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller || wizard_controller->current_screen()->GetName() !=
WizardController::kNetworkScreenName) {
AutomationJSONReply(this, reply_message).SendError(
"Network screen not active.");
return;
}
// Observer will delete itself.
new WizardControllerObserver(wizard_controller, this, reply_message);
wizard_controller->GetNetworkScreen()->OnContinuePressed();
}
void TestingAutomationProvider::AcceptOOBEEula(base::DictionaryValue* args,
IPC::Message* reply_message) {
bool accepted;
bool usage_stats_reporting;
if (!args->GetBoolean("accepted", &accepted) ||
!args->GetBoolean("usage_stats_reporting", &usage_stats_reporting)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args.");
return;
}
WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller || wizard_controller->current_screen()->GetName() !=
WizardController::kEulaScreenName) {
AutomationJSONReply(this, reply_message).SendError(
"EULA screen not active.");
return;
}
// Observer will delete itself.
new WizardControllerObserver(wizard_controller, this, reply_message);
wizard_controller->GetEulaScreen()->OnExit(accepted, usage_stats_reporting);
}
void TestingAutomationProvider::CancelOOBEUpdate(base::DictionaryValue* args,
IPC::Message* reply_message) {
if (chromeos::StartupUtils::IsOobeCompleted()) {
// Update already finished.
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
return_value->SetString("next_screen",
WizardController::kLoginScreenName);
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
return;
}
WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller || wizard_controller->current_screen()->GetName() !=
WizardController::kUpdateScreenName) {
AutomationJSONReply(this, reply_message).SendError(
"Update screen not active.");
return;
}
// Observer will delete itself.
new WizardControllerObserver(wizard_controller, this, reply_message);
wizard_controller->GetUpdateScreen()->CancelUpdate();
}
void TestingAutomationProvider::GetLoginInfo(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
const UserManager* user_manager = UserManager::Get();
if (!user_manager)
reply.SendError("No user manager!");
const chromeos::ScreenLocker* screen_locker =
chromeos::ScreenLocker::default_screen_locker();
return_value->SetString("login_ui_type", "webui");
return_value->SetBoolean("is_owner", user_manager->IsCurrentUserOwner());
return_value->SetBoolean("is_logged_in", user_manager->IsUserLoggedIn());
return_value->SetBoolean("is_screen_locked", screen_locker);
if (user_manager->IsUserLoggedIn()) {
const User* user = user_manager->GetLoggedInUser();
return_value->SetBoolean("is_guest", user_manager->IsLoggedInAsGuest());
return_value->SetString("email", user->email());
return_value->SetString("display_email", user->display_email());
switch (user->image_index()) {
case User::kExternalImageIndex:
return_value->SetString("user_image", "file");
break;
case User::kProfileImageIndex:
return_value->SetString("user_image", "profile");
break;
default:
return_value->SetInteger("user_image", user->image_index());
break;
}
}
reply.SendSuccess(return_value.get());
}
// See the note under LoginAsGuest(). CreateAccount() causes a login as guest.
void TestingAutomationProvider::ShowCreateAccountUI(
base::DictionaryValue* args, IPC::Message* reply_message) {
ExistingUserController* controller =
ExistingUserController::current_controller();
// Return immediately, since we're going to die before the login is finished.
AutomationJSONReply(this, reply_message).SendSuccess(NULL);
controller->CreateAccount();
}
// Logging in as guest will cause session_manager to restart Chrome with new
// flags. If you used EnableChromeTesting, you will have to call it again.
void TestingAutomationProvider::LoginAsGuest(base::DictionaryValue* args,
IPC::Message* reply_message) {
ExistingUserController* controller =
ExistingUserController::current_controller();
// Return immediately, since we're going to die before the login is finished.
AutomationJSONReply(this, reply_message).SendSuccess(NULL);
controller->LoginAsGuest();
}
void TestingAutomationProvider::SubmitLoginForm(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
std::string username, password;
if (!args->GetString("username", &username) ||
!args->GetString("password", &password)) {
reply.SendError("Invalid or missing args.");
return;
}
chromeos::ExistingUserController* controller =
chromeos::ExistingUserController::current_controller();
if (!controller) {
reply.SendError("Unable to access ExistingUserController");
return;
}
// WebUI login.
chromeos::WebUILoginDisplay* webui_login_display =
static_cast<chromeos::WebUILoginDisplay*>(controller->login_display());
VLOG(2) << "TestingAutomationProvider::SubmitLoginForm "
<< "ShowSigninScreenForCreds(" << username << ", " << password << ")";
webui_login_display->ShowSigninScreenForCreds(username, password);
reply.SendSuccess(NULL);
}
void TestingAutomationProvider::AddLoginEventObserver(
base::DictionaryValue* args, IPC::Message* reply_message) {
ExistingUserController* controller =
ExistingUserController::current_controller();
AutomationJSONReply reply(this, reply_message);
if (!controller) {
// This may happen due to SkipToLogin not being called.
reply.SendError("Unable to access ExistingUserController");
return;
}
if (!automation_event_queue_.get())
automation_event_queue_.reset(new AutomationEventQueue);
int observer_id = automation_event_queue_->AddObserver(
new LoginEventObserver(automation_event_queue_.get(), this));
// Return the observer's id.
base::DictionaryValue return_value;
return_value.SetInteger("observer_id", observer_id);
reply.SendSuccess(&return_value);
}
void TestingAutomationProvider::SignOut(base::DictionaryValue* args,
IPC::Message* reply_message) {
ash::Shell::GetInstance()->system_tray_delegate()->SignOut();
// Sign out has the side effect of restarting the session_manager
// and chrome, thereby severing the automation channel, so it's
// not really necessary to send a reply back. The next line is
// for consistency with other methods.
AutomationJSONReply(this, reply_message).SendSuccess(NULL);
}
void TestingAutomationProvider::PickUserImage(base::DictionaryValue* args,
IPC::Message* reply_message) {
std::string image_type;
int image_number = -1;
if (!args->GetString("image", &image_type)
&& !args->GetInteger("image", &image_number)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args.");
return;
}
WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller || wizard_controller->current_screen()->GetName() !=
WizardController::kUserImageScreenName) {
AutomationJSONReply(this, reply_message).SendError(
"User image screen not active.");
return;
}
chromeos::UserImageScreen* image_screen =
wizard_controller->GetUserImageScreen();
// Observer will delete itself unless error is returned.
WizardControllerObserver* observer =
new WizardControllerObserver(wizard_controller, this, reply_message);
if (image_type == "profile") {
image_screen->OnImageSelected("", image_type, true);
image_screen->OnImageAccepted();
} else if (image_type.empty() && image_number >= 0 &&
image_number < chromeos::kDefaultImagesCount) {
image_screen->OnImageSelected(
chromeos::GetDefaultImageUrl(image_number), image_type, true);
image_screen->OnImageAccepted();
} else {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args.");
delete observer;
return;
}
}
void TestingAutomationProvider::SkipToLogin(base::DictionaryValue* args,
IPC::Message* reply_message) {
bool skip_post_login_screens;
// The argument name is a legacy. If set to |true|, this argument causes any
// screens that may otherwise be shown after login (registration, Terms of
// Service, user image selection) to be skipped.
if (!args->GetBoolean("skip_image_selection", &skip_post_login_screens)) {
AutomationJSONReply reply(this, reply_message);
reply.SendError("Invalid or missing args.");
return;
}
if (skip_post_login_screens)
WizardController::SkipPostLoginScreensForTesting();
WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller) {
AutomationJSONReply reply(this, reply_message);
if (ExistingUserController::current_controller()) {
// Already at login screen.
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
return_value->SetString("next_screen",
WizardController::kLoginScreenName);
reply.SendSuccess(return_value.get());
} else {
reply.SendError("OOBE not active.");
}
return;
}
// Observer will delete itself.
WizardControllerObserver* observer =
new WizardControllerObserver(wizard_controller, this, reply_message);
observer->set_screen_to_wait_for(WizardController::kLoginScreenName);
wizard_controller->SkipToLoginForTesting(chromeos::LoginScreenContext());
}
void TestingAutomationProvider::GetOOBEScreenInfo(base::DictionaryValue* args,
IPC::Message* reply_message) {
static const char kScreenNameKey[] = "screen_name";
AutomationJSONReply reply(this, reply_message);
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
WizardController* wizard_controller = WizardController::default_controller();
if (wizard_controller) {
if (wizard_controller->login_screen_started()) {
return_value->SetString(kScreenNameKey,
WizardController::kLoginScreenName);
} else {
return_value->SetString(kScreenNameKey,
wizard_controller->current_screen()->GetName());
}
} else if (ExistingUserController::current_controller()) {
return_value->SetString(kScreenNameKey, WizardController::kLoginScreenName);
} else {
// Already logged in.
reply.SendSuccess(NULL);
return;
}
reply.SendSuccess(return_value.get());
}
void TestingAutomationProvider::LockScreen(base::DictionaryValue* args,
IPC::Message* reply_message) {
new ScreenLockUnlockObserver(this, reply_message, true);
DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
}
void TestingAutomationProvider::UnlockScreen(base::DictionaryValue* args,
IPC::Message* reply_message) {
std::string password;
if (!args->GetString("password", &password)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args.");
return;
}
chromeos::ScreenLocker* screen_locker =
chromeos::ScreenLocker::default_screen_locker();
if (!screen_locker) {
AutomationJSONReply(this, reply_message).SendError(
"No default screen locker. Are you sure the screen is locked?");
return;
}
new ScreenUnlockObserver(this, reply_message);
screen_locker->AuthenticateByPassword(password);
}
// Signing out could have undesirable side effects: session_manager is
// killed, so its children, including chrome and the window manager, will
// also be killed. Anything owned by chronos will probably be killed.
void TestingAutomationProvider::SignoutInScreenLocker(
base::DictionaryValue* args, IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
chromeos::ScreenLocker* screen_locker =
chromeos::ScreenLocker::default_screen_locker();
if (!screen_locker) {
reply.SendError(
"No default screen locker. Are you sure the screen is locked?");
return;
}
// Send success before stopping session because if we're a child of
// session manager then we'll die when the session is stopped.
reply.SendSuccess(NULL);
screen_locker->Signout();
}
void TestingAutomationProvider::GetBatteryInfo(base::DictionaryValue* args,
IPC::Message* reply_message) {
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
const bool battery_is_present = power_supply_properties_.battery_state() !=
power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT;
const bool line_power_on = power_supply_properties_.external_power() !=
power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED;
return_value->SetBoolean("battery_is_present", battery_is_present);
return_value->SetBoolean("line_power_on", line_power_on);
if (battery_is_present) {
const bool battery_is_full = power_supply_properties_.battery_state() ==
power_manager::PowerSupplyProperties_BatteryState_FULL;
return_value->SetBoolean("battery_fully_charged", battery_is_full);
return_value->SetDouble("battery_percentage",
power_supply_properties_.battery_percent());
if (line_power_on) {
int64 time = power_supply_properties_.battery_time_to_full_sec();
if (time > 0 || battery_is_full)
return_value->SetInteger("battery_seconds_to_full", time);
} else {
int64 time = power_supply_properties_.battery_time_to_empty_sec();
if (time > 0)
return_value->SetInteger("battery_seconds_to_empty", time);
}
}
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
}
void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI(
base::DictionaryValue* args, IPC::Message* reply_message) {
std::string javascript, frame_xpath;
if (!args->GetString("javascript", &javascript)) {
AutomationJSONReply(this, reply_message)
.SendError("'javascript' missing or invalid");
return;
}
if (!args->GetString("frame_xpath", &frame_xpath)) {
AutomationJSONReply(this, reply_message)
.SendError("'frame_xpath' missing or invalid");
return;
}
const UserManager* user_manager = UserManager::Get();
if (!user_manager) {
AutomationJSONReply(this, reply_message).SendError(
"No user manager!");
return;
}
if (user_manager->IsUserLoggedIn()) {
AutomationJSONReply(this, reply_message).SendError(
"User is already logged in.");
return;
}
ExistingUserController* controller =
ExistingUserController::current_controller();
if (!controller) {
AutomationJSONReply(this, reply_message).SendError(
"Unable to access ExistingUserController");
return;
}
chromeos::LoginDisplayHostImpl* webui_host =
static_cast<chromeos::LoginDisplayHostImpl*>(
controller->login_display_host());
content::WebContents* web_contents =
webui_host->GetOobeUI()->web_ui()->GetWebContents();
new DomOperationMessageSender(this, reply_message, true);
ExecuteJavascriptInRenderViewFrame(base::ASCIIToUTF16(frame_xpath),
base::ASCIIToUTF16(javascript),
reply_message,
web_contents->GetRenderViewHost());
}
void TestingAutomationProvider::EnableSpokenFeedback(
base::DictionaryValue* args, IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
bool enabled;
if (!args->GetBoolean("enabled", &enabled)) {
reply.SendError("Invalid or missing args.");
return;
}
chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(
enabled, ash::A11Y_NOTIFICATION_NONE);
reply.SendSuccess(return_value.get());
}
void TestingAutomationProvider::IsSpokenFeedbackEnabled(
base::DictionaryValue* args, IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
return_value->SetBoolean(
"spoken_feedback",
chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
reply.SendSuccess(return_value.get());
}
void TestingAutomationProvider::GetTimeInfo(Browser* browser,
base::DictionaryValue* args,
IPC::Message* reply_message) {
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
base::Time time(base::Time::Now());
bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean(
prefs::kUse24HourClock);
base::HourClockType hour_clock_type =
use_24hour_clock ? base::k24HourClock : base::k12HourClock;
base::string16 display_time = base::TimeFormatTimeOfDayWithHourClockType(
time, hour_clock_type, base::kDropAmPm);
base::string16 timezone =
chromeos::system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID();
return_value->SetString("display_time", display_time);
return_value->SetString("display_date", base::TimeFormatFriendlyDate(time));
return_value->SetString("timezone", timezone);
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
}
void TestingAutomationProvider::GetTimeInfo(base::DictionaryValue* args,
IPC::Message* reply_message) {
GetTimeInfo(NULL, args, reply_message);
}
void TestingAutomationProvider::SetTimezone(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
std::string timezone_id;
if (!args->GetString("timezone", &timezone_id)) {
reply.SendError("Invalid or missing args.");
return;
}
chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
settings->SetString(chromeos::kSystemTimezone, timezone_id);
reply.SendSuccess(NULL);
}
void TestingAutomationProvider::UpdateCheck(
base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
DBusThreadManager::Get()->GetUpdateEngineClient()
->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply));
}
void TestingAutomationProvider::GetVolumeInfo(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
if (!audio_handler) {
reply.SendError("CrasAudioHandler not initialized.");
return;
}
return_value->SetDouble("volume", audio_handler->GetOutputVolumePercent());
return_value->SetBoolean("is_mute", audio_handler->IsOutputMuted());
reply.SendSuccess(return_value.get());
}
void TestingAutomationProvider::SetVolume(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
double volume_percent;
if (!args->GetDouble("volume", &volume_percent)) {
reply.SendError("Invalid or missing args.");
return;
}
chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
if (!audio_handler) {
reply.SendError("CrasAudioHandler not initialized.");
return;
}
audio_handler->SetOutputVolumePercent(volume_percent);
reply.SendSuccess(NULL);
}
void TestingAutomationProvider::SetMute(base::DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
bool mute;
if (!args->GetBoolean("mute", &mute)) {
reply.SendError("Invalid or missing args.");
return;
}
chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
if (!audio_handler) {
reply.SendError("CrasAudioHandler not initialized.");
return;
}
audio_handler->SetOutputMute(mute);
reply.SendSuccess(NULL);
}
void TestingAutomationProvider::OpenCrosh(base::DictionaryValue* args,
IPC::Message* reply_message) {
new NavigationNotificationObserver(
NULL, this, reply_message, 1, false, true);
ash::Shell::GetInstance()->new_window_delegate()->OpenCrosh();
}
void TestingAutomationProvider::AddChromeosObservers() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
AddObserver(this);
}
void TestingAutomationProvider::RemoveChromeosObservers() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
RemoveObserver(this);
}
|