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

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: Final style fixes 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 // TODO(dewittj) Add this for all extension action APIs.
2472 api_permissions->insert(APIPermission::kSystemIndicator);
2473
2474 return true;
2475 }
2476
2446 bool Extension::LoadScriptBadge(string16* error) { 2477 bool Extension::LoadScriptBadge(string16* error) {
2447 if (manifest_->HasKey(keys::kScriptBadge)) { 2478 if (manifest_->HasKey(keys::kScriptBadge)) {
2448 if (!FeatureSwitch::script_badges()->IsEnabled()) { 2479 if (!FeatureSwitch::script_badges()->IsEnabled()) {
2449 // So as to not confuse developers if they specify a script badge section 2480 // 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 2481 // in the manifest, show a warning if the script badge declaration isn't
2451 // going to have any effect. 2482 // going to have any effect.
2452 install_warnings_.push_back( 2483 install_warnings_.push_back(
2453 InstallWarning(InstallWarning::FORMAT_TEXT, 2484 InstallWarning(InstallWarning::FORMAT_TEXT,
2454 errors::kScriptBadgeRequiresFlag)); 2485 errors::kScriptBadgeRequiresFlag));
2455 } 2486 }
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 &optional_host_permissions)) { 3288 &optional_host_permissions)) {
3258 return false; 3289 return false;
3259 } 3290 }
3260 3291
3261 if (!LoadAppIsolation(api_permissions, error)) 3292 if (!LoadAppIsolation(api_permissions, error))
3262 return false; 3293 return false;
3263 3294
3264 if (!LoadSharedFeatures(api_permissions, error)) 3295 if (!LoadSharedFeatures(api_permissions, error))
3265 return false; 3296 return false;
3266 3297
3267 if (!LoadExtensionFeatures(api_permissions, error)) 3298 if (!LoadExtensionFeatures(&api_permissions, error))
3268 return false; 3299 return false;
3269 3300
3270 if (!LoadThemeFeatures(error)) 3301 if (!LoadThemeFeatures(error))
3271 return false; 3302 return false;
3272 3303
3273 if (HasMultipleUISurfaces()) { 3304 if (HasMultipleUISurfaces()) {
3274 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 3305 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
3275 return false; 3306 return false;
3276 } 3307 }
3277 3308
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 4126
4096 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4127 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4097 const Extension* extension, 4128 const Extension* extension,
4098 const PermissionSet* permissions, 4129 const PermissionSet* permissions,
4099 Reason reason) 4130 Reason reason)
4100 : reason(reason), 4131 : reason(reason),
4101 extension(extension), 4132 extension(extension),
4102 permissions(permissions) {} 4133 permissions(permissions) {}
4103 4134
4104 } // namespace extensions 4135 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698