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.
5 #include "extensions/browser/api/power/power_api.h"
7 #include "extensions/browser/api/power/power_api_manager.h"
8 #include "extensions/common/api/power.h"
10 namespace extensions
{
12 bool 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
);
22 bool PowerReleaseKeepAwakeFunction::RunSync() {
23 PowerApiManager::Get(browser_context())->RemoveRequest(extension_id());
27 } // namespace extensions