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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 10264004: Generate a browser action for any extension which doesn't have a browser or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make comment make more sense in extension.cc context Created 8 years, 7 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 extension_action_api_type_ = ExtensionAction::TYPE_BROWSER;
2332 return true; 2332 return true;
2333 } 2333 }
2334 2334
2335 void Extension::GenerateBrowserActionIfPossible() {
Aaron Boodman 2012/04/30 03:27:22 IfNecessary?
not at google - send to devlin 2012/04/30 04:48:22 Well, IfPossible is I think more accurate. I like
2336 // It only makes sense to generate brower actions for extensions that are
2337 // shown in chrome://extensions.
2338 if (!ShouldDisplayInExtensionSettings())
2339 return;
2340
2341 // Hosted and platform apps are shown in extension settings, but we don't
2342 // want to generate browser actions for those either, since they can't define
2343 // browser actions.
2344 if (is_app())
2345 return;
2346
2347 browser_action_.reset(new ExtensionAction(id()));
2348 browser_action_->SetTitle(ExtensionAction::kDefaultTabId, name());
2349 }
2350
2335 bool Extension::LoadFileBrowserHandlers(string16* error) { 2351 bool Extension::LoadFileBrowserHandlers(string16* error) {
2336 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) 2352 if (!manifest_->HasKey(keys::kFileBrowserHandlers))
2337 return true; 2353 return true;
2338 ListValue* file_browser_handlers_value = NULL; 2354 ListValue* file_browser_handlers_value = NULL;
2339 if (!manifest_->GetList(keys::kFileBrowserHandlers, 2355 if (!manifest_->GetList(keys::kFileBrowserHandlers,
2340 &file_browser_handlers_value)) { 2356 &file_browser_handlers_value)) {
2341 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler); 2357 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
2342 return false; 2358 return false;
2343 } 2359 }
2344 file_browser_handlers_.reset( 2360 file_browser_handlers_.reset(
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 3090
3075 if (!LoadSharedFeatures(api_permissions, error)) 3091 if (!LoadSharedFeatures(api_permissions, error))
3076 return false; 3092 return false;
3077 3093
3078 if (!LoadExtensionFeatures(api_permissions, error)) 3094 if (!LoadExtensionFeatures(api_permissions, error))
3079 return false; 3095 return false;
3080 3096
3081 if (!LoadThemeFeatures(error)) 3097 if (!LoadThemeFeatures(error))
3082 return false; 3098 return false;
3083 3099
3100 if (CommandLine::ForCurrentProcess()->HasSwitch(
3101 switches::kEnableBrowserActionsForAll) &&
3102 !browser_action()) {
3103 GenerateBrowserActionIfPossible();
3104 }
3105
3084 if (HasMultipleUISurfaces()) { 3106 if (HasMultipleUISurfaces()) {
3085 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 3107 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
3086 return false; 3108 return false;
3087 } 3109 }
3088 3110
3089 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( 3111 runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
3090 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet())); 3112 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()));
3091 required_permission_set_ = new ExtensionPermissionSet( 3113 required_permission_set_ = new ExtensionPermissionSet(
3092 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()); 3114 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet());
3093 optional_permission_set_ = new ExtensionPermissionSet( 3115 optional_permission_set_ = new ExtensionPermissionSet(
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 const std::string& id, 3660 const std::string& id,
3639 const FilePath& path, 3661 const FilePath& path,
3640 Extension::Location location) 3662 Extension::Location location)
3641 : extension_id(id), 3663 : extension_id(id),
3642 extension_path(path), 3664 extension_path(path),
3643 extension_location(location) { 3665 extension_location(location) {
3644 if (manifest) 3666 if (manifest)
3645 extension_manifest.reset(manifest->DeepCopy()); 3667 extension_manifest.reset(manifest->DeepCopy());
3646 } 3668 }
3647 3669
3670 bool Extension::ShouldDisplayInExtensionSettings() const {
3671 // Don't show for themes since the settings UI isn't really useful for them.
3672 if (is_theme())
3673 return false;
3674
3675 // Don't show component extensions because they are only extensions as an
3676 // implementation detail of Chrome.
3677 if (location() == Extension::COMPONENT &&
3678 !CommandLine::ForCurrentProcess()->HasSwitch(
3679 switches::kShowComponentExtensionOptions))
3680 return false;
3681
3682 // Always show unpacked extensions and apps.
3683 if (location() == Extension::LOAD)
3684 return true;
3685
3686 // Unless they are unpacked, never show hosted apps. Note: We intentionally
3687 // show packaged apps and platform apps because there are some pieces of
3688 // functionality that are only available in chrome://extensions/ but which
3689 // are needed for packaged and platform apps. For example, inspecting
3690 // background pages. See http://crbug.com/116134.
3691 if (is_hosted_app())
3692 return false;
3693
3694 return true;
3695 }
3696
3648 ExtensionInfo::~ExtensionInfo() {} 3697 ExtensionInfo::~ExtensionInfo() {}
3649 3698
3650 Extension::RuntimeData::RuntimeData() {} 3699 Extension::RuntimeData::RuntimeData() {}
3651 Extension::RuntimeData::RuntimeData(const ExtensionPermissionSet* active) 3700 Extension::RuntimeData::RuntimeData(const ExtensionPermissionSet* active)
3652 : active_permissions_(active) {} 3701 : active_permissions_(active) {}
3653 Extension::RuntimeData::~RuntimeData() {} 3702 Extension::RuntimeData::~RuntimeData() {}
3654 3703
3655 scoped_refptr<const ExtensionPermissionSet> 3704 scoped_refptr<const ExtensionPermissionSet>
3656 Extension::RuntimeData::GetActivePermissions() const { 3705 Extension::RuntimeData::GetActivePermissions() const {
3657 return active_permissions_; 3706 return active_permissions_;
(...skipping 11 matching lines...) Expand all
3669 already_disabled(false), 3718 already_disabled(false),
3670 extension(extension) {} 3719 extension(extension) {}
3671 3720
3672 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3721 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3673 const Extension* extension, 3722 const Extension* extension,
3674 const ExtensionPermissionSet* permissions, 3723 const ExtensionPermissionSet* permissions,
3675 Reason reason) 3724 Reason reason)
3676 : reason(reason), 3725 : reason(reason),
3677 extension(extension), 3726 extension(extension),
3678 permissions(permissions) {} 3727 permissions(permissions) {}
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698