Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Side by Side Diff: chrome/browser/extensions/api/system_info_display/system_info_display_api.cc

Issue 16817006: Add ability to change display settings to chrome.systemInfo.display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win compile Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/system_info_display/system_info_display_ api.h" 5 #include "chrome/browser/extensions/api/system_info_display/system_info_display_ api.h"
6 6
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h"
9
7 namespace extensions { 10 namespace extensions {
8 11
9 using api::system_info_display::DisplayUnitInfo; 12 using api::system_info_display::DisplayUnitInfo;
10 13
14 namespace SetDisplayProperties = api::system_info_display::SetDisplayProperties;
15
11 bool SystemInfoDisplayGetDisplayInfoFunction::RunImpl() { 16 bool SystemInfoDisplayGetDisplayInfoFunction::RunImpl() {
12 DisplayInfoProvider::GetProvider()->RequestInfo( 17 DisplayInfoProvider::GetProvider()->RequestInfo(
13 base::Bind( 18 base::Bind(
14 &SystemInfoDisplayGetDisplayInfoFunction::OnGetDisplayInfoCompleted, 19 &SystemInfoDisplayGetDisplayInfoFunction::OnGetDisplayInfoCompleted,
15 this)); 20 this));
16 return true; 21 return true;
17 } 22 }
18 23
19 void SystemInfoDisplayGetDisplayInfoFunction::OnGetDisplayInfoCompleted( 24 void SystemInfoDisplayGetDisplayInfoFunction::OnGetDisplayInfoCompleted(
20 const DisplayInfo& info, bool success) { 25 const DisplayInfo& info, bool success) {
21 if (success) 26 if (success) {
22 results_ = api::system_info_display::GetDisplayInfo::Results::Create(info); 27 results_ = api::system_info_display::GetDisplayInfo::Results::Create(info);
23 else 28 } else {
24 SetError("Error occurred when querying display information."); 29 SetError("Error occurred when querying display information.");
30 }
25 SendResponse(success); 31 SendResponse(success);
26 } 32 }
27 33
34 bool SystemInfoDisplaySetDisplayPropertiesFunction::RunImpl() {
35 #if !defined(OS_CHROMEOS)
36 SetError("Function available only on ChromeOS.");
37 return false;
38 #else
39 if (!KioskEnabledInfo::IsKioskEnabled(GetExtension())) {
40 SetError("The extension needs to be kiosk enabled to use the function.");
41 return false;
42 }
43
44 scoped_ptr<SetDisplayProperties::Params> params(
45 SetDisplayProperties::Params::Create(*args_));
46 DisplayInfoProvider::GetProvider()->SetInfo(params->id, params->info,
47 base::Bind(
48 &SystemInfoDisplaySetDisplayPropertiesFunction::OnPropertiesSet,
49 this));
50 return true;
51 #endif
52 }
53
54 void SystemInfoDisplaySetDisplayPropertiesFunction::OnPropertiesSet(
55 bool success, const std::string& error) {
56 if (!success)
57 SetError(error);
58 SendResponse(success);
59 }
60
28 } // namespace extensions 61 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698