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

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

Issue 445233002: Allow enhanced bookmarks external component extensions to be disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: rebase 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/external_component_loader.h" 5 #include "chrome/browser/extensions/external_component_loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/sha1.h"
9 #include "base/strings/string_number_conversions.h"
8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" 10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
9 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 12 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/extensions/extension_constants.h" 14 #include "chrome/common/extensions/extension_constants.h"
13 #include "components/signin/core/browser/signin_manager.h" 15 #include "components/signin/core/browser/signin_manager.h"
14 16
15 // TODO(thestig): Remove after extensions are disabled on mobile. 17 // TODO(thestig): Remove after extensions are disabled on mobile.
16 #if defined(ENABLE_EXTENSIONS) 18 #if defined(ENABLE_EXTENSIONS)
17 #include "chrome/browser/search/hotword_service_factory.h" 19 #include "chrome/browser/search/hotword_service_factory.h"
18 #endif 20 #endif
19 21
20 namespace { 22 namespace {
21 23
22 bool IsUserSignedin(Profile* profile) { 24 bool IsUserSignedin(Profile* profile) {
23 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); 25 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
24 return signin && !signin->GetAuthenticatedUsername().empty(); 26 return signin && !signin->GetAuthenticatedUsername().empty();
25 } 27 }
26 28
27 } // namespace 29 } // namespace
28 30
29 namespace extensions { 31 namespace extensions {
30 32
31 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) 33 ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
32 : profile_(profile) { 34 : profile_(profile) {
33 } 35 }
34 36
35 ExternalComponentLoader::~ExternalComponentLoader() {} 37 ExternalComponentLoader::~ExternalComponentLoader() {}
36 38
39 // static
40 bool ExternalComponentLoader::IsModifiable(
41 const extensions::Extension* extension) {
42 if (extension->location() == extensions::Manifest::EXTERNAL_COMPONENT) {
43 static const char* enhanced_extension_hashes[] = {
44 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
45 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
46 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
47 };
48 std::string hash = base::SHA1HashString(extension->id());
49 hash = base::HexEncode(hash.c_str(), hash.length());
50 for (size_t i = 0; i < arraysize(enhanced_extension_hashes); i++)
51 if (hash == enhanced_extension_hashes[i])
52 return true;
53 }
54 return false;
55 }
56
37 void ExternalComponentLoader::StartLoading() { 57 void ExternalComponentLoader::StartLoading() {
38 prefs_.reset(new base::DictionaryValue()); 58 prefs_.reset(new base::DictionaryValue());
39 std::string appId = extension_misc::kInAppPaymentsSupportAppId; 59 std::string appId = extension_misc::kInAppPaymentsSupportAppId;
40 prefs_->SetString(appId + ".external_update_url", 60 prefs_->SetString(appId + ".external_update_url",
41 extension_urls::GetWebstoreUpdateUrl().spec()); 61 extension_urls::GetWebstoreUpdateUrl().spec());
42 62
43 #if defined(ENABLE_EXTENSIONS) 63 #if defined(ENABLE_EXTENSIONS)
44 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { 64 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) {
45 std::string hotwordId = extension_misc::kHotwordExtensionId; 65 std::string hotwordId = extension_misc::kHotwordExtensionId;
46 CommandLine* command_line = CommandLine::ForCurrentProcess(); 66 CommandLine* command_line = CommandLine::ForCurrentProcess();
(...skipping 15 matching lines...) Expand all
62 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && 82 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) &&
63 !ext_id.empty()) { 83 !ext_id.empty()) {
64 prefs_->SetString(ext_id + ".external_update_url", 84 prefs_->SetString(ext_id + ".external_update_url",
65 extension_urls::GetWebstoreUpdateUrl().spec()); 85 extension_urls::GetWebstoreUpdateUrl().spec());
66 } 86 }
67 87
68 LoadFinished(); 88 LoadFinished();
69 } 89 }
70 90
71 } // namespace extensions 91 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698