| 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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (GetProfile()->IsSupervised()) | 600 if (GetProfile()->IsSupervised()) |
| 601 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); | 601 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); |
| 602 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, | 602 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, |
| 603 *update.in_developer_mode); | 603 *update.in_developer_mode); |
| 604 } | 604 } |
| 605 | 605 |
| 606 return RespondNow(NoArguments()); | 606 return RespondNow(NoArguments()); |
| 607 } | 607 } |
| 608 | 608 |
| 609 DeveloperPrivateUpdateExtensionConfigurationFunction:: | 609 DeveloperPrivateUpdateExtensionConfigurationFunction:: |
| 610 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {} | 610 DeveloperPrivateUpdateExtensionConfigurationFunction( |
| 611 const mojo::Callback<void()>& callback) |
| 612 : MojoExtensionFunction(callback) {} |
| 611 | 613 |
| 612 ExtensionFunction::ResponseAction | 614 DeveloperPrivateUpdateExtensionConfigurationFunction:: |
| 613 DeveloperPrivateUpdateExtensionConfigurationFunction::Run() { | 615 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {} |
| 614 std::unique_ptr<developer::UpdateExtensionConfiguration::Params> params( | |
| 615 developer::UpdateExtensionConfiguration::Params::Create(*args_)); | |
| 616 EXTENSION_FUNCTION_VALIDATE(params); | |
| 617 | 616 |
| 618 const developer::ExtensionConfigurationUpdate& update = params->update; | 617 MojoExtensionFunctionBase::RunResult |
| 618 DeveloperPrivateUpdateExtensionConfigurationFunction::Run( |
| 619 mojom::UpdateExtensionConfigurationParamsPtr update) { |
| 620 const Extension* extension = ExtensionRegistry::Get(browser_context()) |
| 621 ->enabled_extensions() |
| 622 .GetByID(update->extension_id); |
| 623 if (!extension) |
| 624 return Error(kNoSuchExtensionError); |
| 625 if (!user_gesture()) |
| 626 return Error(kRequiresUserGestureError); |
| 619 | 627 |
| 620 const Extension* extension = GetExtensionById(update.extension_id); | 628 if (update->has_file_access) { |
| 621 if (!extension) | |
| 622 return RespondNow(Error(kNoSuchExtensionError)); | |
| 623 if (!user_gesture()) | |
| 624 return RespondNow(Error(kRequiresUserGestureError)); | |
| 625 | |
| 626 if (update.file_access) { | |
| 627 std::string error; | 629 std::string error; |
| 628 if (!UserCanModifyExtensionConfiguration(extension, | 630 if (!UserCanModifyExtensionConfiguration(extension, |
| 629 browser_context(), | 631 browser_context(), |
| 630 &error)) { | 632 &error)) { |
| 631 return RespondNow(Error(error)); | 633 return Error(error); |
| 632 } | 634 } |
| 633 util::SetAllowFileAccess( | 635 util::SetAllowFileAccess(extension->id(), browser_context(), |
| 634 extension->id(), browser_context(), *update.file_access); | 636 update->file_access); |
| 635 } | 637 } |
| 636 if (update.incognito_access) { | 638 if (update->has_incognito_access) { |
| 637 util::SetIsIncognitoEnabled( | 639 util::SetIsIncognitoEnabled(extension->id(), browser_context(), |
| 638 extension->id(), browser_context(), *update.incognito_access); | 640 update->incognito_access); |
| 639 } | 641 } |
| 640 if (update.error_collection) { | 642 if (update->has_error_collection) { |
| 641 ErrorConsole::Get(browser_context())->SetReportingAllForExtension( | 643 ErrorConsole::Get(browser_context()) |
| 642 extension->id(), *update.error_collection); | 644 ->SetReportingAllForExtension(extension->id(), |
| 645 update->error_collection); |
| 643 } | 646 } |
| 644 if (update.run_on_all_urls) { | 647 if (update->has_run_on_all_urls) { |
| 645 util::SetAllowedScriptingOnAllUrls( | 648 util::SetAllowedScriptingOnAllUrls(extension->id(), browser_context(), |
| 646 extension->id(), browser_context(), *update.run_on_all_urls); | 649 update->run_on_all_urls); |
| 647 } | 650 } |
| 648 if (update.show_action_button) { | 651 if (update->has_show_action_button) { |
| 649 ExtensionActionAPI::Get(browser_context())->SetBrowserActionVisibility( | 652 ExtensionActionAPI::Get(browser_context()) |
| 650 extension->id(), | 653 ->SetBrowserActionVisibility(extension->id(), |
| 651 *update.show_action_button); | 654 update->show_action_button); |
| 652 } | 655 } |
| 653 | 656 |
| 654 return RespondNow(NoArguments()); | 657 return Respond(); |
| 655 } | 658 } |
| 656 | 659 |
| 657 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} | 660 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} |
| 658 | 661 |
| 659 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { | 662 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { |
| 660 std::unique_ptr<Reload::Params> params(Reload::Params::Create(*args_)); | 663 std::unique_ptr<Reload::Params> params(Reload::Params::Create(*args_)); |
| 661 EXTENSION_FUNCTION_VALIDATE(params.get()); | 664 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 662 | 665 |
| 663 const Extension* extension = GetExtensionById(params->extension_id); | 666 const Extension* extension = GetExtensionById(params->extension_id); |
| 664 if (!extension) | 667 if (!extension) |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 update.extension_id, update.command_name, *update.keybinding); | 1448 update.extension_id, update.command_name, *update.keybinding); |
| 1446 } | 1449 } |
| 1447 | 1450 |
| 1448 return RespondNow(NoArguments()); | 1451 return RespondNow(NoArguments()); |
| 1449 } | 1452 } |
| 1450 | 1453 |
| 1451 | 1454 |
| 1452 } // namespace api | 1455 } // namespace api |
| 1453 | 1456 |
| 1454 } // namespace extensions | 1457 } // namespace extensions |
| OLD | NEW |