| Index: content/renderer/wake_lock_dispatcher.cc
|
| diff --git a/content/renderer/wake_lock_dispatcher.cc b/content/renderer/wake_lock_dispatcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..90f4b9caec81747cafc8ad34bc49ae9410999686
|
| --- /dev/null
|
| +++ b/content/renderer/wake_lock_dispatcher.cc
|
| @@ -0,0 +1,68 @@
|
| +// Copyright (c) 2014 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 "content/renderer/wake_lock_dispatcher.h"
|
| +
|
| +#include "content/common/wake_lock_messages.h"
|
| +#include "content/renderer/render_view_impl.h"
|
| +
|
| +namespace content {
|
| +
|
| +WakeLockDispatcher::WakeLockDispatcher(content::RenderView* render_view)
|
| + : RenderViewObserver(render_view),
|
| + blink::WebWakeLockClient() {
|
| + routing_id_ = render_view->GetRoutingID();
|
| +}
|
| +
|
| +WakeLockDispatcher::~WakeLockDispatcher() {}
|
| +
|
| +bool WakeLockDispatcher::OnMessageReceived(const IPC::Message& message) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(WakeLockDispatcher, message)
|
| + IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_LockedSuccessful,
|
| + OnWakeLockCreatedSuccessful)
|
| + IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_LockedFailed,
|
| + OnWakeLockCreatedFailed)
|
| + IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_UnlockedSuccessful,
|
| + OnWakeLockUnlockedSuccessful)
|
| + IPC_MESSAGE_HANDLER(WakeLockScreenViewMsg_UnlockedFailed,
|
| + OnWakeLockUnlockedFailed)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +void WakeLockDispatcher::requestWakeLock() {
|
| + Send(new WakeLockScreenViewHostMsg_RequestLock(routing_id_));
|
| +}
|
| +
|
| +void WakeLockDispatcher::requestWakeUnlock() {
|
| + Send(new WakeLockScreenViewHostMsg_RequestUnlock(routing_id_));
|
| +}
|
| +
|
| +void WakeLockDispatcher::OnWakeLockCreatedSuccessful() {
|
| + controller_->onCreatedWakeLockScreenSuccessful();
|
| +}
|
| +
|
| +void WakeLockDispatcher::OnWakeLockCreatedFailed() {
|
| + controller_->onCreatedWakeLockScreenFailed();
|
| +}
|
| +
|
| +void WakeLockDispatcher::OnWakeLockUnlockedSuccessful() {
|
| + controller_->onUnlockedWakeLockScreenSuccessful();
|
| +}
|
| +
|
| +void WakeLockDispatcher::OnWakeLockUnlockedFailed() {
|
| + controller_->onUnlockedWakeLockScreenFailed();
|
| +}
|
| +
|
| +void WakeLockDispatcher::wakeLockDestroyed() {
|
| + controller_.reset();
|
| +}
|
| +
|
| +void WakeLockDispatcher::setController(
|
| + blink::WebWakeLockController* controller) {
|
| + controller_.reset(controller);
|
| +}
|
| +}
|
|
|