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

Side by Side Diff: chrome/browser/extensions/extension_util.cc

Issue 480133002: Only show the checkbox for all urls when the switch is on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/extensions/extension_util.h" 5 #include "chrome/browser/extensions/extension_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_sync_service.h" 11 #include "chrome/browser/extensions/extension_sync_service.h"
12 #include "chrome/browser/extensions/permissions_updater.h" 12 #include "chrome/browser/extensions/permissions_updater.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 14 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" 16 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
17 #include "chrome/common/extensions/sync_helper.h" 17 #include "chrome/common/extensions/sync_helper.h"
18 #include "content/public/browser/site_instance.h" 18 #include "content/public/browser/site_instance.h"
19 #include "extensions/browser/extension_prefs.h" 19 #include "extensions/browser/extension_prefs.h"
20 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
21 #include "extensions/browser/extension_system.h" 21 #include "extensions/browser/extension_system.h"
22 #include "extensions/browser/extension_util.h" 22 #include "extensions/browser/extension_util.h"
23 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_icon_set.h" 24 #include "extensions/common/extension_icon_set.h"
25 #include "extensions/common/feature_switch.h"
25 #include "extensions/common/features/simple_feature.h" 26 #include "extensions/common/features/simple_feature.h"
26 #include "extensions/common/manifest.h" 27 #include "extensions/common/manifest.h"
27 #include "extensions/common/manifest_handlers/incognito_info.h" 28 #include "extensions/common/manifest_handlers/incognito_info.h"
29 #include "extensions/common/permissions/permissions_data.h"
28 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
29 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
30 32
31 namespace extensions { 33 namespace extensions {
32 namespace util { 34 namespace util {
33 35
34 namespace { 36 namespace {
35 // The entry into the ExtensionPrefs for allowing an extension to script on 37 // The entry into the ExtensionPrefs for allowing an extension to script on
36 // all urls without explicit permission. 38 // all urls without explicit permission.
37 const char kExtensionAllowedOnAllUrlsPrefName[] = 39 const char kExtensionAllowedOnAllUrlsPrefName[] =
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 extension_id); 199 extension_id);
198 if (extension) { 200 if (extension) {
199 PermissionsUpdater updater(context); 201 PermissionsUpdater updater(context);
200 if (allowed) 202 if (allowed)
201 updater.GrantWithheldImpliedAllHosts(extension); 203 updater.GrantWithheldImpliedAllHosts(extension);
202 else 204 else
203 updater.WithholdImpliedAllHosts(extension); 205 updater.WithholdImpliedAllHosts(extension);
204 } 206 }
205 } 207 }
206 208
209 bool ScriptsMayRequireActionForExtension(const Extension* extension) {
210 // An extension requires user action to execute scripts iff the switch to do
211 // so is enabled, the extension shows up in chrome:extensions (so the user can
212 // grant withheld permissions), the extension is not part of chrome or
213 // corporate policy, and also not on the scripting whitelist.
214 return FeatureSwitch::scripts_require_action()->IsEnabled() &&
215 extension->ShouldDisplayInExtensionSettings() &&
216 !Manifest::IsPolicyLocation(extension->location()) &&
217 !Manifest::IsComponentLocation(extension->location()) &&
218 !PermissionsData::CanExecuteScriptEverywhere(extension);
219 }
220
207 bool IsAppLaunchable(const std::string& extension_id, 221 bool IsAppLaunchable(const std::string& extension_id,
208 content::BrowserContext* context) { 222 content::BrowserContext* context) {
209 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id); 223 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id);
210 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) || 224 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) ||
211 (reason & Extension::DISABLE_CORRUPTED)); 225 (reason & Extension::DISABLE_CORRUPTED));
212 } 226 }
213 227
214 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id, 228 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
215 content::BrowserContext* context) { 229 content::BrowserContext* context) {
216 return ExtensionRegistry::Get(context)->GetExtensionById( 230 return ExtensionRegistry::Get(context)->GetExtensionById(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 IDR_APP_DEFAULT_ICON); 318 IDR_APP_DEFAULT_ICON);
305 } 319 }
306 320
307 const gfx::ImageSkia& GetDefaultExtensionIcon() { 321 const gfx::ImageSkia& GetDefaultExtensionIcon() {
308 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 322 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
309 IDR_EXTENSION_DEFAULT_ICON); 323 IDR_EXTENSION_DEFAULT_ICON);
310 } 324 }
311 325
312 } // namespace util 326 } // namespace util
313 } // namespace extensions 327 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_util.h ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698