Add 'did_proceed' and 'repeat_visit' to ClientMalwareReportRequest to track CTR.
[chromium-blink-merge.git] / components / web_view / test_frame_tree_delegate.cc
blobac95488dedf3546ac34d748c6ad1ee52dd9c1551
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
3 // found in the LICENSE file.
5 #include "components/web_view/test_frame_tree_delegate.h"
7 #include "base/run_loop.h"
8 #include "components/web_view/client_initiated_frame_connection.h"
9 #include "components/web_view/frame_connection.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace web_view {
14 TestFrameTreeDelegate::TestFrameTreeDelegate(mojo::ApplicationImpl* app)
15 : app_(app),
16 waiting_for_create_frame_(false),
17 waiting_for_destroy_frame_(nullptr),
18 most_recent_frame_(nullptr),
19 waiting_for_frame_disconnected_(nullptr) {}
21 TestFrameTreeDelegate::~TestFrameTreeDelegate() {}
23 Frame* TestFrameTreeDelegate::WaitForCreateFrame() {
24 if (is_waiting()) {
25 ADD_FAILURE() << "already waiting";
26 return nullptr;
28 waiting_for_create_frame_ = true;
29 run_loop_.reset(new base::RunLoop);
30 run_loop_->Run();
31 run_loop_.reset();
32 return most_recent_frame_;
35 void TestFrameTreeDelegate::WaitForDestroyFrame(Frame* frame) {
36 ASSERT_FALSE(is_waiting());
37 waiting_for_destroy_frame_ = frame;
38 run_loop_.reset(new base::RunLoop);
39 run_loop_->Run();
40 run_loop_.reset();
43 void TestFrameTreeDelegate::WaitForFrameDisconnected(Frame* frame) {
44 ASSERT_FALSE(is_waiting());
45 waiting_for_frame_disconnected_ = frame;
46 run_loop_.reset(new base::RunLoop);
47 run_loop_->Run();
48 run_loop_.reset();
51 scoped_ptr<FrameUserData> TestFrameTreeDelegate::CreateUserDataForNewFrame(
52 mojom::FrameClientPtr frame_client) {
53 return make_scoped_ptr(
54 new ClientInitiatedFrameConnection(frame_client.Pass()));
57 bool TestFrameTreeDelegate::CanPostMessageEventToFrame(
58 const Frame* source,
59 const Frame* target,
60 mojom::HTMLMessageEvent* event) {
61 return true;
64 void TestFrameTreeDelegate::LoadingStateChanged(bool loading, double progress) {
67 void TestFrameTreeDelegate::TitleChanged(const mojo::String& title) {}
69 void TestFrameTreeDelegate::NavigateTopLevel(Frame* source,
70 mojo::URLRequestPtr request) {}
72 void TestFrameTreeDelegate::CanNavigateFrame(
73 Frame* target,
74 mojo::URLRequestPtr request,
75 const CanNavigateFrameCallback& callback) {
76 FrameConnection::CreateConnectionForCanNavigateFrame(
77 app_, target, request.Pass(), callback);
80 void TestFrameTreeDelegate::DidStartNavigation(Frame* frame) {}
82 void TestFrameTreeDelegate::DidCommitProvisionalLoad(Frame* frame) {}
84 void TestFrameTreeDelegate::DidCreateFrame(Frame* frame) {
85 if (waiting_for_create_frame_) {
86 most_recent_frame_ = frame;
87 run_loop_->Quit();
91 void TestFrameTreeDelegate::DidDestroyFrame(Frame* frame) {
92 if (waiting_for_destroy_frame_ == frame) {
93 waiting_for_destroy_frame_ = nullptr;
94 run_loop_->Quit();
98 void TestFrameTreeDelegate::OnViewEmbeddedInFrameDisconnected(Frame* frame) {
99 if (waiting_for_frame_disconnected_ == frame) {
100 waiting_for_frame_disconnected_ = nullptr;
101 run_loop_->Quit();
105 } // namespace web_view