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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/system_info_display/system_info_display_api.cc
diff --git a/chrome/browser/extensions/api/system_info_display/system_info_display_api.cc b/chrome/browser/extensions/api/system_info_display/system_info_display_api.cc
index d8388fb131899c2d49e4d092bc2dccd3dd62e78a..2c20e673ab953d0f86339525f03555226f13db50 100644
--- a/chrome/browser/extensions/api/system_info_display/system_info_display_api.cc
+++ b/chrome/browser/extensions/api/system_info_display/system_info_display_api.cc
@@ -4,10 +4,15 @@
#include "chrome/browser/extensions/api/system_info_display/system_info_display_api.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h"
+
namespace extensions {
using api::system_info_display::DisplayUnitInfo;
+namespace SetDisplayProperties = api::system_info_display::SetDisplayProperties;
+
bool SystemInfoDisplayGetDisplayInfoFunction::RunImpl() {
DisplayInfoProvider::GetProvider()->RequestInfo(
base::Bind(
@@ -18,10 +23,38 @@ bool SystemInfoDisplayGetDisplayInfoFunction::RunImpl() {
void SystemInfoDisplayGetDisplayInfoFunction::OnGetDisplayInfoCompleted(
const DisplayInfo& info, bool success) {
- if (success)
+ if (success) {
results_ = api::system_info_display::GetDisplayInfo::Results::Create(info);
- else
+ } else {
SetError("Error occurred when querying display information.");
+ }
+ SendResponse(success);
+}
+
+bool SystemInfoDisplaySetDisplayPropertiesFunction::RunImpl() {
+#if !defined(OS_CHROMEOS)
+ SetError("Function available only on ChromeOS.");
+ return false;
+#else
+ if (!KioskEnabledInfo::IsKioskEnabled(GetExtension())) {
+ SetError("The extension needs to be kiosk enabled to use the function.");
+ return false;
+ }
+
+ scoped_ptr<SetDisplayProperties::Params> params(
+ SetDisplayProperties::Params::Create(*args_));
+ DisplayInfoProvider::GetProvider()->SetInfo(params->id, params->info,
+ base::Bind(
+ &SystemInfoDisplaySetDisplayPropertiesFunction::OnPropertiesSet,
+ this));
+ return true;
+#endif
+}
+
+void SystemInfoDisplaySetDisplayPropertiesFunction::OnPropertiesSet(
+ bool success, const std::string& error) {
+ if (!success)
+ SetError(error);
SendResponse(success);
}

Powered by Google App Engine
This is Rietveld 408576698