blob: 1f021eedd3fb30b19d6094fd916dee1bcda27873 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_
#define COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "components/web_view/frame_tree_delegate.h"
namespace base {
class RunLoop;
}
namespace mojo {
class ApplicationImpl;
}
namespace web_view {
class TestFrameTreeDelegate : public FrameTreeDelegate {
public:
explicit TestFrameTreeDelegate(mojo::ApplicationImpl* app);
~TestFrameTreeDelegate() override;
mojo::ApplicationImpl* app() { return app_; }
// Runs a message loop until DidCreateFrame() is called, returning the
// Frame supplied to DidCreateFrame().
Frame* WaitForCreateFrame();
// Waits for DidDestroyFrame() to be called with |frame|.
void WaitForDestroyFrame(Frame* frame);
// Waits for OnViewEmbeddedInFrameDisconnected() to be called with |frame|.
void WaitForFrameDisconnected(Frame* frame);
// TestFrameTreeDelegate:
scoped_ptr<FrameUserData> CreateUserDataForNewFrame(
mojom::FrameClientPtr frame_client) override;
bool CanPostMessageEventToFrame(const Frame* source,
const Frame* target,
mojom::HTMLMessageEvent* event) override;
void LoadingStateChanged(bool loading, double progress) override;
void TitleChanged(const mojo::String& title) override;
void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override;
void CanNavigateFrame(Frame* target,
mojo::URLRequestPtr request,
const CanNavigateFrameCallback& callback) override;
void DidStartNavigation(Frame* frame) override;
void DidCommitProvisionalLoad(Frame* frame) override;
void DidNavigateLocally(Frame* source, const GURL& url) override;
void DidCreateFrame(Frame* frame) override;
void DidDestroyFrame(Frame* frame) override;
void OnViewEmbeddedInFrameDisconnected(Frame* frame) override;
private:
bool is_waiting() const { return run_loop_.get(); }
mojo::ApplicationImpl* app_;
bool waiting_for_create_frame_;
Frame* waiting_for_destroy_frame_;
scoped_ptr<base::RunLoop> run_loop_;
Frame* most_recent_frame_;
Frame* waiting_for_frame_disconnected_;
DISALLOW_COPY_AND_ASSIGN(TestFrameTreeDelegate);
};
} // namespace web_view
#endif // COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_
|