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