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

Unified Diff: chrome/browser/extensions/api/system_display/system_display_api.cc

Issue 23441032: [SystemInfo API] Rewrite DisplayInfoProvider without SystemInfoProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing head file Created 7 years, 3 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_display/system_display_api.cc
diff --git a/chrome/browser/extensions/api/system_display/system_display_api.cc b/chrome/browser/extensions/api/system_display/system_display_api.cc
index 36dd2f26e73fc2a75e368ff3af643be94b34c923..ec9d253f2359a31bf6cf2732ffd63294787e7f43 100644
--- a/chrome/browser/extensions/api/system_display/system_display_api.cc
+++ b/chrome/browser/extensions/api/system_display/system_display_api.cc
@@ -4,8 +4,15 @@
#include "chrome/browser/extensions/api/system_display/system_display_api.h"
+#include <string>
+
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/extensions/api/system_display/display_info_provider.h"
+#include "chrome/common/extensions/api/system_display.h"
#include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/screen.h"
namespace extensions {
@@ -13,25 +20,17 @@ using api::system_display::DisplayUnitInfo;
namespace SetDisplayProperties = api::system_display::SetDisplayProperties;
+typedef std::vector<linked_ptr<
+ api::system_display::DisplayUnitInfo> > DisplayInfo;
+
bool SystemDisplayGetInfoFunction::RunImpl() {
- DisplayInfoProvider::Get()->RequestInfo(
- base::Bind(
- &SystemDisplayGetInfoFunction::OnGetDisplayInfoCompleted,
- this));
+ DisplayInfo all_displays_info =
+ DisplayInfoProvider::Get()->GetAllDisplaysInfo();
+ results_ = api::system_display::GetInfo::Results::Create(all_displays_info);
+ SendResponse(true);
return true;
}
-void SystemDisplayGetInfoFunction::OnGetDisplayInfoCompleted(
- bool success) {
- if (success) {
- results_ = api::system_display::GetInfo::Results::Create(
- DisplayInfoProvider::Get()->display_info());
- } else {
- SetError("Error occurred when querying display information.");
- }
- SendResponse(success);
-}
-
bool SystemDisplaySetDisplayPropertiesFunction::RunImpl() {
#if !defined(OS_CHROMEOS)
SetError("Function available only on ChromeOS.");
@@ -41,22 +40,17 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunImpl() {
SetError("The extension needs to be kiosk enabled to use the function.");
return false;
}
-
+ std::string error;
scoped_ptr<SetDisplayProperties::Params> params(
SetDisplayProperties::Params::Create(*args_));
- DisplayInfoProvider::Get()->SetInfo(params->id, params->info,
- base::Bind(
- &SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet,
- this));
- return true;
-#endif
-}
-
-void SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet(
- bool success, const std::string& error) {
+ bool success = DisplayInfoProvider::Get()->SetInfo(params->id,
+ params->info,
+ &error);
if (!success)
SetError(error);
SendResponse(success);
+ return true;
+#endif
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698