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

Side by Side Diff: content/renderer/wake_lock_dispatcher.cc

Issue 406483004: Initial implementation of API WakeLock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
(Empty)
1 // Copyright (c) 2014 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 "content/renderer/wake_lock_dispatcher.h"
6
7 #include "content/common/wake_lock_messages.h"
8 #include "content/renderer/render_view_impl.h"
9
10 namespace content {
11
12 WakeLockDispatcher::WakeLockDispatcher(content::RenderView* render_view)
13 : RenderViewObserver(render_view),
14 blink::WebWakeLockClient() {
15 routing_id_ = render_view->GetRoutingID();
16 }
17
18 WakeLockDispatcher::~WakeLockDispatcher() {}
19
20 bool WakeLockDispatcher::OnMessageReceived(const IPC::Message& message) {
21 bool handled = true;
22 IPC_BEGIN_MESSAGE_MAP(WakeLockDispatcher, message)
23 IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_LockedSuccessful,
24 OnWakeLockCreatedSuccessful)
25 IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_LockedFailed,
26 OnWakeLockCreatedFailed)
27 IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_UnlockedSuccessful,
28 OnWakeLockUnlockedSuccessful)
29 IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_UnlockedFailed,
30 OnWakeLockUnlockedFailed)
31 IPC_MESSAGE_UNHANDLED(handled = false)
32 IPC_END_MESSAGE_MAP()
33 return handled;
34 }
35
36 void WakeLockDispatcher::requestWakeLock() {
37 Send(new WakeLockScreenViewHostMsg_RequestLock(routing_id_));
38 }
39
40 void WakeLockDispatcher::requestWakeUnlock() {
41 Send(new WakeLockScreenViewHostMsg_RequestUnlock(routing_id_));
42 }
43
44 void WakeLockDispatcher::OnWakeLockCreatedSuccessful() {
45 controller_->onCreatedWakeLockScreenSuccessful();
46 }
47
48 void WakeLockDispatcher::OnWakeLockCreatedFailed() {
49 controller_->onCreatedWakeLockScreenFailed();
50 }
51
52 void WakeLockDispatcher::OnWakeLockUnlockedSuccessful() {
53 controller_->onUnlockedWakeLockScreenSuccessful();
54 }
55
56 void WakeLockDispatcher::OnWakeLockUnlockedFailed() {
57 controller_->onUnlockedWakeLockScreenFailed();
58 }
59
60 void WakeLockDispatcher::wakeLockDestroyed() {
61 controller_.reset();
62 }
63
64 void WakeLockDispatcher::setController(
65 blink::WebWakeLockController* controller) {
66 controller_.reset(controller);
67 }
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698