1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "extensions/browser/api/power/power_api.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "extensions/browser/api/power/power_api_manager.h"
8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "extensions/common/api/power.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace extensions {
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liubool PowerRequestKeepAwakeFunction::RunSync() {
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  scoped_ptr<core_api::power::RequestKeepAwake::Params> params(
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      core_api::power::RequestKeepAwake::Params::Create(*args_));
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXTENSION_FUNCTION_VALIDATE(params);
16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  EXTENSION_FUNCTION_VALIDATE(params->level != core_api::power::LEVEL_NONE);
17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  PowerApiManager::Get(browser_context())->AddRequest(
18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      extension_id(), params->level);
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return true;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liubool PowerReleaseKeepAwakeFunction::RunSync() {
23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  PowerApiManager::Get(browser_context())->RemoveRequest(extension_id());
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return true;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace extensions
28