| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/browser/updater/update_data_provider.h" | 5 #include "extensions/browser/updater/update_data_provider.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/stl_util.h" | |
| 12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 13 #include "components/update_client/update_client.h" | 12 #include "components/update_client/update_client.h" |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 15 #include "crypto/sha2.h" | 14 #include "crypto/sha2.h" |
| 16 #include "extensions/browser/content_verifier.h" | 15 #include "extensions/browser/content_verifier.h" |
| 17 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| 18 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
| 19 #include "extensions/browser/updater/update_install_shim.h" | 18 #include "extensions/browser/updater/update_install_shim.h" |
| 20 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 21 | 20 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 const ExtensionRegistry* registry = ExtensionRegistry::Get(context_); | 38 const ExtensionRegistry* registry = ExtensionRegistry::Get(context_); |
| 40 for (const auto& id : ids) { | 39 for (const auto& id : ids) { |
| 41 const Extension* extension = registry->GetInstalledExtension(id); | 40 const Extension* extension = registry->GetInstalledExtension(id); |
| 42 if (!extension) | 41 if (!extension) |
| 43 continue; | 42 continue; |
| 44 data->push_back(update_client::CrxComponent()); | 43 data->push_back(update_client::CrxComponent()); |
| 45 update_client::CrxComponent* info = &data->back(); | 44 update_client::CrxComponent* info = &data->back(); |
| 46 std::string pubkey_bytes; | 45 std::string pubkey_bytes; |
| 47 base::Base64Decode(extension->public_key(), &pubkey_bytes); | 46 base::Base64Decode(extension->public_key(), &pubkey_bytes); |
| 48 info->pk_hash.resize(crypto::kSHA256Length, 0); | 47 info->pk_hash.resize(crypto::kSHA256Length, 0); |
| 49 crypto::SHA256HashString(pubkey_bytes, vector_as_array(&info->pk_hash), | 48 crypto::SHA256HashString(pubkey_bytes, info->pk_hash.data(), |
| 50 info->pk_hash.size()); | 49 info->pk_hash.size()); |
| 51 info->version = *extension->version(); | 50 info->version = *extension->version(); |
| 52 info->allow_background_download = false; | 51 info->allow_background_download = false; |
| 53 | 52 |
| 54 info->installer = new UpdateInstallShim( | 53 info->installer = new UpdateInstallShim( |
| 55 id, extension->path(), | 54 id, extension->path(), |
| 56 base::Bind(&UpdateDataProvider::RunInstallCallback, this)); | 55 base::Bind(&UpdateDataProvider::RunInstallCallback, this)); |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 | 58 |
| 60 void UpdateDataProvider::RunInstallCallback(const std::string& extension_id, | 59 void UpdateDataProvider::RunInstallCallback(const std::string& extension_id, |
| 61 const base::FilePath& temp_dir) { | 60 const base::FilePath& temp_dir) { |
| 62 if (!context_) { | 61 if (!context_) { |
| 63 content::BrowserThread::PostBlockingPoolTask( | 62 content::BrowserThread::PostBlockingPoolTask( |
| 64 FROM_HERE, | 63 FROM_HERE, |
| 65 base::Bind(base::IgnoreResult(&base::DeleteFile), temp_dir, false)); | 64 base::Bind(base::IgnoreResult(&base::DeleteFile), temp_dir, false)); |
| 66 return; | 65 return; |
| 67 } else { | 66 } else { |
| 68 callback_.Run(context_, extension_id, temp_dir); | 67 callback_.Run(context_, extension_id, temp_dir); |
| 69 } | 68 } |
| 70 } | 69 } |
| 71 | 70 |
| 72 } // namespace extensions | 71 } // namespace extensions |
| OLD | NEW |