| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "base/version.h" | 23 #include "base/version.h" |
| 24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
| 27 // TODO(rdevlin.cronin): Remove these once all references have been removed as | 27 // TODO(rdevlin.cronin): Remove these once all references have been removed as |
| 28 // part of crbug.com/159265. | 28 // part of crbug.com/159265. |
| 29 #include "chrome/common/extensions/api/extension_action/action_info.h" | 29 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 30 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" | |
| 31 #include "chrome/common/extensions/api/icons/icons_handler.h" | |
| 32 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 30 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 33 #include "chrome/common/extensions/api/themes/theme_handler.h" | |
| 34 #include "chrome/common/extensions/background_info.h" | 31 #include "chrome/common/extensions/background_info.h" |
| 35 #include "chrome/common/extensions/extension_icon_set.h" | |
| 36 #include "chrome/common/extensions/extension_manifest_constants.h" | 32 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 37 #include "chrome/common/extensions/feature_switch.h" | 33 #include "chrome/common/extensions/feature_switch.h" |
| 38 #include "chrome/common/extensions/features/base_feature_provider.h" | 34 #include "chrome/common/extensions/features/base_feature_provider.h" |
| 39 #include "chrome/common/extensions/features/feature.h" | 35 #include "chrome/common/extensions/features/feature.h" |
| 40 #include "chrome/common/extensions/incognito_handler.h" | 36 #include "chrome/common/extensions/incognito_handler.h" |
| 41 #include "chrome/common/extensions/manifest.h" | 37 #include "chrome/common/extensions/manifest.h" |
| 42 #include "chrome/common/extensions/manifest_handler.h" | 38 #include "chrome/common/extensions/manifest_handler.h" |
| 43 #include "chrome/common/extensions/manifest_handler_helpers.h" | 39 #include "chrome/common/extensions/manifest_handler_helpers.h" |
| 44 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 40 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 45 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h" | 41 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 656 } |
| 661 | 657 |
| 662 bool Extension::ShowConfigureContextMenus() const { | 658 bool Extension::ShowConfigureContextMenus() const { |
| 663 // Don't show context menu for component extensions. We might want to show | 659 // Don't show context menu for component extensions. We might want to show |
| 664 // options for component extension button but now there is no component | 660 // options for component extension button but now there is no component |
| 665 // extension with options. All other menu items like uninstall have | 661 // extension with options. All other menu items like uninstall have |
| 666 // no sense for component extensions. | 662 // no sense for component extensions. |
| 667 return location() != Manifest::COMPONENT; | 663 return location() != Manifest::COMPONENT; |
| 668 } | 664 } |
| 669 | 665 |
| 670 std::set<base::FilePath> Extension::GetBrowserImages() const { | |
| 671 std::set<base::FilePath> image_paths; | |
| 672 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| | |
| 673 // indicate that we're doing something wrong. | |
| 674 | |
| 675 // Extension icons. | |
| 676 for (ExtensionIconSet::IconMap::const_iterator iter = | |
| 677 IconsInfo::GetIcons(this).map().begin(); | |
| 678 iter != IconsInfo::GetIcons(this).map().end(); ++iter) { | |
| 679 image_paths.insert( | |
| 680 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); | |
| 681 } | |
| 682 | |
| 683 // Theme images. | |
| 684 DictionaryValue* theme_images = ThemeInfo::GetThemeImages(this); | |
| 685 if (theme_images) { | |
| 686 for (DictionaryValue::Iterator it(*theme_images); !it.IsAtEnd(); | |
| 687 it.Advance()) { | |
| 688 std::string val; | |
| 689 if (it.value().GetAsString(&val)) | |
| 690 image_paths.insert(base::FilePath::FromWStringHack(UTF8ToWide(val))); | |
| 691 } | |
| 692 } | |
| 693 | |
| 694 const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(this); | |
| 695 if (page_action_info && !page_action_info->default_icon.empty()) { | |
| 696 for (ExtensionIconSet::IconMap::const_iterator iter = | |
| 697 page_action_info->default_icon.map().begin(); | |
| 698 iter != page_action_info->default_icon.map().end(); | |
| 699 ++iter) { | |
| 700 image_paths.insert( | |
| 701 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); | |
| 702 } | |
| 703 } | |
| 704 | |
| 705 const ActionInfo* browser_action = ActionInfo::GetBrowserActionInfo(this); | |
| 706 if (browser_action && !browser_action->default_icon.empty()) { | |
| 707 for (ExtensionIconSet::IconMap::const_iterator iter = | |
| 708 browser_action->default_icon.map().begin(); | |
| 709 iter != browser_action->default_icon.map().end(); | |
| 710 ++iter) { | |
| 711 image_paths.insert( | |
| 712 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); | |
| 713 } | |
| 714 } | |
| 715 | |
| 716 return image_paths; | |
| 717 } | |
| 718 | |
| 719 GURL Extension::GetFullLaunchURL() const { | 666 GURL Extension::GetFullLaunchURL() const { |
| 720 return launch_local_path().empty() ? GURL(launch_web_url()) : | 667 return launch_local_path().empty() ? GURL(launch_web_url()) : |
| 721 url().Resolve(launch_local_path()); | 668 url().Resolve(launch_local_path()); |
| 722 } | 669 } |
| 723 | 670 |
| 724 bool Extension::CanExecuteScriptOnPage(const GURL& document_url, | 671 bool Extension::CanExecuteScriptOnPage(const GURL& document_url, |
| 725 const GURL& top_frame_url, | 672 const GURL& top_frame_url, |
| 726 int tab_id, | 673 int tab_id, |
| 727 const UserScript* script, | 674 const UserScript* script, |
| 728 std::string* error) const { | 675 std::string* error) const { |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 | 1750 |
| 1804 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 1751 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 1805 const Extension* extension, | 1752 const Extension* extension, |
| 1806 const PermissionSet* permissions, | 1753 const PermissionSet* permissions, |
| 1807 Reason reason) | 1754 Reason reason) |
| 1808 : reason(reason), | 1755 : reason(reason), |
| 1809 extension(extension), | 1756 extension(extension), |
| 1810 permissions(permissions) {} | 1757 permissions(permissions) {} |
| 1811 | 1758 |
| 1812 } // namespace extensions | 1759 } // namespace extensions |
| OLD | NEW |