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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 bool got_message = false; | 40 bool got_message = false; |
41 | 41 |
42 // The bindings for the page are generated from a .mojom file. This code looks | 42 // The bindings for the page are generated from a .mojom file. This code looks |
43 // up the generated file from disk and returns it. | 43 // up the generated file from disk and returns it. |
44 bool GetResource(const std::string& id, | 44 bool GetResource(const std::string& id, |
45 const WebUIDataSource::GotDataCallback& callback) { | 45 const WebUIDataSource::GotDataCallback& callback) { |
46 if (id.find(".mojom") != std::string::npos) { | 46 if (id.find(".mojom") != std::string::npos) { |
47 std::string contents; | 47 std::string contents; |
48 CHECK(base::ReadFileToString(mojo::test::GetFilePathForJSResource(id), | 48 CHECK(base::ReadFileToString(mojo::test::GetFilePathForJSResource(id), |
49 &contents, std::string::npos)) | 49 &contents)) |
50 << id; | 50 << id; |
51 base::RefCountedString* ref_contents = new base::RefCountedString; | 51 base::RefCountedString* ref_contents = new base::RefCountedString; |
52 ref_contents->data() = contents; | 52 ref_contents->data() = contents; |
53 callback.Run(ref_contents); | 53 callback.Run(ref_contents); |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 base::FilePath path; | 57 base::FilePath path; |
58 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); | 58 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); |
59 path = path.AppendASCII(id.substr(0, id.find("?"))); | 59 path = path.AppendASCII(id.substr(0, id.find("?"))); |
60 std::string contents; | 60 std::string contents; |
61 CHECK(base::ReadFileToString(path, &contents, std::string::npos)) | 61 CHECK(base::ReadFileToString(path, &contents)) << path.value(); |
62 << path.value(); | |
63 base::RefCountedString* ref_contents = new base::RefCountedString; | 62 base::RefCountedString* ref_contents = new base::RefCountedString; |
64 ref_contents->data() = contents; | 63 ref_contents->data() = contents; |
65 callback.Run(ref_contents); | 64 callback.Run(ref_contents); |
66 return true; | 65 return true; |
67 } | 66 } |
68 | 67 |
69 class BrowserTargetImpl : public BrowserTarget { | 68 class BrowserTargetImpl : public BrowserTarget { |
70 public: | 69 public: |
71 BrowserTargetImpl(base::RunLoop* run_loop, | 70 BrowserTargetImpl(base::RunLoop* run_loop, |
72 mojo::InterfaceRequest<BrowserTarget> request) | 71 mojo::InterfaceRequest<BrowserTarget> request) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); | 240 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); |
242 | 241 |
243 DOMMessageQueue message_queue; | 242 DOMMessageQueue message_queue; |
244 std::string message; | 243 std::string message; |
245 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 244 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
246 EXPECT_EQ("true", message); | 245 EXPECT_EQ("true", message); |
247 } | 246 } |
248 | 247 |
249 } // namespace | 248 } // namespace |
250 } // namespace content | 249 } // namespace content |
OLD | NEW |