| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_protocols.h" | 5 #include "chrome/browser/extensions/extension_protocols.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 if (send_cors_header) { | 69 if (send_cors_header) { |
| 70 raw_headers.append(1, '\0'); | 70 raw_headers.append(1, '\0'); |
| 71 raw_headers.append("Access-Control-Allow-Origin: *"); | 71 raw_headers.append("Access-Control-Allow-Origin: *"); |
| 72 } | 72 } |
| 73 | 73 |
| 74 if (!last_modified_time.is_null()) { | 74 if (!last_modified_time.is_null()) { |
| 75 // Hash the time and make an etag to avoid exposing the exact | 75 // Hash the time and make an etag to avoid exposing the exact |
| 76 // user installation time of the extension. | 76 // user installation time of the extension. |
| 77 std::string hash = base::StringPrintf("%"PRId64"", | 77 std::string hash = base::StringPrintf("%" PRId64, |
| 78 last_modified_time.ToInternalValue()); | 78 last_modified_time.ToInternalValue()); |
| 79 hash = base::SHA1HashString(hash); | 79 hash = base::SHA1HashString(hash); |
| 80 std::string etag; | 80 std::string etag; |
| 81 if (base::Base64Encode(hash, &etag)) { | 81 if (base::Base64Encode(hash, &etag)) { |
| 82 raw_headers.append(1, '\0'); | 82 raw_headers.append(1, '\0'); |
| 83 raw_headers.append("ETag: \""); | 83 raw_headers.append("ETag: \""); |
| 84 raw_headers.append(etag); | 84 raw_headers.append(etag); |
| 85 raw_headers.append("\""); | 85 raw_headers.append("\""); |
| 86 // Also force revalidation. | 86 // Also force revalidation. |
| 87 raw_headers.append(1, '\0'); | 87 raw_headers.append(1, '\0'); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 send_cors_header); | 562 send_cors_header); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace | 565 } // namespace |
| 566 | 566 |
| 567 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 567 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 568 bool is_incognito, | 568 bool is_incognito, |
| 569 ExtensionInfoMap* extension_info_map) { | 569 ExtensionInfoMap* extension_info_map) { |
| 570 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 570 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 571 } | 571 } |
| OLD | NEW |