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

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: rebase 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
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/sha1.h"
10 #include "base/strings/string_number_conversions.h"
9 #include "base/values.h" 11 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_sync_service.h" 13 #include "chrome/browser/extensions/extension_sync_service.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 15 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
14 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" 17 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
16 #include "chrome/common/extensions/sync_helper.h" 18 #include "chrome/common/extensions/sync_helper.h"
17 #include "content/public/browser/site_instance.h" 19 #include "content/public/browser/site_instance.h"
18 #include "extensions/browser/extension_prefs.h" 20 #include "extensions/browser/extension_prefs.h"
(...skipping 10 matching lines...) Expand all
29 namespace extensions { 31 namespace extensions {
30 namespace util { 32 namespace util {
31 33
32 namespace { 34 namespace {
33 // 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
34 // all urls without explicit permission. 36 // all urls without explicit permission.
35 const char kExtensionAllowedOnAllUrlsPrefName[] = 37 const char kExtensionAllowedOnAllUrlsPrefName[] =
36 "extension_can_script_all_urls"; 38 "extension_can_script_all_urls";
37 } 39 }
38 40
41 bool EnableIncognitoByDefault(const Extension* extension) {
42 // Internal component extensions are always enabled in IsIncognitoEnabled.
43 if (extension->location() != Manifest::EXTERNAL_COMPONENT)
44 return false;
45
46 // Enable external component extensions with hashes in this array in incognito
47 // mode.
48 static const char* kIncognitoEnabledExternalComponentExtensionHash[] = {
49 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
50 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
51 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
52 };
53
54 std::string hash = base::SHA1HashString(extension->id());
55 hash = base::HexEncode(hash.c_str(), hash.length());
56 for (size_t i = 0;
57 i < arraysize(kIncognitoEnabledExternalComponentExtensionHash); i++) {
58 if (hash == kIncognitoEnabledExternalComponentExtensionHash[i])
59 return true;
60 }
not at google - send to devlin 2014/06/18 23:49:20 see code here: https://code.google.com/p/chromium
Mike Wittman 2014/06/19 00:21:49 Done.
61
62 return false;
63 }
64
39 bool IsIncognitoEnabled(const std::string& extension_id, 65 bool IsIncognitoEnabled(const std::string& extension_id,
40 content::BrowserContext* context) { 66 content::BrowserContext* context) {
41 const Extension* extension = ExtensionRegistry::Get(context)-> 67 const Extension* extension = ExtensionRegistry::Get(context)->
42 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); 68 GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
43 if (extension) { 69 if (extension) {
44 if (!extension->can_be_incognito_enabled()) 70 if (!extension->can_be_incognito_enabled())
45 return false; 71 return false;
46 // If this is an existing component extension we always allow it to 72 // If this is an existing component extension we always allow it to
47 // work in incognito mode. 73 // work in incognito mode.
48 if (extension->location() == Manifest::COMPONENT) 74 if (extension->location() == Manifest::COMPONENT)
49 return true; 75 return true;
not at google - send to devlin 2014/06/18 23:49:20 like here: if (IsWhitelistedForIncognito(..)) r
Mike Wittman 2014/06/19 00:21:49 Either way works fine for my use case. I assumed t
50 } 76 }
51 77
52 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id); 78 return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id);
53 } 79 }
54 80
55 void SetIsIncognitoEnabled(const std::string& extension_id, 81 void SetIsIncognitoEnabled(const std::string& extension_id,
56 content::BrowserContext* context, 82 content::BrowserContext* context,
57 bool enabled) { 83 bool enabled) {
58 ExtensionService* service = 84 ExtensionService* service =
59 ExtensionSystem::Get(context)->extension_service(); 85 ExtensionSystem::Get(context)->extension_service();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 IDR_APP_DEFAULT_ICON); 305 IDR_APP_DEFAULT_ICON);
280 } 306 }
281 307
282 const gfx::ImageSkia& GetDefaultExtensionIcon() { 308 const gfx::ImageSkia& GetDefaultExtensionIcon() {
283 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 309 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
284 IDR_EXTENSION_DEFAULT_ICON); 310 IDR_EXTENSION_DEFAULT_ICON);
285 } 311 }
286 312
287 } // namespace util 313 } // namespace util
288 } // namespace extensions 314 } // namespace extensions
OLDNEW
« chrome/browser/extensions/extension_util.h ('K') | « chrome/browser/extensions/extension_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698