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 "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_path.h" | 10 #include "base/file_path.h" |
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 *error = ASCIIToUTF16(errors::kInvalidPageAction); | 2297 *error = ASCIIToUTF16(errors::kInvalidPageAction); |
2298 return false; | 2298 return false; |
2299 } | 2299 } |
2300 } | 2300 } |
2301 | 2301 |
2302 // If page_action_value is not NULL, then there was a valid page action. | 2302 // If page_action_value is not NULL, then there was a valid page action. |
2303 if (page_action_value) { | 2303 if (page_action_value) { |
2304 page_action_ = LoadExtensionActionHelper(page_action_value, error); | 2304 page_action_ = LoadExtensionActionHelper(page_action_value, error); |
2305 if (!page_action_.get()) | 2305 if (!page_action_.get()) |
2306 return false; // Failed to parse page action definition. | 2306 return false; // Failed to parse page action definition. |
2307 extension_action_api_type_ = ExtensionAction::TYPE_PAGE; | 2307 declared_action_type_ = ExtensionAction::TYPE_PAGE; |
2308 | 2308 |
2309 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2309 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2310 switches::kEnableBrowserActionsForAll)) { | 2310 switches::kEnableBrowserActionsForAll)) { |
2311 browser_action_ = page_action_.Pass(); | 2311 browser_action_ = page_action_.Pass(); |
2312 // extension_action_api_type_ stays the same; that's the point. | 2312 // declared_action_type_ stays the same; that's the point. |
2313 } | 2313 } |
2314 } | 2314 } |
2315 | 2315 |
2316 return true; | 2316 return true; |
2317 } | 2317 } |
2318 | 2318 |
2319 bool Extension::LoadBrowserAction(string16* error) { | 2319 bool Extension::LoadBrowserAction(string16* error) { |
2320 if (!manifest_->HasKey(keys::kBrowserAction)) | 2320 if (!manifest_->HasKey(keys::kBrowserAction)) |
2321 return true; | 2321 return true; |
2322 DictionaryValue* browser_action_value = NULL; | 2322 DictionaryValue* browser_action_value = NULL; |
2323 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) { | 2323 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) { |
2324 *error = ASCIIToUTF16(errors::kInvalidBrowserAction); | 2324 *error = ASCIIToUTF16(errors::kInvalidBrowserAction); |
2325 return false; | 2325 return false; |
2326 } | 2326 } |
2327 | 2327 |
2328 browser_action_ = LoadExtensionActionHelper(browser_action_value, error); | 2328 browser_action_ = LoadExtensionActionHelper(browser_action_value, error); |
2329 if (!browser_action_.get()) | 2329 if (!browser_action_.get()) |
2330 return false; // Failed to parse browser action definition. | 2330 return false; // Failed to parse browser action definition. |
2331 extension_action_api_type_ = ExtensionAction::TYPE_BROWSER; | 2331 declared_action_type_ = ExtensionAction::TYPE_BROWSER; |
2332 return true; | 2332 return true; |
2333 } | 2333 } |
2334 | 2334 |
2335 bool Extension::LoadFileBrowserHandlers(string16* error) { | 2335 bool Extension::LoadFileBrowserHandlers(string16* error) { |
2336 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) | 2336 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) |
2337 return true; | 2337 return true; |
2338 ListValue* file_browser_handlers_value = NULL; | 2338 ListValue* file_browser_handlers_value = NULL; |
2339 if (!manifest_->GetList(keys::kFileBrowserHandlers, | 2339 if (!manifest_->GetList(keys::kFileBrowserHandlers, |
2340 &file_browser_handlers_value)) { | 2340 &file_browser_handlers_value)) { |
2341 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler); | 2341 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 // See http://b/4946060 for more details. | 2819 // See http://b/4946060 for more details. |
2820 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); | 2820 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); |
2821 } | 2821 } |
2822 | 2822 |
2823 Extension::Extension(const FilePath& path, | 2823 Extension::Extension(const FilePath& path, |
2824 scoped_ptr<extensions::Manifest> manifest) | 2824 scoped_ptr<extensions::Manifest> manifest) |
2825 : manifest_version_(0), | 2825 : manifest_version_(0), |
2826 incognito_split_mode_(false), | 2826 incognito_split_mode_(false), |
2827 offline_enabled_(false), | 2827 offline_enabled_(false), |
2828 converted_from_user_script_(false), | 2828 converted_from_user_script_(false), |
2829 extension_action_api_type_(ExtensionAction::TYPE_NONE), | 2829 declared_action_type_(ExtensionAction::TYPE_NONE), |
2830 background_page_is_persistent_(true), | 2830 background_page_is_persistent_(true), |
2831 allow_background_js_access_(true), | 2831 allow_background_js_access_(true), |
2832 manifest_(manifest.release()), | 2832 manifest_(manifest.release()), |
2833 is_storage_isolated_(false), | 2833 is_storage_isolated_(false), |
2834 launch_container_(extension_misc::LAUNCH_TAB), | 2834 launch_container_(extension_misc::LAUNCH_TAB), |
2835 launch_width_(0), | 2835 launch_width_(0), |
2836 launch_height_(0), | 2836 launch_height_(0), |
2837 wants_file_access_(false), | 2837 wants_file_access_(false), |
2838 creation_flags_(0) { | 2838 creation_flags_(0) { |
2839 DCHECK(path.empty() || path.IsAbsolute()); | 2839 DCHECK(path.empty() || path.IsAbsolute()); |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 already_disabled(false), | 3669 already_disabled(false), |
3670 extension(extension) {} | 3670 extension(extension) {} |
3671 | 3671 |
3672 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3672 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3673 const Extension* extension, | 3673 const Extension* extension, |
3674 const ExtensionPermissionSet* permissions, | 3674 const ExtensionPermissionSet* permissions, |
3675 Reason reason) | 3675 Reason reason) |
3676 : reason(reason), | 3676 : reason(reason), |
3677 extension(extension), | 3677 extension(extension), |
3678 permissions(permissions) {} | 3678 permissions(permissions) {} |
OLD | NEW |