OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/component_updater/cld_component_installer.h" | 5 #include "chrome/browser/component_updater/cld_component_installer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
17 #include "chrome/browser/component_updater/default_component_installer.h" | |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
22 #include "net/ssl/ssl_config_service.h" | 21 #include "net/ssl/ssl_config_service.h" |
23 | 22 |
24 using component_updater::ComponentUpdateService; | 23 using component_updater::ComponentUpdateService; |
25 using content::BrowserThread; | 24 using content::BrowserThread; |
26 | 25 |
27 namespace { | 26 namespace { |
(...skipping 13 matching lines...) Expand all Loading... |
41 // The extension id is: dpedmmgabcgnikllifiidmijgoiihfgf | 40 // The extension id is: dpedmmgabcgnikllifiidmijgoiihfgf |
42 const uint8 kPublicKeySHA256[32] = { | 41 const uint8 kPublicKeySHA256[32] = { |
43 0x3f, 0x43, 0xcc, 0x60, 0x12, 0x6d, 0x8a, 0xbb, | 42 0x3f, 0x43, 0xcc, 0x60, 0x12, 0x6d, 0x8a, 0xbb, |
44 0x85, 0x88, 0x3c, 0x89, 0x6e, 0x88, 0x75, 0x65, | 43 0x85, 0x88, 0x3c, 0x89, 0x6e, 0x88, 0x75, 0x65, |
45 0xb9, 0x46, 0x09, 0xe8, 0xca, 0x92, 0xdd, 0x82, | 44 0xb9, 0x46, 0x09, 0xe8, 0xca, 0x92, 0xdd, 0x82, |
46 0x4e, 0x6d, 0x0e, 0xe6, 0x79, 0x8a, 0x87, 0xf5 | 45 0x4e, 0x6d, 0x0e, 0xe6, 0x79, 0x8a, 0x87, 0xf5 |
47 }; | 46 }; |
48 | 47 |
49 const char kCldManifestName[] = "CLD2 Data"; | 48 const char kCldManifestName[] = "CLD2 Data"; |
50 | 49 |
51 class CldComponentInstallerTraits : public ComponentInstallerTraits { | |
52 public: | |
53 CldComponentInstallerTraits(); | |
54 virtual ~CldComponentInstallerTraits() {} | |
55 | |
56 private: | |
57 // The following methods override ComponentInstallerTraits. | |
58 virtual bool CanAutoUpdate() const OVERRIDE; | |
59 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, | |
60 const base::FilePath& install_dir) OVERRIDE; | |
61 virtual bool VerifyInstallation( | |
62 const base::FilePath& install_dir) const OVERRIDE; | |
63 virtual void ComponentReady( | |
64 const base::Version& version, | |
65 const base::FilePath& path, | |
66 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; | |
67 virtual base::FilePath GetBaseDirectory() const OVERRIDE; | |
68 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; | |
69 virtual std::string GetName() const OVERRIDE; | |
70 | |
71 base::FilePath GetInstalledPath(const base::FilePath& base) const; | |
72 void SetLatestCldDataFile(const base::FilePath& path); | |
73 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits); | |
74 }; | |
75 | |
76 CldComponentInstallerTraits::CldComponentInstallerTraits() { | 50 CldComponentInstallerTraits::CldComponentInstallerTraits() { |
77 } | 51 } |
78 | 52 |
79 bool CldComponentInstallerTraits::CanAutoUpdate() const { | 53 bool CldComponentInstallerTraits::CanAutoUpdate() const { |
80 return true; | 54 return true; |
81 } | 55 } |
82 | 56 |
83 bool CldComponentInstallerTraits::OnCustomInstall( | 57 bool CldComponentInstallerTraits::OnCustomInstall( |
84 const base::DictionaryValue& manifest, | 58 const base::DictionaryValue& manifest, |
85 const base::FilePath& install_dir) { | 59 const base::FilePath& install_dir) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 108 |
135 void RegisterCldComponent(ComponentUpdateService* cus) { | 109 void RegisterCldComponent(ComponentUpdateService* cus) { |
136 scoped_ptr<ComponentInstallerTraits> traits( | 110 scoped_ptr<ComponentInstallerTraits> traits( |
137 new CldComponentInstallerTraits()); | 111 new CldComponentInstallerTraits()); |
138 // |cus| will take ownership of |installer| during installer->Register(cus). | 112 // |cus| will take ownership of |installer| during installer->Register(cus). |
139 DefaultComponentInstaller* installer = | 113 DefaultComponentInstaller* installer = |
140 new DefaultComponentInstaller(traits.Pass()); | 114 new DefaultComponentInstaller(traits.Pass()); |
141 installer->Register(cus); | 115 installer->Register(cus); |
142 } | 116 } |
143 | 117 |
144 // This method is completely threadsafe. | |
145 void CldComponentInstallerTraits::SetLatestCldDataFile( | 118 void CldComponentInstallerTraits::SetLatestCldDataFile( |
146 const base::FilePath& path) { | 119 const base::FilePath& path) { |
147 VLOG(1) << "Setting CLD data file location: " << path.value(); | 120 VLOG(1) << "Setting CLD data file location: " << path.value(); |
148 base::AutoLock lock(cld_file_lock.Get()); | 121 base::AutoLock lock(cld_file_lock.Get()); |
149 cld_file.Get() = path; | 122 cld_file.Get() = path; |
150 } | 123 } |
151 | 124 |
152 bool GetLatestCldDataFile(base::FilePath* path) { | 125 bool GetLatestCldDataFile(base::FilePath* path) { |
153 base::AutoLock lock(cld_file_lock.Get()); | 126 base::AutoLock lock(cld_file_lock.Get()); |
154 const base::FilePath cached = cld_file.Get(); | 127 const base::FilePath cached = cld_file.Get(); |
155 if (cached.empty()) | 128 if (cached.empty()) |
156 return false; | 129 return false; |
157 *path = cached; | 130 *path = cached; |
158 return true; | 131 return true; |
159 } | 132 } |
160 | 133 |
161 } // namespace component_updater | 134 } // namespace component_updater |
OLD | NEW |