| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 17 #include "content/public/browser/resource_request_info.h" | 18 #include "content/public/browser/resource_request_info.h" |
| 18 #include "content/public/test/mock_resource_context.h" | 19 #include "content/public/test/mock_resource_context.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "extensions/browser/extension_protocols.h" | 21 #include "extensions/browser/extension_protocols.h" |
| 21 #include "extensions/browser/info_map.h" | 22 #include "extensions/browser/info_map.h" |
| 22 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 &resource_context_, | 140 &resource_context_, |
| 140 -1, // render_process_id | 141 -1, // render_process_id |
| 141 -1, // render_view_id | 142 -1, // render_view_id |
| 142 -1, // render_frame_id | 143 -1, // render_frame_id |
| 143 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, // is_main_frame | 144 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, // is_main_frame |
| 144 false, // parent_is_main_frame | 145 false, // parent_is_main_frame |
| 145 true, // allow_download | 146 true, // allow_download |
| 146 false, // is_async | 147 false, // is_async |
| 147 false); // is_using_lofi | 148 false); // is_using_lofi |
| 148 request->Start(); | 149 request->Start(); |
| 149 base::MessageLoop::current()->Run(); | 150 base::RunLoop().Run(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 // Helper method to create a URLRequest, call StartRequest on it, and return | 153 // Helper method to create a URLRequest, call StartRequest on it, and return |
| 153 // the result. If |extension| hasn't already been added to | 154 // the result. If |extension| hasn't already been added to |
| 154 // |extension_info_map_|, this will add it. | 155 // |extension_info_map_|, this will add it. |
| 155 net::URLRequestStatus::Status DoRequest(const Extension& extension, | 156 net::URLRequestStatus::Status DoRequest(const Extension& extension, |
| 156 const std::string& relative_path) { | 157 const std::string& relative_path) { |
| 157 if (!extension_info_map_->extensions().Contains(extension.id())) { | 158 if (!extension_info_map_->extensions().Contains(extension.id())) { |
| 158 extension_info_map_->AddExtension(&extension, | 159 extension_info_map_->AddExtension(&extension, |
| 159 base::Time::Now(), | 160 base::Time::Now(), |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 DoRequest(*extension, relative_path.AsUTF8Unsafe())); | 400 DoRequest(*extension, relative_path.AsUTF8Unsafe())); |
| 400 | 401 |
| 401 // Loading "/_metadata/a.txt" should also fail. | 402 // Loading "/_metadata/a.txt" should also fail. |
| 402 relative_path = base::FilePath(kMetadataFolder).AppendASCII("a.txt"); | 403 relative_path = base::FilePath(kMetadataFolder).AppendASCII("a.txt"); |
| 403 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); | 404 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); |
| 404 EXPECT_EQ(net::URLRequestStatus::FAILED, | 405 EXPECT_EQ(net::URLRequestStatus::FAILED, |
| 405 DoRequest(*extension, relative_path.AsUTF8Unsafe())); | 406 DoRequest(*extension, relative_path.AsUTF8Unsafe())); |
| 406 } | 407 } |
| 407 | 408 |
| 408 } // namespace extensions | 409 } // namespace extensions |
| OLD | NEW |