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 | 7 |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 15 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
15 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 base::RefCountedString* ref_contents = new base::RefCountedString; | 75 base::RefCountedString* ref_contents = new base::RefCountedString; |
75 ref_contents->data() = contents; | 76 ref_contents->data() = contents; |
76 callback.Run(ref_contents); | 77 callback.Run(ref_contents); |
77 return true; | 78 return true; |
78 } | 79 } |
79 | 80 |
80 class BrowserTargetImpl : public BrowserTarget { | 81 class BrowserTargetImpl : public BrowserTarget { |
81 public: | 82 public: |
82 BrowserTargetImpl(base::RunLoop* run_loop, | 83 BrowserTargetImpl(base::RunLoop* run_loop, |
83 mojo::InterfaceRequest<BrowserTarget> request) | 84 mojo::InterfaceRequest<BrowserTarget> request) |
84 : run_loop_(run_loop), binding_(this, request.Pass()) {} | 85 : run_loop_(run_loop), binding_(this, std::move(request)) {} |
85 | 86 |
86 ~BrowserTargetImpl() override {} | 87 ~BrowserTargetImpl() override {} |
87 | 88 |
88 // BrowserTarget overrides: | 89 // BrowserTarget overrides: |
89 void Start(const mojo::Closure& closure) override { | 90 void Start(const mojo::Closure& closure) override { |
90 closure.Run(); | 91 closure.Run(); |
91 } | 92 } |
92 void Stop() override { | 93 void Stop() override { |
93 got_message = true; | 94 got_message = true; |
94 run_loop_->Quit(); | 95 run_loop_->Quit(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ~PingTestWebUIController() override {} | 134 ~PingTestWebUIController() override {} |
134 | 135 |
135 // WebUIController overrides: | 136 // WebUIController overrides: |
136 void RenderViewCreated(RenderViewHost* render_view_host) override { | 137 void RenderViewCreated(RenderViewHost* render_view_host) override { |
137 render_view_host->GetMainFrame()->GetServiceRegistry()-> | 138 render_view_host->GetMainFrame()->GetServiceRegistry()-> |
138 AddService<BrowserTarget>(base::Bind( | 139 AddService<BrowserTarget>(base::Bind( |
139 &PingTestWebUIController::CreateHandler, base::Unretained(this))); | 140 &PingTestWebUIController::CreateHandler, base::Unretained(this))); |
140 } | 141 } |
141 | 142 |
142 void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { | 143 void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { |
143 browser_target_.reset(new BrowserTargetImpl(run_loop_, request.Pass())); | 144 browser_target_.reset(new BrowserTargetImpl(run_loop_, std::move(request))); |
144 } | 145 } |
145 | 146 |
146 private: | 147 private: |
147 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController); | 148 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController); |
148 }; | 149 }; |
149 | 150 |
150 // WebUIControllerFactory that creates TestWebUIController. | 151 // WebUIControllerFactory that creates TestWebUIController. |
151 class TestWebUIControllerFactory : public WebUIControllerFactory { | 152 class TestWebUIControllerFactory : public WebUIControllerFactory { |
152 public: | 153 public: |
153 TestWebUIControllerFactory() : run_loop_(NULL) {} | 154 TestWebUIControllerFactory() : run_loop_(NULL) {} |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); | 254 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); |
254 | 255 |
255 DOMMessageQueue message_queue; | 256 DOMMessageQueue message_queue; |
256 std::string message; | 257 std::string message; |
257 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 258 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
258 EXPECT_EQ("true", message); | 259 EXPECT_EQ("true", message); |
259 } | 260 } |
260 | 261 |
261 } // namespace | 262 } // namespace |
262 } // namespace content | 263 } // namespace content |
OLD | NEW |