| 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 <limits> | 5 #include <limits> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 // The bindings for the page are generated from a .mojom file. This code looks | 54 // The bindings for the page are generated from a .mojom file. This code looks |
| 55 // up the generated file from disk and returns it. | 55 // up the generated file from disk and returns it. |
| 56 bool GetResource(const std::string& id, | 56 bool GetResource(const std::string& id, |
| 57 const WebUIDataSource::GotDataCallback& callback) { | 57 const WebUIDataSource::GotDataCallback& callback) { |
| 58 base::ThreadRestrictions::ScopedAllowIO allow_io_from_test_callbacks; | 58 base::ThreadRestrictions::ScopedAllowIO allow_io_from_test_callbacks; |
| 59 | 59 |
| 60 std::string contents; | 60 std::string contents; |
| 61 if (base::EndsWith(id, ".mojom", base::CompareCase::SENSITIVE)) { | 61 if (base::EndsWith(id, ".mojom", base::CompareCase::SENSITIVE)) { |
| 62 CHECK(base::ReadFileToString(GetFilePathForJSResource(id), &contents)) | 62 CHECK(base::ReadFileToString(GetFilePathForJSResource(id), &contents)); |
| 63 << id; | |
| 64 } else { | 63 } else { |
| 65 base::FilePath path; | 64 base::FilePath path; |
| 66 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); | 65 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); |
| 67 path = path.AppendASCII(id.substr(0, id.find("?"))); | 66 path = path.AppendASCII(id.substr(0, id.find("?"))); |
| 68 CHECK(base::ReadFileToString(path, &contents)) << path.value(); | 67 CHECK(base::ReadFileToString(path, &contents)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 base::RefCountedString* ref_contents = new base::RefCountedString; | 70 base::RefCountedString* ref_contents = new base::RefCountedString; |
| 72 ref_contents->data() = contents; | 71 ref_contents->data() = contents; |
| 73 callback.Run(ref_contents); | 72 callback.Run(ref_contents); |
| 74 return true; | 73 return true; |
| 75 } | 74 } |
| 76 | 75 |
| 77 class BrowserTargetImpl : public mojom::BrowserTarget { | 76 class BrowserTargetImpl : public mojom::BrowserTarget { |
| 78 public: | 77 public: |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 NavigateToURL(other_shell, test_url); | 230 NavigateToURL(other_shell, test_url); |
| 232 // RunLoop is quit when message received from page. | 231 // RunLoop is quit when message received from page. |
| 233 other_run_loop.Run(); | 232 other_run_loop.Run(); |
| 234 EXPECT_TRUE(g_got_message); | 233 EXPECT_TRUE(g_got_message); |
| 235 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), | 234 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), |
| 236 other_shell->web_contents()->GetRenderProcessHost()); | 235 other_shell->web_contents()->GetRenderProcessHost()); |
| 237 } | 236 } |
| 238 | 237 |
| 239 } // namespace | 238 } // namespace |
| 240 } // namespace content | 239 } // namespace content |
| OLD | NEW |