| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/web_view/frame.h" | 5 #include "components/web_view/frame.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "components/mus/public/cpp/window_tree_delegate.h" | 21 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 22 #include "components/mus/public/cpp/window_tree_host_factory.h" | 22 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 23 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 23 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 24 #include "components/web_view/frame_connection.h" | 24 #include "components/web_view/frame_connection.h" |
| 25 #include "components/web_view/frame_tree.h" | 25 #include "components/web_view/frame_tree.h" |
| 26 #include "components/web_view/frame_tree_delegate.h" | 26 #include "components/web_view/frame_tree_delegate.h" |
| 27 #include "components/web_view/frame_user_data.h" | 27 #include "components/web_view/frame_user_data.h" |
| 28 #include "components/web_view/test_frame_tree_delegate.h" | 28 #include "components/web_view/test_frame_tree_delegate.h" |
| 29 #include "mojo/shell/public/cpp/application_connection.h" | 29 #include "mojo/shell/public/cpp/application_connection.h" |
| 30 #include "mojo/shell/public/cpp/application_delegate.h" | 30 #include "mojo/shell/public/cpp/application_delegate.h" |
| 31 #include "mojo/shell/public/cpp/application_impl.h" | |
| 32 #include "mojo/shell/public/cpp/application_test_base.h" | 31 #include "mojo/shell/public/cpp/application_test_base.h" |
| 33 #include "mojo/shell/public/cpp/service_provider_impl.h" | 32 #include "mojo/shell/public/cpp/service_provider_impl.h" |
| 34 | 33 |
| 35 using mus::Window; | 34 using mus::Window; |
| 36 using mus::WindowTreeConnection; | 35 using mus::WindowTreeConnection; |
| 37 | 36 |
| 38 namespace web_view { | 37 namespace web_view { |
| 39 | 38 |
| 40 namespace { | 39 namespace { |
| 41 | 40 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 69 } | 68 } |
| 70 | 69 |
| 71 } // namespace | 70 } // namespace |
| 72 | 71 |
| 73 void OnGotIdCallback(base::RunLoop* run_loop) { | 72 void OnGotIdCallback(base::RunLoop* run_loop) { |
| 74 run_loop->Quit(); | 73 run_loop->Quit(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 // Creates a new FrameConnection. This runs a nested message loop until the | 76 // Creates a new FrameConnection. This runs a nested message loop until the |
| 78 // content handler id is obtained. | 77 // content handler id is obtained. |
| 79 scoped_ptr<FrameConnection> CreateFrameConnection(mojo::ApplicationImpl* app) { | 78 scoped_ptr<FrameConnection> CreateFrameConnection(mojo::Shell* shell, |
| 79 const std::string& url) { |
| 80 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 80 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
| 81 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 81 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 82 request->url = mojo::String::From(app->url()); | 82 request->url = mojo::String::From(url); |
| 83 base::RunLoop run_loop; | 83 base::RunLoop run_loop; |
| 84 frame_connection->Init(app, std::move(request), | 84 frame_connection->Init(shell, std::move(request), |
| 85 base::Bind(&OnGotIdCallback, &run_loop)); | 85 base::Bind(&OnGotIdCallback, &run_loop)); |
| 86 run_loop.Run(); | 86 run_loop.Run(); |
| 87 return frame_connection; | 87 return frame_connection; |
| 88 } | 88 } |
| 89 | 89 |
| 90 class TestFrameClient : public mojom::FrameClient { | 90 class TestFrameClient : public mojom::FrameClient { |
| 91 public: | 91 public: |
| 92 TestFrameClient() | 92 TestFrameClient() |
| 93 : connect_count_(0), last_dispatch_load_event_frame_id_(0) {} | 93 : connect_count_(0), last_dispatch_load_event_frame_id_(0) {} |
| 94 ~TestFrameClient() override {} | 94 ~TestFrameClient() override {} |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 FrameTree* frame_tree() { return frame_tree_.get(); } | 305 FrameTree* frame_tree() { return frame_tree_.get(); } |
| 306 WindowAndFrame* root_window_and_frame() { | 306 WindowAndFrame* root_window_and_frame() { |
| 307 return root_window_and_frame_.get(); | 307 return root_window_and_frame_.get(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 scoped_ptr<WindowAndFrame> NavigateFrameWithStartTime( | 310 scoped_ptr<WindowAndFrame> NavigateFrameWithStartTime( |
| 311 WindowAndFrame* window_and_frame, | 311 WindowAndFrame* window_and_frame, |
| 312 base::TimeTicks navigation_start_time) { | 312 base::TimeTicks navigation_start_time) { |
| 313 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 313 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 314 request->url = mojo::String::From(application_impl()->url()); | 314 request->url = mojo::String::From(shell_url()); |
| 315 request->originating_time_ticks = navigation_start_time.ToInternalValue(); | 315 request->originating_time_ticks = navigation_start_time.ToInternalValue(); |
| 316 window_and_frame->server_frame()->RequestNavigate( | 316 window_and_frame->server_frame()->RequestNavigate( |
| 317 mojom::NavigationTargetType::EXISTING_FRAME, | 317 mojom::NavigationTargetType::EXISTING_FRAME, |
| 318 window_and_frame->window()->id(), std::move(request)); | 318 window_and_frame->window()->id(), std::move(request)); |
| 319 return WaitForViewAndFrame(); | 319 return WaitForViewAndFrame(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 scoped_ptr<WindowAndFrame> NavigateFrame(WindowAndFrame* window_and_frame) { | 322 scoped_ptr<WindowAndFrame> NavigateFrame(WindowAndFrame* window_and_frame) { |
| 323 return NavigateFrameWithStartTime(window_and_frame, base::TimeTicks()); | 323 return NavigateFrameWithStartTime(window_and_frame, base::TimeTicks()); |
| 324 } | 324 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 void OnEmbed(Window* root) override { | 367 void OnEmbed(Window* root) override { |
| 368 most_recent_connection_ = root->connection(); | 368 most_recent_connection_ = root->connection(); |
| 369 QuitRunLoop(); | 369 QuitRunLoop(); |
| 370 } | 370 } |
| 371 void OnConnectionLost(WindowTreeConnection* connection) override {} | 371 void OnConnectionLost(WindowTreeConnection* connection) override {} |
| 372 | 372 |
| 373 // Overridden from testing::Test: | 373 // Overridden from testing::Test: |
| 374 void SetUp() override { | 374 void SetUp() override { |
| 375 ApplicationTestBase::SetUp(); | 375 ApplicationTestBase::SetUp(); |
| 376 | 376 |
| 377 mus::CreateWindowTreeHost(application_impl(), this, &host_, nullptr); | 377 mus::CreateWindowTreeHost(shell(), this, &host_, nullptr); |
| 378 | 378 |
| 379 ASSERT_TRUE(DoRunLoopWithTimeout()); | 379 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 380 std::swap(window_manager_, most_recent_connection_); | 380 std::swap(window_manager_, most_recent_connection_); |
| 381 | 381 |
| 382 // Creates a FrameTree, which creates a single frame. Wait for the | 382 // Creates a FrameTree, which creates a single frame. Wait for the |
| 383 // FrameClient to be connected to. | 383 // FrameClient to be connected to. |
| 384 frame_tree_delegate_.reset(new TestFrameTreeDelegate(application_impl())); | 384 frame_tree_delegate_.reset(new TestFrameTreeDelegate(shell())); |
| 385 scoped_ptr<FrameConnection> frame_connection = | 385 scoped_ptr<FrameConnection> frame_connection = |
| 386 CreateFrameConnection(application_impl()); | 386 CreateFrameConnection(shell(), shell_url()); |
| 387 mojom::FrameClient* frame_client = frame_connection->frame_client(); | 387 mojom::FrameClient* frame_client = frame_connection->frame_client(); |
| 388 mus::mojom::WindowTreeClientPtr window_tree_client = | 388 mus::mojom::WindowTreeClientPtr window_tree_client = |
| 389 frame_connection->GetWindowTreeClient(); | 389 frame_connection->GetWindowTreeClient(); |
| 390 mus::Window* frame_root_view = window_manager()->NewWindow(); | 390 mus::Window* frame_root_view = window_manager()->NewWindow(); |
| 391 (*window_manager()->GetRoots().begin())->AddChild(frame_root_view); | 391 (*window_manager()->GetRoots().begin())->AddChild(frame_root_view); |
| 392 frame_tree_.reset(new FrameTree( | 392 frame_tree_.reset(new FrameTree( |
| 393 0u, frame_root_view, std::move(window_tree_client), | 393 0u, frame_root_view, std::move(window_tree_client), |
| 394 frame_tree_delegate_.get(), frame_client, std::move(frame_connection), | 394 frame_tree_delegate_.get(), frame_client, std::move(frame_connection), |
| 395 Frame::ClientPropertyMap(), base::TimeTicks::Now())); | 395 Frame::ClientPropertyMap(), base::TimeTicks::Now())); |
| 396 root_window_and_frame_ = WaitForViewAndFrame(); | 396 root_window_and_frame_ = WaitForViewAndFrame(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 base::TimeTicks navigation_start_time = base::TimeTicks::FromInternalValue(1); | 574 base::TimeTicks navigation_start_time = base::TimeTicks::FromInternalValue(1); |
| 575 scoped_ptr<WindowAndFrame> navigated_child_view_and_frame = | 575 scoped_ptr<WindowAndFrame> navigated_child_view_and_frame = |
| 576 NavigateFrameWithStartTime(child_view_and_frame.get(), | 576 NavigateFrameWithStartTime(child_view_and_frame.get(), |
| 577 navigation_start_time); | 577 navigation_start_time); |
| 578 EXPECT_EQ(navigation_start_time, | 578 EXPECT_EQ(navigation_start_time, |
| 579 navigated_child_view_and_frame->test_frame_client() | 579 navigated_child_view_and_frame->test_frame_client() |
| 580 ->last_navigation_start_time()); | 580 ->last_navigation_start_time()); |
| 581 } | 581 } |
| 582 | 582 |
| 583 } // namespace web_view | 583 } // namespace web_view |
| OLD | NEW |