OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/convert_web_app.h" | 5 #include "chrome/browser/extensions/convert_web_app.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 // Create the public key for the converted web app. | 40 // Create the public key for the converted web app. |
41 // | 41 // |
42 // Web apps are not signed, but the public key for an extension doubles as | 42 // Web apps are not signed, but the public key for an extension doubles as |
43 // its unique identity, and we need one of those. A web app's unique identity | 43 // its unique identity, and we need one of those. A web app's unique identity |
44 // is its manifest URL, so we hash that to create a public key. There will be | 44 // is its manifest URL, so we hash that to create a public key. There will be |
45 // no corresponding private key, which means that these extensions cannot be | 45 // no corresponding private key, which means that these extensions cannot be |
46 // auto-updated using ExtensionUpdater. But Chrome does notice updates to the | 46 // auto-updated using ExtensionUpdater. But Chrome does notice updates to the |
47 // manifest and regenerates these extensions. | 47 // manifest and regenerates these extensions. |
48 std::string GenerateKey(const GURL& manifest_url) { | 48 std::string GenerateKey(const GURL& manifest_url) { |
49 char raw[crypto::SHA256_LENGTH] = {0}; | 49 char raw[crypto::kSHA256Length] = {0}; |
50 std::string key; | 50 std::string key; |
51 crypto::SHA256HashString(manifest_url.spec().c_str(), | 51 crypto::SHA256HashString(manifest_url.spec().c_str(), raw, |
52 raw, | 52 crypto::kSHA256Length); |
wtc
2011/09/02 17:08:42
Nit: since 'raw' and crypto::kSHA256Length are rel
| |
53 crypto::SHA256_LENGTH); | 53 base::Base64Encode(std::string(raw, crypto::kSHA256Length), &key); |
54 base::Base64Encode(std::string(raw, crypto::SHA256_LENGTH), &key); | |
55 return key; | 54 return key; |
56 } | 55 } |
57 | 56 |
58 } | 57 } |
59 | 58 |
60 | 59 |
61 // Generates a version for the converted app using the current date. This isn't | 60 // Generates a version for the converted app using the current date. This isn't |
62 // really needed, but it seems like useful information. | 61 // really needed, but it seems like useful information. |
63 std::string ConvertTimeToExtensionVersion(const Time& create_time) { | 62 std::string ConvertTimeToExtensionVersion(const Time& create_time) { |
64 Time::Exploded create_time_exploded; | 63 Time::Exploded create_time_exploded; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 extension_flags, | 183 extension_flags, |
185 &error); | 184 &error); |
186 if (!extension) { | 185 if (!extension) { |
187 LOG(ERROR) << error; | 186 LOG(ERROR) << error; |
188 return NULL; | 187 return NULL; |
189 } | 188 } |
190 | 189 |
191 temp_dir.Take(); // The caller takes ownership of the directory. | 190 temp_dir.Take(); // The caller takes ownership of the directory. |
192 return extension; | 191 return extension; |
193 } | 192 } |
OLD | NEW |