Chromium Code Reviews| 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"; | |
|
Devlin
2017/04/13 21:49:52
Do you need to keep these logs?
khmel
2017/04/13 23:02:51
Most of the functions here use similar structure:
| |
| 388 std::unique_ptr<base::DictionaryValue> play_store_state_value = | |
| 389 base::MakeUnique<base::DictionaryValue>(); | |
| 390 play_store_state_value->SetBoolean("allowed", false); | |
| 391 #if defined(OS_CHROMEOS) | |
| 392 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
| 393 if (arc::IsArcAllowedForProfile(profile)) { | |
| 394 play_store_state_value->SetBoolean("allowed", true); | |
|
Devlin
2017/04/13 21:49:52
Please use the generated types rather than using a
khmel
2017/04/13 23:02:51
Done.
| |
| 395 play_store_state_value->SetBoolean( | |
| 396 "enabled", arc::IsArcPlayStoreEnabledForProfile(profile)); | |
| 397 play_store_state_value->SetBoolean( | |
| 398 "managed", | |
| 399 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)); | |
| 400 } | |
| 401 #endif | |
| 402 return RespondNow(OneArgument(std::move(play_store_state_value))); | |
| 403 } | |
| 404 | |
| 405 ExtensionFunction::ResponseAction | |
| 406 AutotestPrivateSetPlayStoreEnabledFunction::Run() { | |
| 407 DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction"; | |
| 408 std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params( | |
| 409 api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_)); | |
| 410 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
| 411 #if defined(OS_CHROMEOS) | |
| 412 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
| 413 if (arc::IsArcAllowedForProfile(profile)) { | |
| 414 arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled); | |
| 415 if (params->enabled != arc::IsArcPlayStoreEnabledForProfile(profile)) { | |
|
Devlin
2017/04/13 21:49:52
This would be cleaner if we just had SetArcPlaySto
khmel
2017/04/13 23:02:51
You mean static boolean SetArcPlayStoreEnabledForP
Devlin
2017/04/13 23:06:00
Ah, sorry, I can see how that would be confusing.
khmel
2017/04/13 23:16:01
Got you :), done.
| |
| 416 return RespondNow( | |
| 417 Error("ARC enabled state cannot be changed for the current user")); | |
| 418 } | |
| 419 return RespondNow(NoArguments()); | |
| 420 } else { | |
| 421 return RespondNow(Error("ARC is not available for the current user")); | |
| 422 } | |
| 423 #endif | |
| 424 return RespondNow(Error("ARC is not available for the current platform")); | |
| 425 } | |
| 426 | |
| 383 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: | 427 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>:: |
| 384 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; | 428 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
| 385 | 429 |
| 386 // static | 430 // static |
| 387 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 431 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
| 388 AutotestPrivateAPI::GetFactoryInstance() { | 432 AutotestPrivateAPI::GetFactoryInstance() { |
| 389 return g_factory.Pointer(); | 433 return g_factory.Pointer(); |
| 390 } | 434 } |
| 391 | 435 |
| 392 template <> | 436 template <> |
| 393 KeyedService* | 437 KeyedService* |
| 394 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 438 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
| 395 content::BrowserContext* context) const { | 439 content::BrowserContext* context) const { |
| 396 return new AutotestPrivateAPI(); | 440 return new AutotestPrivateAPI(); |
| 397 } | 441 } |
| 398 | 442 |
| 399 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 443 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
| 400 } | 444 } |
| 401 | 445 |
| 402 AutotestPrivateAPI::~AutotestPrivateAPI() { | 446 AutotestPrivateAPI::~AutotestPrivateAPI() { |
| 403 } | 447 } |
| 404 | 448 |
| 405 } // namespace extensions | 449 } // namespace extensions |
| OLD | NEW |