OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #import "base/test/ios/wait_util.h" | 9 #import "base/test/ios/wait_util.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #import "ios/web/public/navigation_manager.h" | 11 #import "ios/web/public/navigation_manager.h" |
| 12 #include "ios/web/public/web_state/web_state_interface_provider.h" |
12 #include "ios/web/public/web_ui_ios_data_source.h" | 13 #include "ios/web/public/web_ui_ios_data_source.h" |
13 #include "ios/web/public/webui/web_ui_ios_controller.h" | 14 #include "ios/web/public/webui/web_ui_ios_controller.h" |
14 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" | 15 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" |
15 #include "ios/web/test/grit/test_resources.h" | 16 #include "ios/web/test/grit/test_resources.h" |
16 #include "ios/web/test/mojo_test.mojom.h" | 17 #include "ios/web/test/mojo_test.mojom.h" |
17 #include "ios/web/test/test_url_constants.h" | 18 #include "ios/web/test/test_url_constants.h" |
18 #import "ios/web/test/web_int_test.h" | 19 #import "ios/web/test/web_int_test.h" |
19 #import "ios/web/web_state/ui/crw_web_controller.h" | 20 #import "ios/web/web_state/ui/crw_web_controller.h" |
20 #import "ios/web/web_state/web_state_impl.h" | 21 #import "ios/web/web_state/web_state_impl.h" |
21 #include "mojo/public/cpp/bindings/binding_set.h" | 22 #include "mojo/public/cpp/bindings/binding_set.h" |
22 #include "services/service_manager/public/cpp/identity.h" | 23 #include "services/service_manager/public/cpp/identity.h" |
23 #include "services/service_manager/public/cpp/interface_registry.h" | |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 #include "url/scheme_host_port.h" | 25 #include "url/scheme_host_port.h" |
26 | 26 |
27 namespace web { | 27 namespace web { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Hostname for test WebUI page. | 31 // Hostname for test WebUI page. |
32 const char kTestWebUIURLHost[] = "testwebui"; | 32 const char kTestWebUIURLHost[] = "testwebui"; |
33 | 33 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 web::WebUIIOSDataSource::Create(kTestWebUIURLHost); | 96 web::WebUIIOSDataSource::Create(kTestWebUIURLHost); |
97 | 97 |
98 source->AddResourcePath("mojo_test.js", IDR_MOJO_TEST_JS); | 98 source->AddResourcePath("mojo_test.js", IDR_MOJO_TEST_JS); |
99 source->AddResourcePath("ios/web/test/mojo_test.mojom", | 99 source->AddResourcePath("ios/web/test/mojo_test.mojom", |
100 IDR_MOJO_TEST_MOJO_JS); | 100 IDR_MOJO_TEST_MOJO_JS); |
101 source->SetDefaultResource(IDR_MOJO_TEST_HTML); | 101 source->SetDefaultResource(IDR_MOJO_TEST_HTML); |
102 | 102 |
103 web::WebState* web_state = web_ui->GetWebState(); | 103 web::WebState* web_state = web_ui->GetWebState(); |
104 web::WebUIIOSDataSource::Add(web_state->GetBrowserState(), source); | 104 web::WebUIIOSDataSource::Add(web_state->GetBrowserState(), source); |
105 | 105 |
106 web_state->GetMojoInterfaceRegistry()->AddInterface(ui_handler); | 106 web_state->GetWebStateInterfaceProvider()->registry()->AddInterface( |
| 107 ui_handler); |
107 } | 108 } |
108 }; | 109 }; |
109 | 110 |
110 // Factory that creates TestUI controller. | 111 // Factory that creates TestUI controller. |
111 class TestWebUIControllerFactory : public WebUIIOSControllerFactory { | 112 class TestWebUIControllerFactory : public WebUIIOSControllerFactory { |
112 public: | 113 public: |
113 // Constructs a controller factory which will eventually create |ui_handler|. | 114 // Constructs a controller factory which will eventually create |ui_handler|. |
114 explicit TestWebUIControllerFactory(TestUIHandler* ui_handler) | 115 explicit TestWebUIControllerFactory(TestUIHandler* ui_handler) |
115 : ui_handler_(ui_handler) {} | 116 : ui_handler_(ui_handler) {} |
116 | 117 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // of this hack. | 171 // of this hack. |
171 base::RunLoop loop; | 172 base::RunLoop loop; |
172 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 173 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
173 loop.QuitClosure()); | 174 loop.QuitClosure()); |
174 loop.Run(); | 175 loop.Run(); |
175 return test_ui_handler()->IsFinReceived(); | 176 return test_ui_handler()->IsFinReceived(); |
176 }); | 177 }); |
177 } | 178 } |
178 | 179 |
179 } // namespace web | 180 } // namespace web |
OLD | NEW |