| 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 "chrome/browser/extensions/api/system_display/system_display_api.h" | 5 #include "chrome/browser/extensions/api/system_display/system_display_api.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h" | 8 #include "chrome/common/extensions/manifest_handlers/kiosk_mode_info.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 using api::system_display::DisplayUnitInfo; | 12 using api::system_display::DisplayUnitInfo; |
| 13 | 13 |
| 14 namespace SetDisplayProperties = api::system_display::SetDisplayProperties; | 14 namespace SetDisplayProperties = api::system_display::SetDisplayProperties; |
| 15 | 15 |
| 16 bool SystemDisplayGetInfoFunction::RunImpl() { | 16 bool SystemDisplayGetInfoFunction::RunImpl() { |
| 17 DisplayInfoProvider::Get()->RequestInfo( | 17 DisplayInfoProvider::Get()->RequestInfo( |
| 18 base::Bind( | 18 base::Bind( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 SetError("Error occurred when querying display information."); | 30 SetError("Error occurred when querying display information."); |
| 31 } | 31 } |
| 32 SendResponse(success); | 32 SendResponse(success); |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool SystemDisplaySetDisplayPropertiesFunction::RunImpl() { | 35 bool SystemDisplaySetDisplayPropertiesFunction::RunImpl() { |
| 36 #if !defined(OS_CHROMEOS) | 36 #if !defined(OS_CHROMEOS) |
| 37 SetError("Function available only on ChromeOS."); | 37 SetError("Function available only on ChromeOS."); |
| 38 return false; | 38 return false; |
| 39 #else | 39 #else |
| 40 if (!KioskEnabledInfo::IsKioskEnabled(GetExtension())) { | 40 if (!KioskModeInfo::IsKioskEnabled(GetExtension())) { |
| 41 SetError("The extension needs to be kiosk enabled to use the function."); | 41 SetError("The extension needs to be kiosk enabled to use the function."); |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 scoped_ptr<SetDisplayProperties::Params> params( | 45 scoped_ptr<SetDisplayProperties::Params> params( |
| 46 SetDisplayProperties::Params::Create(*args_)); | 46 SetDisplayProperties::Params::Create(*args_)); |
| 47 DisplayInfoProvider::Get()->SetInfo(params->id, params->info, | 47 DisplayInfoProvider::Get()->SetInfo(params->id, params->info, |
| 48 base::Bind( | 48 base::Bind( |
| 49 &SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet, | 49 &SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet, |
| 50 this)); | 50 this)); |
| 51 return true; | 51 return true; |
| 52 #endif | 52 #endif |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet( | 55 void SystemDisplaySetDisplayPropertiesFunction::OnPropertiesSet( |
| 56 bool success, const std::string& error) { | 56 bool success, const std::string& error) { |
| 57 if (!success) | 57 if (!success) |
| 58 SetError(error); | 58 SetError(error); |
| 59 SendResponse(success); | 59 SendResponse(success); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace extensions | 62 } // namespace extensions |
| OLD | NEW |