12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 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) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/api/power/power_api.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/api/power/power_api_manager.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/common/extensions/api/power.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace extensions { 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liubool PowerRequestKeepAwakeFunction::RunSync() { 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<api::power::RequestKeepAwake::Params> params( 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) api::power::RequestKeepAwake::Params::Create(*args_)); 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXTENSION_FUNCTION_VALIDATE(params); 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXTENSION_FUNCTION_VALIDATE(params->level != 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