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

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

Issue 11361189: Initial skeleton for System Indicator API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add manifest parsing and integrate with extension action api handlers. Created 8 years 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
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 <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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 if (!LoadFileHandler(*iter, *handler, error)) 2179 if (!LoadFileHandler(*iter, *handler, error))
2180 return false; 2180 return false;
2181 } else { 2181 } else {
2182 *error = ASCIIToUTF16(errors::kInvalidFileHandlers); 2182 *error = ASCIIToUTF16(errors::kInvalidFileHandlers);
2183 return false; 2183 return false;
2184 } 2184 }
2185 } 2185 }
2186 return true; 2186 return true;
2187 } 2187 }
2188 2188
2189 bool Extension::LoadExtensionFeatures(const APIPermissionSet& api_permissions, 2189 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
2190 string16* error) { 2190 string16* error) {
2191 if (manifest_->HasKey(keys::kConvertedFromUserScript)) 2191 if (manifest_->HasKey(keys::kConvertedFromUserScript))
2192 manifest_->GetBoolean(keys::kConvertedFromUserScript, 2192 manifest_->GetBoolean(keys::kConvertedFromUserScript,
2193 &converted_from_user_script_); 2193 &converted_from_user_script_);
2194 2194
2195 if (!LoadDevToolsPage(error) || 2195 if (!LoadDevToolsPage(error) ||
2196 !LoadInputComponents(api_permissions, error) || 2196 !LoadInputComponents(*api_permissions, error) ||
2197 !LoadContentScripts(error) || 2197 !LoadContentScripts(error) ||
2198 !LoadPageAction(error) || 2198 !LoadPageAction(error) ||
2199 !LoadBrowserAction(error) || 2199 !LoadBrowserAction(error) ||
2200 !LoadSystemIndicator(api_permissions, error) ||
2200 !LoadScriptBadge(error) || 2201 !LoadScriptBadge(error) ||
2201 !LoadFileBrowserHandlers(error) || 2202 !LoadFileBrowserHandlers(error) ||
2202 !LoadChromeURLOverrides(error) || 2203 !LoadChromeURLOverrides(error) ||
2203 !LoadOmnibox(error) || 2204 !LoadOmnibox(error) ||
2204 !LoadTextToSpeechVoices(error) || 2205 !LoadTextToSpeechVoices(error) ||
2205 !LoadIncognitoMode(error) || 2206 !LoadIncognitoMode(error) ||
2206 !LoadFileHandlers(error) || 2207 !LoadFileHandlers(error) ||
2207 !LoadContentSecurityPolicy(error)) 2208 !LoadContentSecurityPolicy(error))
2208 return false; 2209 return false;
2209 2210
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 return false; 2437 return false;
2437 } 2438 }
2438 2439
2439 browser_action_info_ = LoadExtensionActionInfoHelper( 2440 browser_action_info_ = LoadExtensionActionInfoHelper(
2440 browser_action_value, Extension::ActionInfo::TYPE_BROWSER, error); 2441 browser_action_value, Extension::ActionInfo::TYPE_BROWSER, error);
2441 if (!browser_action_info_.get()) 2442 if (!browser_action_info_.get())
2442 return false; // Failed to parse browser action definition. 2443 return false; // Failed to parse browser action definition.
2443 return true; 2444 return true;
2444 } 2445 }
2445 2446
2447 bool Extension::LoadSystemIndicator(APIPermissionSet* api_permissions,
2448 string16* error) {
2449 if (!manifest_->HasKey(keys::kSystemIndicator)) {
2450 // There was no manifest entry for the system indicator.
2451 return true;
2452 }
2453
2454 DictionaryValue* system_indicator_value = NULL;
2455 if (!manifest_->GetDictionary(keys::kSystemIndicator,
2456 &system_indicator_value)) {
2457 *error = ASCIIToUTF16(errors::kInvalidSystemIndicator);
2458 return false;
2459 }
2460
2461 system_indicator_info_ = LoadExtensionActionInfoHelper(
2462 system_indicator_value,
2463 Extension::ActionInfo::TYPE_SYSTEM_INDICATOR,
2464 error);
2465
2466 if (!system_indicator_info_.get()) {
2467 return false;
2468 }
2469
2470 // Because the manifest was successfully parsed, auto-grant the permission.
2471 api_permissions->insert(APIPermission::kSystemIndicator);
not at google - send to devlin 2012/11/21 23:39:23 TODO(dewittj): do this for all extension action AP
dewittj 2012/11/26 18:32:58 Done.
2472
2473 return true;
2474 }
2475
2446 bool Extension::LoadScriptBadge(string16* error) { 2476 bool Extension::LoadScriptBadge(string16* error) {
2447 if (manifest_->HasKey(keys::kScriptBadge)) { 2477 if (manifest_->HasKey(keys::kScriptBadge)) {
2448 if (!FeatureSwitch::script_badges()->IsEnabled()) { 2478 if (!FeatureSwitch::script_badges()->IsEnabled()) {
2449 // So as to not confuse developers if they specify a script badge section 2479 // So as to not confuse developers if they specify a script badge section
2450 // in the manifest, show a warning if the script badge declaration isn't 2480 // in the manifest, show a warning if the script badge declaration isn't
2451 // going to have any effect. 2481 // going to have any effect.
2452 install_warnings_.push_back( 2482 install_warnings_.push_back(
2453 InstallWarning(InstallWarning::FORMAT_TEXT, 2483 InstallWarning(InstallWarning::FORMAT_TEXT,
2454 errors::kScriptBadgeRequiresFlag)); 2484 errors::kScriptBadgeRequiresFlag));
2455 } 2485 }
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 &optional_host_permissions)) { 3287 &optional_host_permissions)) {
3258 return false; 3288 return false;
3259 } 3289 }
3260 3290
3261 if (!LoadAppIsolation(api_permissions, error)) 3291 if (!LoadAppIsolation(api_permissions, error))
3262 return false; 3292 return false;
3263 3293
3264 if (!LoadSharedFeatures(api_permissions, error)) 3294 if (!LoadSharedFeatures(api_permissions, error))
3265 return false; 3295 return false;
3266 3296
3267 if (!LoadExtensionFeatures(api_permissions, error)) 3297 if (!LoadExtensionFeatures(&api_permissions, error))
3268 return false; 3298 return false;
3269 3299
3270 if (!LoadThemeFeatures(error)) 3300 if (!LoadThemeFeatures(error))
3271 return false; 3301 return false;
3272 3302
3273 if (HasMultipleUISurfaces()) { 3303 if (HasMultipleUISurfaces()) {
3274 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 3304 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
3275 return false; 3305 return false;
3276 } 3306 }
3277 3307
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 4125
4096 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4126 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4097 const Extension* extension, 4127 const Extension* extension,
4098 const PermissionSet* permissions, 4128 const PermissionSet* permissions,
4099 Reason reason) 4129 Reason reason)
4100 : reason(reason), 4130 : reason(reason),
4101 extension(extension), 4131 extension(extension),
4102 permissions(permissions) {} 4132 permissions(permissions) {}
4103 4133
4104 } // namespace extensions 4134 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698