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" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/extensions/extension_action_manager.h" | 14 #include "chrome/browser/extensions/extension_action_manager.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/extensions/extension_util.h" | 16 #include "chrome/browser/extensions/extension_util.h" |
17 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/extensions/api/autotest_private.h" | 19 #include "chrome/common/extensions/api/autotest_private.h" |
20 #include "extensions/browser/extension_function_registry.h" | 20 #include "extensions/browser/extension_function_registry.h" |
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/common/manifest_handlers/background_info.h" | 23 #include "extensions/common/manifest_handlers/background_info.h" |
24 #include "extensions/common/manifest_handlers/options_page_info.h" | 24 #include "extensions/common/manifest_handlers/options_page_info.h" |
25 #include "extensions/common/permissions/api_permission_set.h" | 25 #include "extensions/common/permissions/api_permission_set.h" |
26 #include "extensions/common/permissions/permission_set.h" | 26 #include "extensions/common/permissions/permission_set.h" |
27 #include "extensions/common/permissions/permissions_data.h" | 27 #include "extensions/common/permissions/permissions_data.h" |
28 | 28 |
29 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
30 #include "chrome/browser/chromeos/arc/arc_util.h" | |
30 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 31 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
31 #include "chrome/browser/chromeos/system/input_device_settings.h" | 32 #include "chrome/browser/chromeos/system/input_device_settings.h" |
33 #include "chrome/browser/profiles/profile_manager.h" | |
32 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
33 #include "chromeos/dbus/session_manager_client.h" | 35 #include "chromeos/dbus/session_manager_client.h" |
34 #include "components/user_manager/user.h" | 36 #include "components/user_manager/user.h" |
35 #include "components/user_manager/user_manager.h" | 37 #include "components/user_manager/user_manager.h" |
36 #include "ui/message_center/message_center.h" | 38 #include "ui/message_center/message_center.h" |
37 #include "ui/message_center/notification.h" | 39 #include "ui/message_center/notification.h" |
38 #endif | 40 #endif |
39 | 41 |
40 namespace extensions { | 42 namespace extensions { |
41 namespace { | 43 namespace { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 result->SetString("message", notification->message()); | 373 result->SetString("message", notification->message()); |
372 result->SetInteger("priority", notification->priority()); | 374 result->SetInteger("priority", notification->priority()); |
373 result->SetInteger("progress", notification->progress()); | 375 result->SetInteger("progress", notification->progress()); |
374 values->Append(std::move(result)); | 376 values->Append(std::move(result)); |
375 } | 377 } |
376 | 378 |
377 #endif | 379 #endif |
378 return RespondNow(OneArgument(std::move(values))); | 380 return RespondNow(OneArgument(std::move(values))); |
379 } | 381 } |
380 | 382 |
383 ExtensionFunction::ResponseAction | |
384 AutotestPrivateIsPlayStoreEnabledFunction::Run() { | |
385 DVLOG(1) << "AutotestPrivateIsPlayStoreEnabledFunction"; | |
386 bool enabled = false; | |
387 #if defined(OS_CHROMEOS) | |
388 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
389 enabled = arc::IsArcPlayStoreEnabledForProfile(profile); | |
390 #endif | |
391 return RespondNow(OneArgument(base::MakeUnique<base::Value>(enabled))); | |
392 } | |
393 | |
394 ExtensionFunction::ResponseAction | |
395 AutotestPrivateIsPlayStoreManagedFunction::Run() { | |
396 DVLOG(1) << "AutotestPrivateIsPlayStoreManagedFunction"; | |
397 bool managed = false; | |
398 #if defined(OS_CHROMEOS) | |
399 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
400 managed = arc::IsArcAllowedForProfile(profile) && | |
401 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile); | |
402 #endif | |
403 return RespondNow(OneArgument(base::MakeUnique<base::Value>(managed))); | |
404 } | |
405 | |
406 ExtensionFunction::ResponseAction | |
407 AutotestPrivateSetPlayStoreEnabledFunction::Run() { | |
408 DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction"; | |
409 std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params( | |
410 api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_)); | |
411 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
412 bool was_enabled = false; | |
413 #if defined(OS_CHROMEOS) | |
414 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
415 if (arc::IsArcAllowedForProfile(profile)) { | |
416 arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled); | |
417 was_enabled = arc::IsArcPlayStoreEnabledForProfile(profile); | |
stevenjb
2017/04/11 15:58:56
I think this should probably be:
if (!arc::IsArcPl
| |
418 } | |
419 #endif | |
420 return RespondNow(OneArgument(base::MakeUnique<base::Value>(was_enabled))); | |
421 } | |
422 | |
381 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: | 423 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: |
382 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; | 424 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
383 | 425 |
384 // static | 426 // static |
385 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 427 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
386 AutotestPrivateAPI::GetFactoryInstance() { | 428 AutotestPrivateAPI::GetFactoryInstance() { |
387 return g_factory.Pointer(); | 429 return g_factory.Pointer(); |
388 } | 430 } |
389 | 431 |
390 template <> | 432 template <> |
391 KeyedService* | 433 KeyedService* |
392 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 434 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
393 content::BrowserContext* context) const { | 435 content::BrowserContext* context) const { |
394 return new AutotestPrivateAPI(); | 436 return new AutotestPrivateAPI(); |
395 } | 437 } |
396 | 438 |
397 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 439 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
398 } | 440 } |
399 | 441 |
400 AutotestPrivateAPI::~AutotestPrivateAPI() { | 442 AutotestPrivateAPI::~AutotestPrivateAPI() { |
401 } | 443 } |
402 | 444 |
403 } // namespace extensions | 445 } // namespace extensions |
OLD | NEW |