| 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "base/version.h" | 25 #include "base/version.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
| 29 #include "chrome/common/extensions/csp_validator.h" | 29 #include "chrome/common/extensions/csp_validator.h" |
| 30 #include "chrome/common/extensions/extension_action.h" | |
| 31 #include "chrome/common/extensions/extension_error_utils.h" | 30 #include "chrome/common/extensions/extension_error_utils.h" |
| 32 #include "chrome/common/extensions/extension_manifest_constants.h" | 31 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 33 #include "chrome/common/extensions/extension_resource.h" | 32 #include "chrome/common/extensions/extension_resource.h" |
| 34 #include "chrome/common/extensions/extension_switch_utils.h" | 33 #include "chrome/common/extensions/extension_switch_utils.h" |
| 35 #include "chrome/common/extensions/features/feature.h" | 34 #include "chrome/common/extensions/features/feature.h" |
| 36 #include "chrome/common/extensions/features/simple_feature_provider.h" | 35 #include "chrome/common/extensions/features/simple_feature_provider.h" |
| 37 #include "chrome/common/extensions/file_browser_handler.h" | 36 #include "chrome/common/extensions/file_browser_handler.h" |
| 38 #include "chrome/common/extensions/manifest.h" | 37 #include "chrome/common/extensions/manifest.h" |
| 39 #include "chrome/common/extensions/permissions/permissions_info.h" | 38 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 40 #include "chrome/common/extensions/permissions/permission_set.h" | 39 #include "chrome/common/extensions/permissions/permission_set.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 280 } |
| 282 | 281 |
| 283 Extension::InputComponentInfo::~InputComponentInfo() {} | 282 Extension::InputComponentInfo::~InputComponentInfo() {} |
| 284 | 283 |
| 285 Extension::TtsVoice::TtsVoice() {} | 284 Extension::TtsVoice::TtsVoice() {} |
| 286 Extension::TtsVoice::~TtsVoice() {} | 285 Extension::TtsVoice::~TtsVoice() {} |
| 287 | 286 |
| 288 Extension::OAuth2Info::OAuth2Info() {} | 287 Extension::OAuth2Info::OAuth2Info() {} |
| 289 Extension::OAuth2Info::~OAuth2Info() {} | 288 Extension::OAuth2Info::~OAuth2Info() {} |
| 290 | 289 |
| 290 Extension::ActionInfo::ActionInfo(Type action_type) |
| 291 : action_type(action_type) {} |
| 292 Extension::ActionInfo::~ActionInfo() {} |
| 293 |
| 291 // | 294 // |
| 292 // Extension | 295 // Extension |
| 293 // | 296 // |
| 294 | 297 |
| 295 // static | 298 // static |
| 296 scoped_refptr<Extension> Extension::Create(const FilePath& path, | 299 scoped_refptr<Extension> Extension::Create(const FilePath& path, |
| 297 Location location, | 300 Location location, |
| 298 const DictionaryValue& value, | 301 const DictionaryValue& value, |
| 299 int flags, | 302 int flags, |
| 300 std::string* utf8_error) { | 303 std::string* utf8_error) { |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 base::IntToString(i)); | 793 base::IntToString(i)); |
| 791 return false; | 794 return false; |
| 792 } | 795 } |
| 793 | 796 |
| 794 (instance->*add_method)(glob); | 797 (instance->*add_method)(glob); |
| 795 } | 798 } |
| 796 | 799 |
| 797 return true; | 800 return true; |
| 798 } | 801 } |
| 799 | 802 |
| 800 scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper( | 803 scoped_ptr<Extension::ActionInfo> Extension::LoadExtensionActionHelper( |
| 801 const DictionaryValue* extension_action, | 804 const DictionaryValue* extension_action, |
| 802 ExtensionAction::Type action_type, | 805 ActionInfo::Type action_type, |
| 803 string16* error) { | 806 string16* error) { |
| 804 scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type)); | 807 scoped_ptr<ActionInfo> result(new ActionInfo(action_type)); |
| 805 | |
| 806 // Page/script actions are hidden/disabled by default, and browser actions are | |
| 807 // visible/enabled by default. | |
| 808 result->SetAppearance(ExtensionAction::kDefaultTabId, | |
| 809 action_type == ExtensionAction::TYPE_BROWSER ? | |
| 810 ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); | |
| 811 | 808 |
| 812 if (manifest_version_ == 1) { | 809 if (manifest_version_ == 1) { |
| 813 const ListValue* icons = NULL; | 810 const ListValue* icons = NULL; |
| 814 if (extension_action->HasKey(keys::kPageActionIcons) && | 811 if (extension_action->HasKey(keys::kPageActionIcons) && |
| 815 extension_action->GetList(keys::kPageActionIcons, &icons)) { | 812 extension_action->GetList(keys::kPageActionIcons, &icons)) { |
| 816 for (ListValue::const_iterator iter = icons->begin(); | 813 for (ListValue::const_iterator iter = icons->begin(); |
| 817 iter != icons->end(); ++iter) { | 814 iter != icons->end(); ++iter) { |
| 818 std::string path; | 815 std::string path; |
| 819 if (!(*iter)->GetAsString(&path) || path.empty()) { | 816 if (!(*iter)->GetAsString(&path) || path.empty()) { |
| 820 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 817 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
| 821 return scoped_ptr<ExtensionAction>(); | 818 return scoped_ptr<ActionInfo>(); |
| 822 } | 819 } |
| 823 | 820 |
| 824 result->icon_paths()->push_back(path); | 821 result->default_icon_path = path; |
| 822 break; |
| 825 } | 823 } |
| 826 } | 824 } |
| 827 | 825 |
| 828 std::string id; | 826 std::string id; |
| 829 if (extension_action->HasKey(keys::kPageActionId)) { | 827 if (extension_action->HasKey(keys::kPageActionId)) { |
| 830 if (!extension_action->GetString(keys::kPageActionId, &id)) { | 828 if (!extension_action->GetString(keys::kPageActionId, &id)) { |
| 831 *error = ASCIIToUTF16(errors::kInvalidPageActionId); | 829 *error = ASCIIToUTF16(errors::kInvalidPageActionId); |
| 832 return scoped_ptr<ExtensionAction>(); | 830 return scoped_ptr<ActionInfo>(); |
| 833 } | 831 } |
| 834 result->set_id(id); | 832 result->id = id; |
| 835 } | 833 } |
| 836 } | 834 } |
| 837 | 835 |
| 838 std::string default_icon; | 836 std::string default_icon; |
| 839 // Read the page action |default_icon| (optional). | 837 // Read the page action |default_icon| (optional). |
| 840 if (extension_action->HasKey(keys::kPageActionDefaultIcon)) { | 838 if (extension_action->HasKey(keys::kPageActionDefaultIcon)) { |
| 841 if (!extension_action->GetString(keys::kPageActionDefaultIcon, | 839 if (!extension_action->GetString(keys::kPageActionDefaultIcon, |
| 842 &default_icon) || | 840 &default_icon) || |
| 843 default_icon.empty()) { | 841 default_icon.empty()) { |
| 844 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 842 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
| 845 return scoped_ptr<ExtensionAction>(); | 843 return scoped_ptr<ActionInfo>(); |
| 846 } | 844 } |
| 847 result->set_default_icon_path(default_icon); | 845 result->default_icon_path = default_icon; |
| 848 } | 846 } |
| 849 | 847 |
| 850 // Read the page action title from |default_title| if present, |name| if not | 848 // Read the page action title from |default_title| if present, |name| if not |
| 851 // (both optional). | 849 // (both optional). |
| 852 std::string title; | 850 std::string title; |
| 853 if (extension_action->HasKey(keys::kPageActionDefaultTitle)) { | 851 if (extension_action->HasKey(keys::kPageActionDefaultTitle)) { |
| 854 if (!extension_action->GetString(keys::kPageActionDefaultTitle, &title)) { | 852 if (!extension_action->GetString(keys::kPageActionDefaultTitle, &title)) { |
| 855 *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle); | 853 *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle); |
| 856 return scoped_ptr<ExtensionAction>(); | 854 return scoped_ptr<ActionInfo>(); |
| 857 } | 855 } |
| 858 } else if (manifest_version_ == 1 && extension_action->HasKey(keys::kName)) { | 856 } else if (manifest_version_ == 1 && extension_action->HasKey(keys::kName)) { |
| 859 if (!extension_action->GetString(keys::kName, &title)) { | 857 if (!extension_action->GetString(keys::kName, &title)) { |
| 860 *error = ASCIIToUTF16(errors::kInvalidPageActionName); | 858 *error = ASCIIToUTF16(errors::kInvalidPageActionName); |
| 861 return scoped_ptr<ExtensionAction>(); | 859 return scoped_ptr<ActionInfo>(); |
| 862 } | 860 } |
| 863 } | 861 } |
| 864 result->SetTitle(ExtensionAction::kDefaultTabId, title); | 862 result->default_title = title; |
| 865 | 863 |
| 866 // Read the action's |popup| (optional). | 864 // Read the action's |popup| (optional). |
| 867 const char* popup_key = NULL; | 865 const char* popup_key = NULL; |
| 868 if (extension_action->HasKey(keys::kPageActionDefaultPopup)) | 866 if (extension_action->HasKey(keys::kPageActionDefaultPopup)) |
| 869 popup_key = keys::kPageActionDefaultPopup; | 867 popup_key = keys::kPageActionDefaultPopup; |
| 870 | 868 |
| 871 if (manifest_version_ == 1 && | 869 if (manifest_version_ == 1 && |
| 872 extension_action->HasKey(keys::kPageActionPopup)) { | 870 extension_action->HasKey(keys::kPageActionPopup)) { |
| 873 if (popup_key) { | 871 if (popup_key) { |
| 874 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 872 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 875 errors::kInvalidPageActionOldAndNewKeys, | 873 errors::kInvalidPageActionOldAndNewKeys, |
| 876 keys::kPageActionDefaultPopup, | 874 keys::kPageActionDefaultPopup, |
| 877 keys::kPageActionPopup); | 875 keys::kPageActionPopup); |
| 878 return scoped_ptr<ExtensionAction>(); | 876 return scoped_ptr<ActionInfo>(); |
| 879 } | 877 } |
| 880 popup_key = keys::kPageActionPopup; | 878 popup_key = keys::kPageActionPopup; |
| 881 } | 879 } |
| 882 | 880 |
| 883 if (popup_key) { | 881 if (popup_key) { |
| 884 const DictionaryValue* popup = NULL; | 882 const DictionaryValue* popup = NULL; |
| 885 std::string url_str; | 883 std::string url_str; |
| 886 | 884 |
| 887 if (extension_action->GetString(popup_key, &url_str)) { | 885 if (extension_action->GetString(popup_key, &url_str)) { |
| 888 // On success, |url_str| is set. Nothing else to do. | 886 // On success, |url_str| is set. Nothing else to do. |
| 889 } else if (manifest_version_ == 1 && | 887 } else if (manifest_version_ == 1 && |
| 890 extension_action->GetDictionary(popup_key, &popup)) { | 888 extension_action->GetDictionary(popup_key, &popup)) { |
| 891 if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) { | 889 if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) { |
| 892 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 890 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 893 errors::kInvalidPageActionPopupPath, "<missing>"); | 891 errors::kInvalidPageActionPopupPath, "<missing>"); |
| 894 return scoped_ptr<ExtensionAction>(); | 892 return scoped_ptr<ActionInfo>(); |
| 895 } | 893 } |
| 896 } else { | 894 } else { |
| 897 *error = ASCIIToUTF16(errors::kInvalidPageActionPopup); | 895 *error = ASCIIToUTF16(errors::kInvalidPageActionPopup); |
| 898 return scoped_ptr<ExtensionAction>(); | 896 return scoped_ptr<ActionInfo>(); |
| 899 } | 897 } |
| 900 | 898 |
| 901 if (!url_str.empty()) { | 899 if (!url_str.empty()) { |
| 902 // An empty string is treated as having no popup. | 900 // An empty string is treated as having no popup. |
| 903 GURL url = GetResourceURL(url_str); | 901 GURL url = GetResourceURL(url_str); |
| 904 if (!url.is_valid()) { | 902 if (!url.is_valid()) { |
| 905 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 903 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 906 errors::kInvalidPageActionPopupPath, url_str); | 904 errors::kInvalidPageActionPopupPath, url_str); |
| 907 return scoped_ptr<ExtensionAction>(); | 905 return scoped_ptr<ActionInfo>(); |
| 908 } | 906 } |
| 909 result->SetPopupUrl(ExtensionAction::kDefaultTabId, url); | 907 result->default_popup_url = url; |
| 910 } else { | 908 } else { |
| 911 DCHECK(!result->HasPopup(ExtensionAction::kDefaultTabId)) | 909 DCHECK(result->default_popup_url.is_empty()) |
| 912 << "Shouldn't be possible for the popup to be set."; | 910 << "Shouldn't be possible for the popup to be set."; |
| 913 } | 911 } |
| 914 } | 912 } |
| 915 | 913 |
| 916 return result.Pass(); | 914 return result.Pass(); |
| 917 } | 915 } |
| 918 | 916 |
| 919 // static | 917 // static |
| 920 bool Extension::InitExtensionID(extensions::Manifest* manifest, | 918 bool Extension::InitExtensionID(extensions::Manifest* manifest, |
| 921 const FilePath& path, | 919 const FilePath& path, |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2291 } else if (manifest_->HasKey(keys::kPageAction)) { | 2289 } else if (manifest_->HasKey(keys::kPageAction)) { |
| 2292 if (!manifest_->GetDictionary(keys::kPageAction, &page_action_value)) { | 2290 if (!manifest_->GetDictionary(keys::kPageAction, &page_action_value)) { |
| 2293 *error = ASCIIToUTF16(errors::kInvalidPageAction); | 2291 *error = ASCIIToUTF16(errors::kInvalidPageAction); |
| 2294 return false; | 2292 return false; |
| 2295 } | 2293 } |
| 2296 } | 2294 } |
| 2297 | 2295 |
| 2298 // If page_action_value is not NULL, then there was a valid page action. | 2296 // If page_action_value is not NULL, then there was a valid page action. |
| 2299 if (page_action_value) { | 2297 if (page_action_value) { |
| 2300 page_action_ = LoadExtensionActionHelper( | 2298 page_action_ = LoadExtensionActionHelper( |
| 2301 page_action_value, ExtensionAction::TYPE_PAGE, error); | 2299 page_action_value, ActionInfo::TYPE_PAGE, error); |
| 2302 if (!page_action_.get()) | 2300 if (!page_action_.get()) |
| 2303 return false; // Failed to parse page action definition. | 2301 return false; // Failed to parse page action definition. |
| 2304 | 2302 |
| 2305 // The action box changes the meaning of the page action area, so we need | 2303 // The action box changes the meaning of the page action area, so we need |
| 2306 // to convert page actions into browser actions. | 2304 // to convert page actions into browser actions. |
| 2307 if (switch_utils::AreScriptBadgesEnabled()) | 2305 if (switch_utils::AreScriptBadgesEnabled()) |
| 2308 browser_action_ = page_action_.Pass(); | 2306 browser_action_ = page_action_.Pass(); |
| 2309 } | 2307 } |
| 2310 | 2308 |
| 2311 return true; | 2309 return true; |
| 2312 } | 2310 } |
| 2313 | 2311 |
| 2314 bool Extension::LoadBrowserAction(string16* error) { | 2312 bool Extension::LoadBrowserAction(string16* error) { |
| 2315 if (!manifest_->HasKey(keys::kBrowserAction)) | 2313 if (!manifest_->HasKey(keys::kBrowserAction)) |
| 2316 return true; | 2314 return true; |
| 2317 DictionaryValue* browser_action_value = NULL; | 2315 DictionaryValue* browser_action_value = NULL; |
| 2318 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) { | 2316 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) { |
| 2319 *error = ASCIIToUTF16(errors::kInvalidBrowserAction); | 2317 *error = ASCIIToUTF16(errors::kInvalidBrowserAction); |
| 2320 return false; | 2318 return false; |
| 2321 } | 2319 } |
| 2322 | 2320 |
| 2323 browser_action_ = LoadExtensionActionHelper( | 2321 browser_action_ = LoadExtensionActionHelper( |
| 2324 browser_action_value, ExtensionAction::TYPE_BROWSER, error); | 2322 browser_action_value, ActionInfo::TYPE_BROWSER, error); |
| 2325 if (!browser_action_.get()) | 2323 if (!browser_action_.get()) |
| 2326 return false; // Failed to parse browser action definition. | 2324 return false; // Failed to parse browser action definition. |
| 2327 return true; | 2325 return true; |
| 2328 } | 2326 } |
| 2329 | 2327 |
| 2330 bool Extension::LoadScriptBadge(string16* error) { | 2328 bool Extension::LoadScriptBadge(string16* error) { |
| 2331 if (manifest_->HasKey(keys::kScriptBadge)) { | 2329 if (manifest_->HasKey(keys::kScriptBadge)) { |
| 2332 if (!switch_utils::AreScriptBadgesEnabled()) { | 2330 if (!switch_utils::AreScriptBadgesEnabled()) { |
| 2333 // So as to not confuse developers if they specify a script badge section | 2331 // So as to not confuse developers if they specify a script badge section |
| 2334 // in the manifest, show a warning if the script badge declaration isn't | 2332 // in the manifest, show a warning if the script badge declaration isn't |
| 2335 // going to have any effect. | 2333 // going to have any effect. |
| 2336 install_warnings_.push_back( | 2334 install_warnings_.push_back( |
| 2337 InstallWarning(InstallWarning::FORMAT_TEXT, | 2335 InstallWarning(InstallWarning::FORMAT_TEXT, |
| 2338 errors::kScriptBadgeRequiresFlag)); | 2336 errors::kScriptBadgeRequiresFlag)); |
| 2339 } | 2337 } |
| 2340 | 2338 |
| 2341 DictionaryValue* script_badge_value = NULL; | 2339 DictionaryValue* script_badge_value = NULL; |
| 2342 if (!manifest_->GetDictionary(keys::kScriptBadge, &script_badge_value)) { | 2340 if (!manifest_->GetDictionary(keys::kScriptBadge, &script_badge_value)) { |
| 2343 *error = ASCIIToUTF16(errors::kInvalidScriptBadge); | 2341 *error = ASCIIToUTF16(errors::kInvalidScriptBadge); |
| 2344 return false; | 2342 return false; |
| 2345 } | 2343 } |
| 2346 | 2344 |
| 2347 script_badge_ = LoadExtensionActionHelper( | 2345 script_badge_ = LoadExtensionActionHelper( |
| 2348 script_badge_value, ExtensionAction::TYPE_SCRIPT_BADGE, error); | 2346 script_badge_value, ActionInfo::TYPE_SCRIPT_BADGE, error); |
| 2349 if (!script_badge_.get()) | 2347 if (!script_badge_.get()) |
| 2350 return false; // Failed to parse script badge definition. | 2348 return false; // Failed to parse script badge definition. |
| 2351 } else { | 2349 } else { |
| 2352 script_badge_.reset( | 2350 script_badge_.reset(new ActionInfo(ActionInfo::TYPE_SCRIPT_BADGE)); |
| 2353 new ExtensionAction(id(), ExtensionAction::TYPE_SCRIPT_BADGE)); | |
| 2354 } | 2351 } |
| 2355 | 2352 |
| 2356 // Script badges always use their extension's title and icon so users can rely | 2353 // Script badges always use their extension's title and icon so users can rely |
| 2357 // on the visual appearance to know which extension is running. This isn't | 2354 // on the visual appearance to know which extension is running. This isn't |
| 2358 // bulletproof since an malicious extension could use a different 16x16 icon | 2355 // bulletproof since an malicious extension could use a different 16x16 icon |
| 2359 // that matches the icon of a trusted extension, and users wouldn't be warned | 2356 // that matches the icon of a trusted extension, and users wouldn't be warned |
| 2360 // during installation. | 2357 // during installation. |
| 2361 | 2358 |
| 2362 if (!script_badge_->GetTitle(ExtensionAction::kDefaultTabId).empty()) { | 2359 if (!script_badge_->default_title.empty()) { |
| 2363 install_warnings_.push_back( | 2360 install_warnings_.push_back( |
| 2364 InstallWarning(InstallWarning::FORMAT_TEXT, | 2361 InstallWarning(InstallWarning::FORMAT_TEXT, |
| 2365 errors::kScriptBadgeTitleIgnored)); | 2362 errors::kScriptBadgeTitleIgnored)); |
| 2366 } | 2363 } |
| 2367 script_badge_->SetTitle(ExtensionAction::kDefaultTabId, name()); | 2364 script_badge_->default_title = name(); |
| 2368 | 2365 |
| 2369 if (!script_badge_->default_icon_path().empty()) { | 2366 if (!script_badge_->default_icon_path.empty()) { |
| 2370 install_warnings_.push_back( | 2367 install_warnings_.push_back( |
| 2371 InstallWarning(InstallWarning::FORMAT_TEXT, | 2368 InstallWarning(InstallWarning::FORMAT_TEXT, |
| 2372 errors::kScriptBadgeIconIgnored)); | 2369 errors::kScriptBadgeIconIgnored)); |
| 2373 } | 2370 } |
| 2374 std::string icon16_path = icons().Get(extension_misc::EXTENSION_ICON_BITTY, | 2371 |
| 2375 ExtensionIconSet::MATCH_EXACTLY); | 2372 script_badge_->default_icon_path = |
| 2376 if (!icon16_path.empty()) { | 2373 icons().Get(extension_misc::EXTENSION_ICON_BITTY, |
| 2377 script_badge_->set_default_icon_path(icon16_path); | 2374 ExtensionIconSet::MATCH_EXACTLY); |
| 2378 } else { | |
| 2379 script_badge_->SetIcon( | |
| 2380 ExtensionAction::kDefaultTabId, | |
| 2381 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | |
| 2382 IDR_EXTENSIONS_FAVICON)); | |
| 2383 } | |
| 2384 | 2375 |
| 2385 return true; | 2376 return true; |
| 2386 } | 2377 } |
| 2387 | 2378 |
| 2388 bool Extension::LoadFileBrowserHandlers(string16* error) { | 2379 bool Extension::LoadFileBrowserHandlers(string16* error) { |
| 2389 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) | 2380 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) |
| 2390 return true; | 2381 return true; |
| 2391 ListValue* file_browser_handlers_value = NULL; | 2382 ListValue* file_browser_handlers_value = NULL; |
| 2392 if (!manifest_->GetList(keys::kFileBrowserHandlers, | 2383 if (!manifest_->GetList(keys::kFileBrowserHandlers, |
| 2393 &file_browser_handlers_value)) { | 2384 &file_browser_handlers_value)) { |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3192 for (DictionaryValue::key_iterator it = theme_images->begin_keys(); | 3183 for (DictionaryValue::key_iterator it = theme_images->begin_keys(); |
| 3193 it != theme_images->end_keys(); ++it) { | 3184 it != theme_images->end_keys(); ++it) { |
| 3194 std::string val; | 3185 std::string val; |
| 3195 if (theme_images->GetStringWithoutPathExpansion(*it, &val)) | 3186 if (theme_images->GetStringWithoutPathExpansion(*it, &val)) |
| 3196 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val))); | 3187 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val))); |
| 3197 } | 3188 } |
| 3198 } | 3189 } |
| 3199 | 3190 |
| 3200 // Page action icons. | 3191 // Page action icons. |
| 3201 if (page_action()) { | 3192 if (page_action()) { |
| 3202 std::vector<std::string>* icon_paths = page_action()->icon_paths(); | 3193 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide( |
| 3203 for (std::vector<std::string>::iterator iter = icon_paths->begin(); | 3194 page_action()->default_icon_path))); |
| 3204 iter != icon_paths->end(); ++iter) { | |
| 3205 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter))); | |
| 3206 } | |
| 3207 } | 3195 } |
| 3208 | 3196 |
| 3209 // Browser action icons. | 3197 // Browser action icons. |
| 3210 if (browser_action()) { | 3198 if (browser_action()) { |
| 3211 std::vector<std::string>* icon_paths = browser_action()->icon_paths(); | 3199 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide( |
| 3212 for (std::vector<std::string>::iterator iter = icon_paths->begin(); | 3200 browser_action()->default_icon_path))); |
| 3213 iter != icon_paths->end(); ++iter) { | |
| 3214 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter))); | |
| 3215 } | |
| 3216 } | 3201 } |
| 3217 | 3202 |
| 3218 return image_paths; | 3203 return image_paths; |
| 3219 } | 3204 } |
| 3220 | 3205 |
| 3221 GURL Extension::GetFullLaunchURL() const { | 3206 GURL Extension::GetFullLaunchURL() const { |
| 3222 return launch_local_path().empty() ? GURL(launch_web_url()) : | 3207 return launch_local_path().empty() ? GURL(launch_web_url()) : |
| 3223 url().Resolve(launch_local_path()); | 3208 url().Resolve(launch_local_path()); |
| 3224 } | 3209 } |
| 3225 | 3210 |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 | 3950 |
| 3966 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3951 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3967 const Extension* extension, | 3952 const Extension* extension, |
| 3968 const PermissionSet* permissions, | 3953 const PermissionSet* permissions, |
| 3969 Reason reason) | 3954 Reason reason) |
| 3970 : reason(reason), | 3955 : reason(reason), |
| 3971 extension(extension), | 3956 extension(extension), |
| 3972 permissions(permissions) {} | 3957 permissions(permissions) {} |
| 3973 | 3958 |
| 3974 } // namespace extensions | 3959 } // namespace extensions |
| OLD | NEW |