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

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: . 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::GenerateBrowserAction() {
2336 browser_action_.reset(new ExtensionAction(id()));
2337 browser_action_->SetTitle(ExtensionAction::kDefaultTabId, name());
Aaron Boodman 2012/04/30 02:37:04 If there's no icon, do we currently display the pu
not at google - send to devlin 2012/04/30 03:18:01 We sure do! I was happy to find this.
2338 }
2339
2335 bool Extension::LoadFileBrowserHandlers(string16* error) { 2340 bool Extension::LoadFileBrowserHandlers(string16* error) {
2336 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) 2341 if (!manifest_->HasKey(keys::kFileBrowserHandlers))
2337 return true; 2342 return true;
2338 ListValue* file_browser_handlers_value = NULL; 2343 ListValue* file_browser_handlers_value = NULL;
2339 if (!manifest_->GetList(keys::kFileBrowserHandlers, 2344 if (!manifest_->GetList(keys::kFileBrowserHandlers,
2340 &file_browser_handlers_value)) { 2345 &file_browser_handlers_value)) {
2341 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler); 2346 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
2342 return false; 2347 return false;
2343 } 2348 }
2344 file_browser_handlers_.reset( 2349 file_browser_handlers_.reset(
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 3079
3075 if (!LoadSharedFeatures(api_permissions, error)) 3080 if (!LoadSharedFeatures(api_permissions, error))
3076 return false; 3081 return false;
3077 3082
3078 if (!LoadExtensionFeatures(api_permissions, error)) 3083 if (!LoadExtensionFeatures(api_permissions, error))
3079 return false; 3084 return false;
3080 3085
3081 if (!LoadThemeFeatures(error)) 3086 if (!LoadThemeFeatures(error))
3082 return false; 3087 return false;
3083 3088
3089 if (CommandLine::ForCurrentProcess()->HasSwitch(
3090 switches::kEnableBrowserActionsForAll) &&
3091 !browser_action() &&
3092 // It only makes sense to generate brower actions for extensions that are
3093 // shown in chrome://extensions.
3094 ShouldShowInExtensionSettings() &&
3095 // Hosted and platform apps are shown in extension settings, but we don't
3096 // want to generate browser actions for those either, since they can't
3097 // define browser actions.
3098 !is_app()) {
Aaron Boodman 2012/04/30 02:37:04 Consider pulling these checks into GenerateBrowser
not at google - send to devlin 2012/04/30 03:18:01 Yeah, nicer.
3099 GenerateBrowserAction();
3100 }
3101
3084 if (HasMultipleUISurfaces()) { 3102 if (HasMultipleUISurfaces()) {
3085 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 3103 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
3086 return false; 3104 return false;
3087 } 3105 }
3088 3106
3089 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( 3107 runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
3090 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet())); 3108 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()));
3091 required_permission_set_ = new ExtensionPermissionSet( 3109 required_permission_set_ = new ExtensionPermissionSet(
3092 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()); 3110 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet());
3093 optional_permission_set_ = new ExtensionPermissionSet( 3111 optional_permission_set_ = new ExtensionPermissionSet(
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 const std::string& id, 3656 const std::string& id,
3639 const FilePath& path, 3657 const FilePath& path,
3640 Extension::Location location) 3658 Extension::Location location)
3641 : extension_id(id), 3659 : extension_id(id),
3642 extension_path(path), 3660 extension_path(path),
3643 extension_location(location) { 3661 extension_location(location) {
3644 if (manifest) 3662 if (manifest)
3645 extension_manifest.reset(manifest->DeepCopy()); 3663 extension_manifest.reset(manifest->DeepCopy());
3646 } 3664 }
3647 3665
3666 bool Extension::ShouldDisplayInExtensionSettings() const {
3667 // Don't show themes since this page's UI isn't really useful for themes.
3668 if (is_theme())
3669 return false;
3670
3671 // Don't show component extensions because they are only extensions as an
3672 // implementation detail of Chrome.
3673 if (location() == Extension::COMPONENT &&
3674 !CommandLine::ForCurrentProcess()->HasSwitch(
3675 switches::kShowComponentExtensionOptions))
3676 return false;
3677
3678 // Always show unpacked extensions and apps.
3679 if (location() == Extension::LOAD)
3680 return true;
3681
3682 // Unless they are unpacked, never show hosted apps. Note: We intentionally
3683 // show packaged apps and platform apps because there are some pieces of
3684 // functionality that are only available in chrome://extensions/ but which
3685 // are needed for packaged and platform apps. For example, inspecting
3686 // background pages. See http://crbug.com/116134.
3687 if (is_hosted_app())
3688 return false;
3689
3690 return true;
3691 }
3692
3648 ExtensionInfo::~ExtensionInfo() {} 3693 ExtensionInfo::~ExtensionInfo() {}
3649 3694
3650 Extension::RuntimeData::RuntimeData() {} 3695 Extension::RuntimeData::RuntimeData() {}
3651 Extension::RuntimeData::RuntimeData(const ExtensionPermissionSet* active) 3696 Extension::RuntimeData::RuntimeData(const ExtensionPermissionSet* active)
3652 : active_permissions_(active) {} 3697 : active_permissions_(active) {}
3653 Extension::RuntimeData::~RuntimeData() {} 3698 Extension::RuntimeData::~RuntimeData() {}
3654 3699
3655 scoped_refptr<const ExtensionPermissionSet> 3700 scoped_refptr<const ExtensionPermissionSet>
3656 Extension::RuntimeData::GetActivePermissions() const { 3701 Extension::RuntimeData::GetActivePermissions() const {
3657 return active_permissions_; 3702 return active_permissions_;
(...skipping 11 matching lines...) Expand all
3669 already_disabled(false), 3714 already_disabled(false),
3670 extension(extension) {} 3715 extension(extension) {}
3671 3716
3672 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3717 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3673 const Extension* extension, 3718 const Extension* extension,
3674 const ExtensionPermissionSet* permissions, 3719 const ExtensionPermissionSet* permissions,
3675 Reason reason) 3720 Reason reason)
3676 : reason(reason), 3721 : reason(reason),
3677 extension(extension), 3722 extension(extension),
3678 permissions(permissions) {} 3723 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