Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1193)

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 25366003: Moved some functions off ExtensionService into a new file extension_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile failures Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
11 #include "apps/shell_window_registry.h" 11 #include "apps/shell_window_registry.h"
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/files/file_enumerator.h" 15 #include "base/files/file_enumerator.h"
16 #include "base/i18n/file_util_icu.h" 16 #include "base/i18n/file_util_icu.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/devtools/devtools_window.h" 21 #include "chrome/browser/devtools/devtools_window.h"
22 #include "chrome/browser/extensions/api/developer_private/developer_private_api_ factory.h" 22 #include "chrome/browser/extensions/api/developer_private/developer_private_api_ factory.h"
23 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 23 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
24 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 24 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
25 #include "chrome/browser/extensions/devtools_util.h" 25 #include "chrome/browser/extensions/devtools_util.h"
26 #include "chrome/browser/extensions/extension_disabled_ui.h" 26 #include "chrome/browser/extensions/extension_disabled_ui.h"
27 #include "chrome/browser/extensions/extension_error_reporter.h" 27 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_system.h" 29 #include "chrome/browser/extensions/extension_system.h"
30 #include "chrome/browser/extensions/extension_util.h"
30 #include "chrome/browser/extensions/management_policy.h" 31 #include "chrome/browser/extensions/management_policy.h"
31 #include "chrome/browser/extensions/unpacked_installer.h" 32 #include "chrome/browser/extensions/unpacked_installer.h"
32 #include "chrome/browser/extensions/updater/extension_updater.h" 33 #include "chrome/browser/extensions/updater/extension_updater.h"
33 #include "chrome/browser/platform_util.h" 34 #include "chrome/browser/platform_util.h"
34 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi ce.h" 36 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi ce.h"
36 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 37 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
37 #include "chrome/browser/ui/chrome_select_file_policy.h" 38 #include "chrome/browser/ui/chrome_select_file_policy.h"
38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
39 #include "chrome/common/extensions/api/developer_private.h" 40 #include "chrome/common/extensions/api/developer_private.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 new std::string(UTF16ToUTF8(item.path().LossyDisplayName()))); 335 new std::string(UTF16ToUTF8(item.path().LossyDisplayName())));
335 for (std::vector<extensions::InstallWarning>::const_iterator it = 336 for (std::vector<extensions::InstallWarning>::const_iterator it =
336 item.install_warnings().begin(); 337 item.install_warnings().begin();
337 it != item.install_warnings().end(); ++it) { 338 it != item.install_warnings().end(); ++it) {
338 developer::InstallWarning* warning = new developer::InstallWarning(); 339 developer::InstallWarning* warning = new developer::InstallWarning();
339 warning->message = it->message; 340 warning->message = it->message;
340 info->install_warnings.push_back(make_linked_ptr(warning)); 341 info->install_warnings.push_back(make_linked_ptr(warning));
341 } 342 }
342 } 343 }
343 344
344 info->incognito_enabled = service->IsIncognitoEnabled(item.id()); 345 info->incognito_enabled =
346 extension_util::IsIncognitoEnabled(item.id(),service);
345 info->wants_file_access = item.wants_file_access(); 347 info->wants_file_access = item.wants_file_access();
346 info->allow_file_access = service->AllowFileAccess(&item); 348 info->allow_file_access = extension_util::AllowFileAccess(&item, service);
347 info->allow_reload = Manifest::IsUnpackedLocation(item.location()); 349 info->allow_reload = Manifest::IsUnpackedLocation(item.location());
348 info->is_unpacked = Manifest::IsUnpackedLocation(item.location()); 350 info->is_unpacked = Manifest::IsUnpackedLocation(item.location());
349 info->terminated = service->terminated_extensions()->Contains(item.id()); 351 info->terminated = service->terminated_extensions()->Contains(item.id());
350 info->allow_incognito = item.can_be_incognito_enabled(); 352 info->allow_incognito = item.can_be_incognito_enabled();
351 353
352 info->homepage_url.reset(new std::string( 354 info->homepage_url.reset(new std::string(
353 ManifestURL::GetHomepageURL(&item).spec())); 355 ManifestURL::GetHomepageURL(&item).spec()));
354 if (!ManifestURL::GetOptionsPage(&item).is_empty()) { 356 if (!ManifestURL::GetOptionsPage(&item).is_empty()) {
355 info->options_url.reset( 357 info->options_url.reset(
356 new std::string(ManifestURL::GetOptionsPage(&item).spec())); 358 new std::string(ManifestURL::GetOptionsPage(&item).spec()));
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 bool result = true; 603 bool result = true;
602 604
603 if (!extension) { 605 if (!extension) {
604 result = false; 606 result = false;
605 } else if (!management_policy->UserMayModifySettings(extension, NULL)) { 607 } else if (!management_policy->UserMayModifySettings(extension, NULL)) {
606 LOG(ERROR) << "Attempt to change allow file access of an extension that " 608 LOG(ERROR) << "Attempt to change allow file access of an extension that "
607 << "non-usermanagable was made. Extension id : " 609 << "non-usermanagable was made. Extension id : "
608 << extension->id(); 610 << extension->id();
609 result = false; 611 result = false;
610 } else { 612 } else {
611 service->SetAllowFileAccess(extension, params->allow); 613 extension_util::SetAllowFileAccess(extension, service, params->allow);
612 result = true; 614 result = true;
613 } 615 }
614 616
615 return result; 617 return result;
616 } 618 }
617 619
618 DeveloperPrivateAllowFileAccessFunction:: 620 DeveloperPrivateAllowFileAccessFunction::
619 ~DeveloperPrivateAllowFileAccessFunction() {} 621 ~DeveloperPrivateAllowFileAccessFunction() {}
620 622
621 bool DeveloperPrivateAllowIncognitoFunction::RunImpl() { 623 bool DeveloperPrivateAllowIncognitoFunction::RunImpl() {
622 scoped_ptr<AllowIncognito::Params> params( 624 scoped_ptr<AllowIncognito::Params> params(
623 AllowIncognito::Params::Create(*args_)); 625 AllowIncognito::Params::Create(*args_));
624 EXTENSION_FUNCTION_VALIDATE(params.get()); 626 EXTENSION_FUNCTION_VALIDATE(params.get());
625 627
626 ExtensionService* service = profile()->GetExtensionService(); 628 ExtensionService* service = profile()->GetExtensionService();
627 const Extension* extension = service->GetInstalledExtension(params->item_id); 629 const Extension* extension = service->GetInstalledExtension(params->item_id);
628 bool result = true; 630 bool result = true;
629 631
630 if (!extension) 632 if (!extension)
631 result = false; 633 result = false;
632 else 634 else
633 service->SetIsIncognitoEnabled(extension->id(), params->allow); 635 extension_util::SetIsIncognitoEnabled(
636 extension->id(),service, params->allow);
634 637
635 return result; 638 return result;
636 } 639 }
637 640
638 DeveloperPrivateAllowIncognitoFunction:: 641 DeveloperPrivateAllowIncognitoFunction::
639 ~DeveloperPrivateAllowIncognitoFunction() {} 642 ~DeveloperPrivateAllowIncognitoFunction() {}
640 643
641 644
642 bool DeveloperPrivateReloadFunction::RunImpl() { 645 bool DeveloperPrivateReloadFunction::RunImpl() {
643 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); 646 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_));
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 return true; 1344 return true;
1342 } 1345 }
1343 1346
1344 DeveloperPrivateIsProfileManagedFunction:: 1347 DeveloperPrivateIsProfileManagedFunction::
1345 ~DeveloperPrivateIsProfileManagedFunction() { 1348 ~DeveloperPrivateIsProfileManagedFunction() {
1346 } 1349 }
1347 1350
1348 } // namespace api 1351 } // namespace api
1349 1352
1350 } // namespace extensions 1353 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698