| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/api/system_display/system_display_api.h" | 5 #include "extensions/browser/api/system_display/system_display_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "extensions/browser/api/system_display/display_info_provider.h" | 9 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 10 #include "extensions/common/api/system_display.h" | 10 #include "extensions/common/api/system_display.h" |
| 11 | 11 |
| 12 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 14 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
| 15 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 using core_api::system_display::DisplayUnitInfo; | 20 using api::system_display::DisplayUnitInfo; |
| 21 | 21 |
| 22 namespace SetDisplayProperties = core_api::system_display::SetDisplayProperties; | 22 namespace SetDisplayProperties = api::system_display::SetDisplayProperties; |
| 23 | 23 |
| 24 typedef std::vector<linked_ptr<core_api::system_display::DisplayUnitInfo> > | 24 typedef std::vector<linked_ptr<api::system_display::DisplayUnitInfo>> |
| 25 DisplayInfo; | 25 DisplayInfo; |
| 26 | 26 |
| 27 bool SystemDisplayGetInfoFunction::RunSync() { | 27 bool SystemDisplayGetInfoFunction::RunSync() { |
| 28 DisplayInfo all_displays_info = | 28 DisplayInfo all_displays_info = |
| 29 DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 29 DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 30 results_ = | 30 results_ = api::system_display::GetInfo::Results::Create(all_displays_info); |
| 31 core_api::system_display::GetInfo::Results::Create(all_displays_info); | |
| 32 return true; | 31 return true; |
| 33 } | 32 } |
| 34 | 33 |
| 35 bool SystemDisplaySetDisplayPropertiesFunction::RunSync() { | 34 bool SystemDisplaySetDisplayPropertiesFunction::RunSync() { |
| 36 #if !defined(OS_CHROMEOS) | 35 #if !defined(OS_CHROMEOS) |
| 37 SetError("Function available only on ChromeOS."); | 36 SetError("Function available only on ChromeOS."); |
| 38 return false; | 37 return false; |
| 39 #else | 38 #else |
| 40 if (!KioskModeInfo::IsKioskEnabled(extension())) { | 39 if (!KioskModeInfo::IsKioskEnabled(extension())) { |
| 41 SetError("The extension needs to be kiosk enabled to use the function."); | 40 SetError("The extension needs to be kiosk enabled to use the function."); |
| 42 return false; | 41 return false; |
| 43 } | 42 } |
| 44 std::string error; | 43 std::string error; |
| 45 scoped_ptr<SetDisplayProperties::Params> params( | 44 scoped_ptr<SetDisplayProperties::Params> params( |
| 46 SetDisplayProperties::Params::Create(*args_)); | 45 SetDisplayProperties::Params::Create(*args_)); |
| 47 bool success = | 46 bool success = |
| 48 DisplayInfoProvider::Get()->SetInfo(params->id, params->info, &error); | 47 DisplayInfoProvider::Get()->SetInfo(params->id, params->info, &error); |
| 49 if (!success) | 48 if (!success) |
| 50 SetError(error); | 49 SetError(error); |
| 51 return true; | 50 return true; |
| 52 #endif | 51 #endif |
| 53 } | 52 } |
| 54 | 53 |
| 55 } // namespace extensions | 54 } // namespace extensions |
| OLD | NEW |