| 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 <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
| 17 #include "extensions/browser/api/system_display/display_info_provider.h" | 17 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 18 #include "extensions/common/api/system_display.h" | 18 #include "extensions/common/api/system_display.h" |
| 19 #include "extensions/common/permissions/permissions_data.h" |
| 19 | 20 |
| 20 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 21 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 22 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace extensions { | 25 namespace extensions { |
| 25 | 26 |
| 26 namespace display = api::system_display; | 27 namespace display = api::system_display; |
| 27 | 28 |
| 28 const char SystemDisplayFunction::kCrosOnlyError[] = | 29 const char SystemDisplayFunction::kCrosOnlyError[] = |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (source_context_type() == Feature::WEBUI_CONTEXT) | 169 if (source_context_type() == Feature::WEBUI_CONTEXT) |
| 169 return true; | 170 return true; |
| 170 if (KioskModeInfo::IsKioskEnabled(extension())) | 171 if (KioskModeInfo::IsKioskEnabled(extension())) |
| 171 return true; | 172 return true; |
| 172 *error = kKioskOnlyError; | 173 *error = kKioskOnlyError; |
| 173 return false; | 174 return false; |
| 174 #endif | 175 #endif |
| 175 } | 176 } |
| 176 | 177 |
| 177 bool SystemDisplayFunction::ShouldRestrictToKioskAndWebUI() { | 178 bool SystemDisplayFunction::ShouldRestrictToKioskAndWebUI() { |
| 179 // Allow autotest extension to access for Chrome OS testing. |
| 180 if (extension() && extension()->permissions_data()->HasAPIPermission( |
| 181 APIPermission::kAutoTestPrivate)) { |
| 182 return false; |
| 183 } |
| 184 |
| 178 return true; | 185 return true; |
| 179 } | 186 } |
| 180 | 187 |
| 181 ExtensionFunction::ResponseAction SystemDisplayGetInfoFunction::Run() { | 188 ExtensionFunction::ResponseAction SystemDisplayGetInfoFunction::Run() { |
| 182 std::unique_ptr<display::GetInfo::Params> params( | 189 std::unique_ptr<display::GetInfo::Params> params( |
| 183 display::GetInfo::Params::Create(*args_)); | 190 display::GetInfo::Params::Create(*args_)); |
| 184 bool single_unified = params->flags && params->flags->single_unified && | 191 bool single_unified = params->flags && params->flags->single_unified && |
| 185 *params->flags->single_unified; | 192 *params->flags->single_unified; |
| 186 DisplayInfoProvider::DisplayUnitInfoList all_displays_info = | 193 DisplayInfoProvider::DisplayUnitInfoList all_displays_info = |
| 187 DisplayInfoProvider::Get()->GetAllDisplaysInfo(single_unified); | 194 DisplayInfoProvider::Get()->GetAllDisplaysInfo(single_unified); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 std::string error; | 347 std::string error; |
| 341 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error)) | 348 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error)) |
| 342 return RespondNow(Error(error)); | 349 return RespondNow(Error(error)); |
| 343 | 350 |
| 344 if (!DisplayInfoProvider::Get()->ClearTouchCalibration(params->id, &error)) | 351 if (!DisplayInfoProvider::Get()->ClearTouchCalibration(params->id, &error)) |
| 345 return RespondNow(Error(error)); | 352 return RespondNow(Error(error)); |
| 346 return RespondNow(NoArguments()); | 353 return RespondNow(NoArguments()); |
| 347 } | 354 } |
| 348 | 355 |
| 349 } // namespace extensions | 356 } // namespace extensions |
| OLD | NEW |