| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autotest_private/autotest_private_api.h" | 5 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "extensions/browser/extension_registry.h" | 21 #include "extensions/browser/extension_registry.h" |
| 22 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 23 #include "extensions/browser/extension_util.h" | 23 #include "extensions/browser/extension_util.h" |
| 24 #include "extensions/common/manifest_handlers/background_info.h" | 24 #include "extensions/common/manifest_handlers/background_info.h" |
| 25 #include "extensions/common/manifest_handlers/options_page_info.h" | 25 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 26 #include "extensions/common/permissions/api_permission_set.h" | 26 #include "extensions/common/permissions/api_permission_set.h" |
| 27 #include "extensions/common/permissions/permission_set.h" | 27 #include "extensions/common/permissions/permission_set.h" |
| 28 #include "extensions/common/permissions/permissions_data.h" | 28 #include "extensions/common/permissions/permissions_data.h" |
| 29 | 29 |
| 30 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 31 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 31 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 32 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 32 #include "chrome/browser/chromeos/system/input_device_settings.h" | 33 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 34 #include "chrome/browser/profiles/profile_manager.h" |
| 33 #include "chromeos/dbus/dbus_thread_manager.h" | 35 #include "chromeos/dbus/dbus_thread_manager.h" |
| 34 #include "chromeos/dbus/session_manager_client.h" | 36 #include "chromeos/dbus/session_manager_client.h" |
| 35 #include "components/user_manager/user.h" | 37 #include "components/user_manager/user.h" |
| 36 #include "components/user_manager/user_manager.h" | 38 #include "components/user_manager/user_manager.h" |
| 37 #include "ui/message_center/message_center.h" | 39 #include "ui/message_center/message_center.h" |
| 38 #include "ui/message_center/notification.h" | 40 #include "ui/message_center/notification.h" |
| 39 #endif | 41 #endif |
| 40 | 42 |
| 41 namespace extensions { | 43 namespace extensions { |
| 42 namespace { | 44 namespace { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 result->SetString("message", notification->message()); | 375 result->SetString("message", notification->message()); |
| 374 result->SetInteger("priority", notification->priority()); | 376 result->SetInteger("priority", notification->priority()); |
| 375 result->SetInteger("progress", notification->progress()); | 377 result->SetInteger("progress", notification->progress()); |
| 376 values->Append(std::move(result)); | 378 values->Append(std::move(result)); |
| 377 } | 379 } |
| 378 | 380 |
| 379 #endif | 381 #endif |
| 380 return RespondNow(OneArgument(std::move(values))); | 382 return RespondNow(OneArgument(std::move(values))); |
| 381 } | 383 } |
| 382 | 384 |
| 385 ExtensionFunction::ResponseAction |
| 386 AutotestPrivateGetPlayStoreStateFunction::Run() { |
| 387 DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction"; |
| 388 api::autotest_private::PlayStoreState play_store_state; |
| 389 play_store_state.allowed = false; |
| 390 #if defined(OS_CHROMEOS) |
| 391 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 392 if (arc::IsArcAllowedForProfile(profile)) { |
| 393 play_store_state.allowed = true; |
| 394 play_store_state.enabled = |
| 395 base::MakeUnique<bool>(arc::IsArcPlayStoreEnabledForProfile(profile)); |
| 396 play_store_state.managed = base::MakeUnique<bool>( |
| 397 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)); |
| 398 } |
| 399 #endif |
| 400 return RespondNow(OneArgument(play_store_state.ToValue())); |
| 401 } |
| 402 |
| 403 ExtensionFunction::ResponseAction |
| 404 AutotestPrivateSetPlayStoreEnabledFunction::Run() { |
| 405 DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction"; |
| 406 std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params( |
| 407 api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_)); |
| 408 EXTENSION_FUNCTION_VALIDATE(params); |
| 409 #if defined(OS_CHROMEOS) |
| 410 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 411 if (arc::IsArcAllowedForProfile(profile)) { |
| 412 if (!arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled)) { |
| 413 return RespondNow( |
| 414 Error("ARC enabled state cannot be changed for the current user")); |
| 415 } |
| 416 return RespondNow(NoArguments()); |
| 417 } else { |
| 418 return RespondNow(Error("ARC is not available for the current user")); |
| 419 } |
| 420 #endif |
| 421 return RespondNow(Error("ARC is not available for the current platform")); |
| 422 } |
| 423 |
| 383 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: | 424 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: |
| 384 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; | 425 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
| 385 | 426 |
| 386 // static | 427 // static |
| 387 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 428 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
| 388 AutotestPrivateAPI::GetFactoryInstance() { | 429 AutotestPrivateAPI::GetFactoryInstance() { |
| 389 return g_factory.Pointer(); | 430 return g_factory.Pointer(); |
| 390 } | 431 } |
| 391 | 432 |
| 392 template <> | 433 template <> |
| 393 KeyedService* | 434 KeyedService* |
| 394 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 435 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
| 395 content::BrowserContext* context) const { | 436 content::BrowserContext* context) const { |
| 396 return new AutotestPrivateAPI(); | 437 return new AutotestPrivateAPI(); |
| 397 } | 438 } |
| 398 | 439 |
| 399 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 440 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
| 400 } | 441 } |
| 401 | 442 |
| 402 AutotestPrivateAPI::~AutotestPrivateAPI() { | 443 AutotestPrivateAPI::~AutotestPrivateAPI() { |
| 403 } | 444 } |
| 404 | 445 |
| 405 } // namespace extensions | 446 } // namespace extensions |
| OLD | NEW |