OLD | NEW |
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" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/search/hotword_service_factory.h" | 12 #include "chrome/browser/search/hotword_service_factory.h" |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
18 #include "extensions/common/extension_urls.h" | 18 #include "extensions/common/extension_urls.h" |
19 | 19 |
| 20 #if defined(OS_CHROMEOS) |
| 21 #include "chromeos/chromeos_switches.h" |
| 22 #endif |
| 23 |
20 namespace extensions { | 24 namespace extensions { |
21 | 25 |
22 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 26 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
23 : profile_(profile) { | 27 : profile_(profile) { |
24 } | 28 } |
25 | 29 |
26 ExternalComponentLoader::~ExternalComponentLoader() {} | 30 ExternalComponentLoader::~ExternalComponentLoader() {} |
27 | 31 |
28 // static | 32 // static |
29 bool ExternalComponentLoader::IsModifiable(const Extension* extension) { | 33 bool ExternalComponentLoader::IsModifiable(const Extension* extension) { |
30 if (extension->location() == Manifest::EXTERNAL_COMPONENT) { | 34 if (extension->location() == Manifest::EXTERNAL_COMPONENT) { |
31 static const char* enhanced_extension_hashes[] = { | 35 static const char* enhanced_extension_hashes[] = { |
32 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900 | 36 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900 |
33 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444 | 37 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444 |
34 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562 | 38 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562 |
35 }; | 39 }; |
36 std::string hash = base::SHA1HashString(extension->id()); | 40 std::string hash = base::SHA1HashString(extension->id()); |
37 hash = base::HexEncode(hash.c_str(), hash.length()); | 41 hash = base::HexEncode(hash.c_str(), hash.length()); |
38 for (size_t i = 0; i < arraysize(enhanced_extension_hashes); i++) | 42 for (size_t i = 0; i < arraysize(enhanced_extension_hashes); i++) |
39 if (hash == enhanced_extension_hashes[i]) | 43 if (hash == enhanced_extension_hashes[i]) |
40 return true; | 44 return true; |
41 } | 45 } |
42 return false; | 46 return false; |
43 } | 47 } |
44 | 48 |
45 void ExternalComponentLoader::StartLoading() { | 49 void ExternalComponentLoader::StartLoading() { |
| 50 CommandLine* const command_line = CommandLine::ForCurrentProcess(); |
| 51 |
46 prefs_.reset(new base::DictionaryValue()); | 52 prefs_.reset(new base::DictionaryValue()); |
47 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 53 std::string app_id = extension_misc::kInAppPaymentsSupportAppId; |
48 prefs_->SetString(appId + ".external_update_url", | 54 prefs_->SetString(app_id + ".external_update_url", |
49 extension_urls::GetWebstoreUpdateUrl().spec()); | 55 extension_urls::GetWebstoreUpdateUrl().spec()); |
50 | 56 |
51 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { | 57 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { |
52 std::string hotwordId = extension_misc::kHotwordExtensionId; | 58 std::string hotword_id = extension_misc::kHotwordExtensionId; |
53 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
54 if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { | 59 if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { |
55 hotwordId = extension_misc::kHotwordSharedModuleId; | 60 hotword_id = extension_misc::kHotwordSharedModuleId; |
56 } | 61 } |
57 prefs_->SetString(hotwordId + ".external_update_url", | 62 prefs_->SetString(hotword_id + ".external_update_url", |
58 extension_urls::GetWebstoreUpdateUrl().spec()); | 63 extension_urls::GetWebstoreUpdateUrl().spec()); |
59 } | 64 } |
60 | 65 |
61 InitBookmarksExperimentState(profile_); | 66 InitBookmarksExperimentState(profile_); |
62 | 67 |
63 std::string ext_id; | 68 { |
64 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && | 69 std::string extension_id; |
65 !ext_id.empty()) { | 70 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), |
66 prefs_->SetString(ext_id + ".external_update_url", | 71 &extension_id) && |
67 extension_urls::GetWebstoreUpdateUrl().spec()); | 72 !extension_id.empty()) { |
| 73 prefs_->SetString(extension_id + ".external_update_url", |
| 74 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 75 } |
68 } | 76 } |
69 | 77 |
| 78 #if defined(OS_CHROMEOS) |
| 79 { |
| 80 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) { |
| 81 const std::string extension_id = extension_misc::kZIPUnpackerExtensionId; |
| 82 prefs_->SetString(extension_id + ".external_update_url", |
| 83 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 84 } |
| 85 } |
| 86 #endif |
| 87 |
70 LoadFinished(); | 88 LoadFinished(); |
71 } | 89 } |
72 | 90 |
73 } // namespace extensions | 91 } // namespace extensions |
OLD | NEW |