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) 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool PowerRequestKeepAwakeFunction::RunImpl() { 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); 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PowerApiManager::GetInstance()->AddRequest(extension_id(), params->level); 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return true; 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool PowerReleaseKeepAwakeFunction::RunImpl() { 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PowerApiManager::GetInstance()->RemoveRequest(extension_id()); 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return true; 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace extensions 27