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

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

Issue 331743004: Always enable enhanced bookmarks external component extensions for incognito mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: address comments Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/manifest.h" 25 #include "extensions/common/manifest.h"
25 #include "extensions/common/manifest_handlers/incognito_info.h" 26 #include "extensions/common/manifest_handlers/incognito_info.h"
26 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
27 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
28 29
29 namespace extensions { 30 namespace extensions {
30 namespace util { 31 namespace util {
31 32
32 namespace { 33 namespace {
33 // The entry into the ExtensionPrefs for allowing an extension to script on 34 // The entry into the ExtensionPrefs for allowing an extension to script on
34 // all urls without explicit permission. 35 // all urls without explicit permission.
35 const char kExtensionAllowedOnAllUrlsPrefName[] = 36 const char kExtensionAllowedOnAllUrlsPrefName[] =
36 "extension_can_script_all_urls"; 37 "extension_can_script_all_urls";
38
39 // Returns true if |extension_id| for an external component extension should
40 // always be enabled in incognito windows.
41 bool IsWhitelistedForIncognito(const std::string& extension_id) {
42 static const char* kExtensionWhitelist[] = {
43 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
44 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
not at google - send to devlin 2014/06/19 01:27:34 nit: 2 spaces before comment
Mike Wittman 2014/06/19 16:42:02 Done.
45 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
46 };
47
48 return extensions::SimpleFeature::IsIdInList(
49 extension_id,
50 std::set<std::string>(
51 kExtensionWhitelist,
52 kExtensionWhitelist + arraysize(kExtensionWhitelist)));
37 } 53 }
54 } // namespace
38 55
39 bool IsIncognitoEnabled(const std::string& extension_id, 56 bool IsIncognitoEnabled(const std::string& extension_id,
40 content::BrowserContext* context) { 57 content::BrowserContext* context) {
41 const Extension* extension = ExtensionRegistry::Get(context)-> 58 const Extension* extension = ExtensionRegistry::Get(context)->
42 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); 59 GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
43 if (extension) { 60 if (extension) {
44 if (!extension->can_be_incognito_enabled()) 61 if (!extension->can_be_incognito_enabled())
45 return false; 62 return false;
46 // If this is an existing component extension we always allow it to 63 // If this is an existing component extension we always allow it to
47 // work in incognito mode. 64 // work in incognito mode.
48 if (extension->location() == Manifest::COMPONENT) 65 if (extension->location() == Manifest::COMPONENT)
49 return true; 66 return true;
67 if (extension->location() == Manifest::EXTERNAL_COMPONENT &&
68 IsWhitelistedForIncognito(extension_id))
69 return true;
not at google - send to devlin 2014/06/19 01:27:34 nit: curlies on body with multi-line condition.
Mike Wittman 2014/06/19 16:42:02 Done.
50 } 70 }
51 71
52 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id); 72 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id);
53 } 73 }
54 74
55 void SetIsIncognitoEnabled(const std::string& extension_id, 75 void SetIsIncognitoEnabled(const std::string& extension_id,
56 content::BrowserContext* context, 76 content::BrowserContext* context,
57 bool enabled) { 77 bool enabled) {
58 ExtensionService* service = 78 ExtensionService* service =
59 ExtensionSystem::Get(context)->extension_service(); 79 ExtensionSystem::Get(context)->extension_service();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 IDR_APP_DEFAULT_ICON); 287 IDR_APP_DEFAULT_ICON);
268 } 288 }
269 289
270 const gfx::ImageSkia& GetDefaultExtensionIcon() { 290 const gfx::ImageSkia& GetDefaultExtensionIcon() {
271 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 291 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
272 IDR_EXTENSION_DEFAULT_ICON); 292 IDR_EXTENSION_DEFAULT_ICON);
273 } 293 }
274 294
275 } // namespace util 295 } // namespace util
276 } // namespace extensions 296 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698