| 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" | 
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 336     UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; | 336     UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; | 
| 337 | 337 | 
| 338 Extension::Requirements::Requirements() | 338 Extension::Requirements::Requirements() | 
| 339     : webgl(false), | 339     : webgl(false), | 
| 340       css3d(false), | 340       css3d(false), | 
| 341       npapi(false) { | 341       npapi(false) { | 
| 342 } | 342 } | 
| 343 | 343 | 
| 344 Extension::Requirements::~Requirements() {} | 344 Extension::Requirements::~Requirements() {} | 
| 345 | 345 | 
| 346 Extension::InputComponentInfo::InputComponentInfo() |  | 
| 347     : type(INPUT_COMPONENT_TYPE_NONE), |  | 
| 348       shortcut_alt(false), |  | 
| 349       shortcut_ctrl(false), |  | 
| 350       shortcut_shift(false) { |  | 
| 351 } |  | 
| 352 |  | 
| 353 Extension::InputComponentInfo::~InputComponentInfo() {} |  | 
| 354 |  | 
| 355 Extension::TtsVoice::TtsVoice() {} | 346 Extension::TtsVoice::TtsVoice() {} | 
| 356 Extension::TtsVoice::~TtsVoice() {} | 347 Extension::TtsVoice::~TtsVoice() {} | 
| 357 | 348 | 
| 358 Extension::OAuth2Info::OAuth2Info() {} | 349 Extension::OAuth2Info::OAuth2Info() {} | 
| 359 Extension::OAuth2Info::~OAuth2Info() {} | 350 Extension::OAuth2Info::~OAuth2Info() {} | 
| 360 | 351 | 
| 361 Extension::ActionInfo::ActionInfo() {} | 352 Extension::ActionInfo::ActionInfo() {} | 
| 362 Extension::ActionInfo::~ActionInfo() {} | 353 Extension::ActionInfo::~ActionInfo() {} | 
| 363 | 354 | 
| 364 Extension::FileHandlerInfo::FileHandlerInfo() {} | 355 Extension::FileHandlerInfo::FileHandlerInfo() {} | 
| (...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2784 } | 2775 } | 
| 2785 | 2776 | 
| 2786 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions, | 2777 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions, | 
| 2787                                       string16* error) { | 2778                                       string16* error) { | 
| 2788   if (manifest_->HasKey(keys::kConvertedFromUserScript)) | 2779   if (manifest_->HasKey(keys::kConvertedFromUserScript)) | 
| 2789     manifest_->GetBoolean(keys::kConvertedFromUserScript, | 2780     manifest_->GetBoolean(keys::kConvertedFromUserScript, | 
| 2790                           &converted_from_user_script_); | 2781                           &converted_from_user_script_); | 
| 2791 | 2782 | 
| 2792   if (!LoadManifestHandlerFeatures(error) || | 2783   if (!LoadManifestHandlerFeatures(error) || | 
| 2793       !LoadDevToolsPage(error) || | 2784       !LoadDevToolsPage(error) || | 
| 2794       !LoadInputComponents(*api_permissions, error) || |  | 
| 2795       !LoadContentScripts(error) || | 2785       !LoadContentScripts(error) || | 
| 2796       !LoadPageAction(error) || | 2786       !LoadPageAction(error) || | 
| 2797       !LoadBrowserAction(error) || | 2787       !LoadBrowserAction(error) || | 
| 2798       !LoadSystemIndicator(api_permissions, error) || | 2788       !LoadSystemIndicator(api_permissions, error) || | 
| 2799       !LoadScriptBadge(error) || | 2789       !LoadScriptBadge(error) || | 
| 2800       !LoadChromeURLOverrides(error) || | 2790       !LoadChromeURLOverrides(error) || | 
| 2801       !LoadTextToSpeechVoices(error) || | 2791       !LoadTextToSpeechVoices(error) || | 
| 2802       !LoadIncognitoMode(error) || | 2792       !LoadIncognitoMode(error) || | 
| 2803       !LoadFileHandlers(error) || | 2793       !LoadFileHandlers(error) || | 
| 2804       !LoadContentSecurityPolicy(error)) | 2794       !LoadContentSecurityPolicy(error)) | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 2824     return true; | 2814     return true; | 
| 2825   std::string devtools_str; | 2815   std::string devtools_str; | 
| 2826   if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) { | 2816   if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) { | 
| 2827     *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); | 2817     *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); | 
| 2828     return false; | 2818     return false; | 
| 2829   } | 2819   } | 
| 2830   devtools_url_ = GetResourceURL(devtools_str); | 2820   devtools_url_ = GetResourceURL(devtools_str); | 
| 2831   return true; | 2821   return true; | 
| 2832 } | 2822 } | 
| 2833 | 2823 | 
| 2834 bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions, |  | 
| 2835                                     string16* error) { |  | 
| 2836   if (!manifest_->HasKey(keys::kInputComponents)) |  | 
| 2837     return true; |  | 
| 2838   ListValue* list_value = NULL; |  | 
| 2839   if (!manifest_->GetList(keys::kInputComponents, &list_value)) { |  | 
| 2840     *error = ASCIIToUTF16(errors::kInvalidInputComponents); |  | 
| 2841     return false; |  | 
| 2842   } |  | 
| 2843 |  | 
| 2844   for (size_t i = 0; i < list_value->GetSize(); ++i) { |  | 
| 2845     DictionaryValue* module_value = NULL; |  | 
| 2846     std::string name_str; |  | 
| 2847     InputComponentType type; |  | 
| 2848     std::string id_str; |  | 
| 2849     std::string description_str; |  | 
| 2850     std::string language_str; |  | 
| 2851     std::set<std::string> layouts; |  | 
| 2852     std::string shortcut_keycode_str; |  | 
| 2853     bool shortcut_alt = false; |  | 
| 2854     bool shortcut_ctrl = false; |  | 
| 2855     bool shortcut_shift = false; |  | 
| 2856 |  | 
| 2857     if (!list_value->GetDictionary(i, &module_value)) { |  | 
| 2858       *error = ASCIIToUTF16(errors::kInvalidInputComponents); |  | 
| 2859       return false; |  | 
| 2860     } |  | 
| 2861 |  | 
| 2862     // Get input_components[i].name. |  | 
| 2863     if (!module_value->GetString(keys::kName, &name_str)) { |  | 
| 2864       *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2865           errors::kInvalidInputComponentName, base::IntToString(i)); |  | 
| 2866       return false; |  | 
| 2867     } |  | 
| 2868 |  | 
| 2869     // Get input_components[i].type. |  | 
| 2870     std::string type_str; |  | 
| 2871     if (module_value->GetString(keys::kType, &type_str)) { |  | 
| 2872       if (type_str == "ime") { |  | 
| 2873         type = INPUT_COMPONENT_TYPE_IME; |  | 
| 2874       } else { |  | 
| 2875         *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2876             errors::kInvalidInputComponentType, base::IntToString(i)); |  | 
| 2877         return false; |  | 
| 2878       } |  | 
| 2879     } else { |  | 
| 2880       *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2881           errors::kInvalidInputComponentType, base::IntToString(i)); |  | 
| 2882       return false; |  | 
| 2883     } |  | 
| 2884 |  | 
| 2885     // Get input_components[i].id. |  | 
| 2886     if (!module_value->GetString(keys::kId, &id_str)) { |  | 
| 2887       id_str = ""; |  | 
| 2888     } |  | 
| 2889 |  | 
| 2890     // Get input_components[i].description. |  | 
| 2891     if (!module_value->GetString(keys::kDescription, &description_str)) { |  | 
| 2892       *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2893           errors::kInvalidInputComponentDescription, base::IntToString(i)); |  | 
| 2894       return false; |  | 
| 2895     } |  | 
| 2896     // Get input_components[i].language. |  | 
| 2897     if (!module_value->GetString(keys::kLanguage, &language_str)) { |  | 
| 2898       language_str = ""; |  | 
| 2899     } |  | 
| 2900 |  | 
| 2901     // Get input_components[i].layouts. |  | 
| 2902     ListValue* layouts_value = NULL; |  | 
| 2903     if (!module_value->GetList(keys::kLayouts, &layouts_value)) { |  | 
| 2904       *error = ASCIIToUTF16(errors::kInvalidInputComponentLayouts); |  | 
| 2905       return false; |  | 
| 2906     } |  | 
| 2907 |  | 
| 2908     for (size_t j = 0; j < layouts_value->GetSize(); ++j) { |  | 
| 2909       std::string layout_name_str; |  | 
| 2910       if (!layouts_value->GetString(j, &layout_name_str)) { |  | 
| 2911         *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2912             errors::kInvalidInputComponentLayoutName, base::IntToString(i), |  | 
| 2913             base::IntToString(j)); |  | 
| 2914         return false; |  | 
| 2915       } |  | 
| 2916       layouts.insert(layout_name_str); |  | 
| 2917     } |  | 
| 2918 |  | 
| 2919     if (module_value->HasKey(keys::kShortcutKey)) { |  | 
| 2920       DictionaryValue* shortcut_value = NULL; |  | 
| 2921       if (!module_value->GetDictionary(keys::kShortcutKey, &shortcut_value)) { |  | 
| 2922         *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2923             errors::kInvalidInputComponentShortcutKey, base::IntToString(i)); |  | 
| 2924         return false; |  | 
| 2925       } |  | 
| 2926 |  | 
| 2927       // Get input_components[i].shortcut_keycode. |  | 
| 2928       if (!shortcut_value->GetString(keys::kKeycode, &shortcut_keycode_str)) { |  | 
| 2929         *error = ErrorUtils::FormatErrorMessageUTF16( |  | 
| 2930             errors::kInvalidInputComponentShortcutKeycode, |  | 
| 2931             base::IntToString(i)); |  | 
| 2932         return false; |  | 
| 2933       } |  | 
| 2934 |  | 
| 2935       // Get input_components[i].shortcut_alt. |  | 
| 2936       if (!shortcut_value->GetBoolean(keys::kAltKey, &shortcut_alt)) { |  | 
| 2937         shortcut_alt = false; |  | 
| 2938       } |  | 
| 2939 |  | 
| 2940       // Get input_components[i].shortcut_ctrl. |  | 
| 2941       if (!shortcut_value->GetBoolean(keys::kCtrlKey, &shortcut_ctrl)) { |  | 
| 2942         shortcut_ctrl = false; |  | 
| 2943       } |  | 
| 2944 |  | 
| 2945       // Get input_components[i].shortcut_shift. |  | 
| 2946       if (!shortcut_value->GetBoolean(keys::kShiftKey, &shortcut_shift)) { |  | 
| 2947         shortcut_shift = false; |  | 
| 2948       } |  | 
| 2949     } |  | 
| 2950 |  | 
| 2951     input_components_.push_back(InputComponentInfo()); |  | 
| 2952     input_components_.back().name = name_str; |  | 
| 2953     input_components_.back().type = type; |  | 
| 2954     input_components_.back().id = id_str; |  | 
| 2955     input_components_.back().description = description_str; |  | 
| 2956     input_components_.back().language = language_str; |  | 
| 2957     input_components_.back().layouts.insert(layouts.begin(), layouts.end()); |  | 
| 2958     input_components_.back().shortcut_keycode = shortcut_keycode_str; |  | 
| 2959     input_components_.back().shortcut_alt = shortcut_alt; |  | 
| 2960     input_components_.back().shortcut_ctrl = shortcut_ctrl; |  | 
| 2961     input_components_.back().shortcut_shift = shortcut_shift; |  | 
| 2962   } |  | 
| 2963 |  | 
| 2964   return true; |  | 
| 2965 } |  | 
| 2966 |  | 
| 2967 bool Extension::LoadContentScripts(string16* error) { | 2824 bool Extension::LoadContentScripts(string16* error) { | 
| 2968   if (!manifest_->HasKey(keys::kContentScripts)) | 2825   if (!manifest_->HasKey(keys::kContentScripts)) | 
| 2969     return true; | 2826     return true; | 
| 2970   ListValue* list_value; | 2827   ListValue* list_value; | 
| 2971   if (!manifest_->GetList(keys::kContentScripts, &list_value)) { | 2828   if (!manifest_->GetList(keys::kContentScripts, &list_value)) { | 
| 2972     *error = ASCIIToUTF16(errors::kInvalidContentScriptsList); | 2829     *error = ASCIIToUTF16(errors::kInvalidContentScriptsList); | 
| 2973     return false; | 2830     return false; | 
| 2974   } | 2831   } | 
| 2975 | 2832 | 
| 2976   for (size_t i = 0; i < list_value->GetSize(); ++i) { | 2833   for (size_t i = 0; i < list_value->GetSize(); ++i) { | 
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4048 | 3905 | 
| 4049 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3906 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 
| 4050     const Extension* extension, | 3907     const Extension* extension, | 
| 4051     const PermissionSet* permissions, | 3908     const PermissionSet* permissions, | 
| 4052     Reason reason) | 3909     Reason reason) | 
| 4053     : reason(reason), | 3910     : reason(reason), | 
| 4054       extension(extension), | 3911       extension(extension), | 
| 4055       permissions(permissions) {} | 3912       permissions(permissions) {} | 
| 4056 | 3913 | 
| 4057 }   // namespace extensions | 3914 }   // namespace extensions | 
| OLD | NEW | 
|---|