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 std::unique_ptr<base::DictionaryValue> play_store_state_value( | |
389 new base::DictionaryValue); | |
390 play_store_state_value->SetBoolean("enabled", false); | |
391 play_store_state_value->SetBoolean("managed", false); | |
392 play_store_state_value->SetBoolean("allowed", false); | |
stevenjb
2017/04/13 00:23:47
nit: Maybe just set "allowed" to false? The other
khmel
2017/04/13 01:14:21
Makes sense
| |
393 #if defined(OS_CHROMEOS) | |
394 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
395 if (arc::IsArcAllowedForProfile(profile)) { | |
396 play_store_state_value->SetBoolean( | |
397 "enabled", arc::IsArcPlayStoreEnabledForProfile(profile)); | |
398 play_store_state_value->SetBoolean( | |
399 "managed", | |
400 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)); | |
401 play_store_state_value->SetBoolean("allowed", true); | |
402 } | |
403 #endif | |
404 return RespondNow(OneArgument(std::move(play_store_state_value))); | |
405 } | |
406 | |
407 ExtensionFunction::ResponseAction | |
408 AutotestPrivateSetPlayStoreEnabledFunction::Run() { | |
409 DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction"; | |
410 std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params( | |
411 api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_)); | |
412 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
413 #if defined(OS_CHROMEOS) | |
414 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
415 if (arc::IsArcAllowedForProfile(profile)) { | |
416 arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled); | |
417 if (params->enabled != arc::IsArcPlayStoreEnabledForProfile(profile)) { | |
418 return RespondNow( | |
419 Error("ARC enabled state cannot be changed for the current user")); | |
420 } | |
421 return RespondNow(NoArguments()); | |
422 } else { | |
423 return RespondNow(Error("ARC is not available for the current user")); | |
424 } | |
425 #endif | |
426 return RespondNow(Error("ARC is not available for the current platform")); | |
427 } | |
428 | |
383 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: | 429 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: |
384 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; | 430 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
385 | 431 |
386 // static | 432 // static |
387 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 433 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
388 AutotestPrivateAPI::GetFactoryInstance() { | 434 AutotestPrivateAPI::GetFactoryInstance() { |
389 return g_factory.Pointer(); | 435 return g_factory.Pointer(); |
390 } | 436 } |
391 | 437 |
392 template <> | 438 template <> |
393 KeyedService* | 439 KeyedService* |
394 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 440 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
395 content::BrowserContext* context) const { | 441 content::BrowserContext* context) const { |
396 return new AutotestPrivateAPI(); | 442 return new AutotestPrivateAPI(); |
397 } | 443 } |
398 | 444 |
399 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 445 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
400 } | 446 } |
401 | 447 |
402 AutotestPrivateAPI::~AutotestPrivateAPI() { | 448 AutotestPrivateAPI::~AutotestPrivateAPI() { |
403 } | 449 } |
404 | 450 |
405 } // namespace extensions | 451 } // namespace extensions |
OLD | NEW |