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

Side by Side Diff: chrome/browser/chromeos/dbus/display_power_service_provider.cc

Issue 12391004: chromeos: Add DisplayPowerServiceProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/dbus/display_power_service_provider.h"
6
7 #include "ash/shell.h"
8 #include "ash/wm/user_activity_detector.h"
9 #include "base/bind.h"
10 #include "chromeos/display/output_configurator.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "dbus/bus.h"
13 #include "dbus/message.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h"
15
16 using content::BrowserThread;
17
18 namespace chromeos {
19
20 DisplayPowerServiceProvider::DisplayPowerServiceProvider()
21 : weak_ptr_factory_(this) {
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
23 }
24
25 DisplayPowerServiceProvider::~DisplayPowerServiceProvider() {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 }
28
29 void DisplayPowerServiceProvider::Start(
30 scoped_refptr<dbus::ExportedObject> exported_object) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 exported_object->ExportMethod(
33 kLibCrosServiceInterface,
34 kSetDisplayPower,
35 base::Bind(&DisplayPowerServiceProvider::SetDisplayPower,
36 weak_ptr_factory_.GetWeakPtr()),
37 base::Bind(&DisplayPowerServiceProvider::OnExported,
38 weak_ptr_factory_.GetWeakPtr()));
39 }
40
41 void DisplayPowerServiceProvider::OnExported(const std::string& interface_name,
42 const std::string& method_name,
43 bool success) {
44 if (!success) {
45 LOG(ERROR) << "Failed to export " << interface_name << "."
46 << method_name;
47 }
48 }
49
50 void DisplayPowerServiceProvider::SetDisplayPower(
51 dbus::MethodCall* method_call,
52 dbus::ExportedObject::ResponseSender response_sender) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
54
55 dbus::MessageReader reader(method_call);
56 int int_state = 0;
57 if (reader.PopInt32(&int_state)) {
58 DisplayPowerState state = static_cast<DisplayPowerState>(int_state);
59 if (state == DISPLAY_POWER_ALL_OFF) {
60 // All displays are turned off when the device becomes idle, which
61 // may trigger a mouse move. Let the UserActivityDetector know so
62 // that it can ignore such events.
marcheu 2013/02/28 04:58:59 So I think this applies to all root window resizes
Daniel Erat 2013/02/28 18:13:13 Probably; I was just copying over the existing log
63 ash::Shell::GetInstance()->user_activity_detector()->
64 OnAllOutputsTurnedOff();
65 }
66 ash::Shell::GetInstance()->output_configurator()->SetDisplayPowerState(
67 state);
68 } else {
69 LOG(ERROR) << "Unable to parse " << kSetDisplayPower << " request";
70 }
71
72 response_sender.Run(dbus::Response::FromMethodCall(method_call));
73 }
74
75 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698