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

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

Issue 10382216: Remove browser-actions-for-all flag and replace funcionality with action-box. (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
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 2086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 } 2097 }
2098 } 2098 }
2099 2099
2100 // If page_action_value is not NULL, then there was a valid page action. 2100 // If page_action_value is not NULL, then there was a valid page action.
2101 if (page_action_value) { 2101 if (page_action_value) {
2102 page_action_ = LoadExtensionActionHelper(page_action_value, error); 2102 page_action_ = LoadExtensionActionHelper(page_action_value, error);
2103 if (!page_action_.get()) 2103 if (!page_action_.get())
2104 return false; // Failed to parse page action definition. 2104 return false; // Failed to parse page action definition.
2105 declared_action_type_ = ExtensionAction::TYPE_PAGE; 2105 declared_action_type_ = ExtensionAction::TYPE_PAGE;
2106 2106
2107 // The action box changes the meaning of the page action area, so we need
2108 // to convert page actions into browser actions.
2107 if (CommandLine::ForCurrentProcess()->HasSwitch( 2109 if (CommandLine::ForCurrentProcess()->HasSwitch(
2108 switches::kEnableBrowserActionsForAll)) { 2110 switches::kEnableActionBox)) {
2109 browser_action_ = page_action_.Pass(); 2111 browser_action_ = page_action_.Pass();
2110 // declared_action_type_ stays the same; that's the point. 2112 // declared_action_type_ stays the same; that's the point.
2111 } 2113 }
2112 } 2114 }
2113 2115
2114 return true; 2116 return true;
2115 } 2117 }
2116 2118
2117 bool Extension::LoadBrowserAction(string16* error) { 2119 bool Extension::LoadBrowserAction(string16* error) {
2118 if (!manifest_->HasKey(keys::kBrowserAction)) 2120 if (!manifest_->HasKey(keys::kBrowserAction))
2119 return true; 2121 return true;
2120 DictionaryValue* browser_action_value = NULL; 2122 DictionaryValue* browser_action_value = NULL;
2121 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) { 2123 if (!manifest_->GetDictionary(keys::kBrowserAction, &browser_action_value)) {
2122 *error = ASCIIToUTF16(errors::kInvalidBrowserAction); 2124 *error = ASCIIToUTF16(errors::kInvalidBrowserAction);
2123 return false; 2125 return false;
2124 } 2126 }
2125 2127
2126 browser_action_ = LoadExtensionActionHelper(browser_action_value, error); 2128 browser_action_ = LoadExtensionActionHelper(browser_action_value, error);
2127 if (!browser_action_.get()) 2129 if (!browser_action_.get())
2128 return false; // Failed to parse browser action definition. 2130 return false; // Failed to parse browser action definition.
2129 declared_action_type_ = ExtensionAction::TYPE_BROWSER; 2131 declared_action_type_ = ExtensionAction::TYPE_BROWSER;
2130 return true; 2132 return true;
2131 } 2133 }
2132 2134
2133 void Extension::GenerateBrowserActionIfPossible() {
2134 // It only makes sense to generate brower actions for extensions that are
2135 // shown in chrome://extensions.
2136 if (!ShouldDisplayInExtensionSettings())
2137 return;
2138
2139 // Hosted and platform apps are shown in extension settings, but we don't
2140 // want to generate browser actions for those either, since they can't define
2141 // browser actions.
2142 if (is_app())
2143 return;
2144
2145 browser_action_.reset(new ExtensionAction(id()));
2146 browser_action_->SetTitle(ExtensionAction::kDefaultTabId, name());
2147 }
2148
2149 bool Extension::LoadFileBrowserHandlers(string16* error) { 2135 bool Extension::LoadFileBrowserHandlers(string16* error) {
2150 if (!manifest_->HasKey(keys::kFileBrowserHandlers)) 2136 if (!manifest_->HasKey(keys::kFileBrowserHandlers))
2151 return true; 2137 return true;
2152 ListValue* file_browser_handlers_value = NULL; 2138 ListValue* file_browser_handlers_value = NULL;
2153 if (!manifest_->GetList(keys::kFileBrowserHandlers, 2139 if (!manifest_->GetList(keys::kFileBrowserHandlers,
2154 &file_browser_handlers_value)) { 2140 &file_browser_handlers_value)) {
2155 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler); 2141 *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
2156 return false; 2142 return false;
2157 } 2143 }
2158 file_browser_handlers_.reset( 2144 file_browser_handlers_.reset(
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 2885
2900 if (!LoadSharedFeatures(api_permissions, error)) 2886 if (!LoadSharedFeatures(api_permissions, error))
2901 return false; 2887 return false;
2902 2888
2903 if (!LoadExtensionFeatures(api_permissions, error)) 2889 if (!LoadExtensionFeatures(api_permissions, error))
2904 return false; 2890 return false;
2905 2891
2906 if (!LoadThemeFeatures(error)) 2892 if (!LoadThemeFeatures(error))
2907 return false; 2893 return false;
2908 2894
2909 if (CommandLine::ForCurrentProcess()->HasSwitch(
2910 switches::kEnableBrowserActionsForAll) &&
2911 !browser_action()) {
2912 GenerateBrowserActionIfPossible();
2913 }
2914
2915 if (HasMultipleUISurfaces()) { 2895 if (HasMultipleUISurfaces()) {
2916 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 2896 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
2917 return false; 2897 return false;
2918 } 2898 }
2919 2899
2920 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( 2900 runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
2921 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet())); 2901 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()));
2922 required_permission_set_ = new ExtensionPermissionSet( 2902 required_permission_set_ = new ExtensionPermissionSet(
2923 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()); 2903 this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet());
2924 optional_permission_set_ = new ExtensionPermissionSet( 2904 optional_permission_set_ = new ExtensionPermissionSet(
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 already_disabled(false), 3535 already_disabled(false),
3556 extension(extension) {} 3536 extension(extension) {}
3557 3537
3558 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3538 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3559 const Extension* extension, 3539 const Extension* extension,
3560 const ExtensionPermissionSet* permissions, 3540 const ExtensionPermissionSet* permissions,
3561 Reason reason) 3541 Reason reason)
3562 : reason(reason), 3542 : reason(reason),
3563 extension(extension), 3543 extension(extension),
3564 permissions(permissions) {} 3544 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698