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

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

Issue 348313003: Create withheld permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test fix Created 6 years, 5 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/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 13 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" 15 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
16 #include "chrome/common/extensions/sync_helper.h" 16 #include "chrome/common/extensions/sync_helper.h"
17 #include "content/public/browser/site_instance.h" 17 #include "content/public/browser/site_instance.h"
18 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
19 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
20 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
21 #include "extensions/browser/extension_util.h" 21 #include "extensions/browser/extension_util.h"
22 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
23 #include "extensions/common/extension_icon_set.h" 23 #include "extensions/common/extension_icon_set.h"
24 #include "extensions/common/features/simple_feature.h" 24 #include "extensions/common/features/simple_feature.h"
25 #include "extensions/common/manifest.h" 25 #include "extensions/common/manifest.h"
26 #include "extensions/common/manifest_handlers/incognito_info.h" 26 #include "extensions/common/manifest_handlers/incognito_info.h"
27 #include "extensions/common/permissions/permissions_data.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
29 30
30 namespace extensions { 31 namespace extensions {
31 namespace util { 32 namespace util {
32 33
33 namespace { 34 namespace {
34 // The entry into the ExtensionPrefs for allowing an extension to script on 35 // The entry into the ExtensionPrefs for allowing an extension to script on
35 // all urls without explicit permission. 36 // all urls without explicit permission.
36 const char kExtensionAllowedOnAllUrlsPrefName[] = 37 const char kExtensionAllowedOnAllUrlsPrefName[] =
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return ExtensionPrefs::Get(context)->ReadPrefAsBoolean( 177 return ExtensionPrefs::Get(context)->ReadPrefAsBoolean(
177 extension_id, 178 extension_id,
178 kExtensionAllowedOnAllUrlsPrefName, 179 kExtensionAllowedOnAllUrlsPrefName,
179 &allowed) && 180 &allowed) &&
180 allowed; 181 allowed;
181 } 182 }
182 183
183 void SetAllowedScriptingOnAllUrls(const std::string& extension_id, 184 void SetAllowedScriptingOnAllUrls(const std::string& extension_id,
184 content::BrowserContext* context, 185 content::BrowserContext* context,
185 bool allowed) { 186 bool allowed) {
187 if (allowed == AllowedScriptingOnAllUrls(extension_id, context))
188 return; // Nothing to do here.
189
186 ExtensionPrefs::Get(context)->UpdateExtensionPref( 190 ExtensionPrefs::Get(context)->UpdateExtensionPref(
187 extension_id, 191 extension_id,
188 kExtensionAllowedOnAllUrlsPrefName, 192 kExtensionAllowedOnAllUrlsPrefName,
189 allowed ? new base::FundamentalValue(true) : NULL); 193 allowed ? new base::FundamentalValue(true) : NULL);
194
195 const Extension* extension =
196 ExtensionRegistry::Get(context)->enabled_extensions().GetByID(
197 extension_id);
198 if (extension) {
199 if (allowed)
200 extension->permissions_data()->GrantWithheldAllHosts();
not at google - send to devlin 2014/06/30 14:37:03 - what about on browser startup (I can't see an ob
Devlin 2014/06/30 17:06:10 Whoops. Had that in there at some point, but it m
201 else
202 extension->permissions_data()->WithholdAllHosts();
203 }
190 } 204 }
191 205
192 bool IsAppLaunchable(const std::string& extension_id, 206 bool IsAppLaunchable(const std::string& extension_id,
193 content::BrowserContext* context) { 207 content::BrowserContext* context) {
194 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id); 208 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id);
195 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) || 209 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) ||
196 (reason & Extension::DISABLE_CORRUPTED)); 210 (reason & Extension::DISABLE_CORRUPTED));
197 } 211 }
198 212
199 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id, 213 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 IDR_APP_DEFAULT_ICON); 303 IDR_APP_DEFAULT_ICON);
290 } 304 }
291 305
292 const gfx::ImageSkia& GetDefaultExtensionIcon() { 306 const gfx::ImageSkia& GetDefaultExtensionIcon() {
293 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 307 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
294 IDR_EXTENSION_DEFAULT_ICON); 308 IDR_EXTENSION_DEFAULT_ICON);
295 } 309 }
296 310
297 } // namespace util 311 } // namespace util
298 } // namespace extensions 312 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698