| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 raw_headers.append("Access-Control-Allow-Origin: *"); | 79 raw_headers.append("Access-Control-Allow-Origin: *"); |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (!last_modified_time.is_null()) { | 82 if (!last_modified_time.is_null()) { |
| 83 // Hash the time and make an etag to avoid exposing the exact | 83 // Hash the time and make an etag to avoid exposing the exact |
| 84 // user installation time of the extension. | 84 // user installation time of the extension. |
| 85 std::string hash = base::StringPrintf("%" PRId64, | 85 std::string hash = base::StringPrintf("%" PRId64, |
| 86 last_modified_time.ToInternalValue()); | 86 last_modified_time.ToInternalValue()); |
| 87 hash = base::SHA1HashString(hash); | 87 hash = base::SHA1HashString(hash); |
| 88 std::string etag; | 88 std::string etag; |
| 89 base::Base64Encode(hash, &etag); | 89 if (base::Base64Encode(hash, &etag)) { |
| 90 raw_headers.append(1, '\0'); | 90 raw_headers.append(1, '\0'); |
| 91 raw_headers.append("ETag: \""); | 91 raw_headers.append("ETag: \""); |
| 92 raw_headers.append(etag); | 92 raw_headers.append(etag); |
| 93 raw_headers.append("\""); | 93 raw_headers.append("\""); |
| 94 // Also force revalidation. | 94 // Also force revalidation. |
| 95 raw_headers.append(1, '\0'); | 95 raw_headers.append(1, '\0'); |
| 96 raw_headers.append("cache-control: no-cache"); | 96 raw_headers.append("cache-control: no-cache"); |
| 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 raw_headers.append(2, '\0'); | 100 raw_headers.append(2, '\0'); |
| 100 return new net::HttpResponseHeaders(raw_headers); | 101 return new net::HttpResponseHeaders(raw_headers); |
| 101 } | 102 } |
| 102 | 103 |
| 103 class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { | 104 class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { |
| 104 public: | 105 public: |
| 105 URLRequestResourceBundleJob(net::URLRequest* request, | 106 URLRequestResourceBundleJob(net::URLRequest* request, |
| 106 net::NetworkDelegate* network_delegate, | 107 net::NetworkDelegate* network_delegate, |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 send_cors_header); | 621 send_cors_header); |
| 621 } | 622 } |
| 622 | 623 |
| 623 } // namespace | 624 } // namespace |
| 624 | 625 |
| 625 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 626 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 626 bool is_incognito, | 627 bool is_incognito, |
| 627 extensions::InfoMap* extension_info_map) { | 628 extensions::InfoMap* extension_info_map) { |
| 628 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 629 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 629 } | 630 } |
| OLD | NEW |