Home | History | Annotate | Download | only in power
      1 // Copyright (c) 2013 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 "chrome/browser/extensions/api/power/power_api.h"
      6 
      7 #include "chrome/browser/extensions/api/power/power_api_manager.h"
      8 #include "chrome/common/extensions/api/power.h"
      9 
     10 namespace extensions {
     11 
     12 bool PowerRequestKeepAwakeFunction::RunImpl() {
     13   scoped_ptr<api::power::RequestKeepAwake::Params> params(
     14       api::power::RequestKeepAwake::Params::Create(*args_));
     15   EXTENSION_FUNCTION_VALIDATE(params);
     16   EXTENSION_FUNCTION_VALIDATE(params->level != api::power::LEVEL_NONE);
     17   PowerApiManager::GetInstance()->AddRequest(extension_id(), params->level);
     18   return true;
     19 }
     20 
     21 bool PowerReleaseKeepAwakeFunction::RunImpl() {
     22   PowerApiManager::GetInstance()->RemoveRequest(extension_id());
     23   return true;
     24 }
     25 
     26 }  // namespace extensions
     27