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 #ifndef COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ | 5 #ifndef COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ |
6 #define COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ | 6 #define COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "third_party/WebKit/public/web/WebViewClient.h" | 9 #include "third_party/WebKit/public/web/WebViewClient.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 class WebView; | 12 class WebView; |
13 } // namespace blink | 13 } // namespace blink |
14 | 14 |
15 namespace test_runner { | 15 namespace test_runner { |
16 | 16 |
17 class EventSender; | 17 class EventSender; |
18 class TestRunner; | 18 class TestRunner; |
19 class WebTestDelegate; | 19 class WebTestDelegate; |
20 class WebViewTestProxyBase; | 20 class WebViewTestProxyBase; |
21 | 21 |
22 // WebViewTestClient implements WebViewClient interface, providing behavior | 22 // WebViewTestClient implements WebViewClient interface, providing behavior |
23 // expected by tests. WebViewTestClient ends up used by WebViewTestProxy | 23 // expected by tests. WebViewTestClient ends up used by WebViewTestProxy |
24 // which coordinates forwarding WebViewClient calls either to | 24 // which coordinates forwarding WebViewClient calls either to |
25 // WebViewTestClient or to the product code (i.e. to RenderViewImpl). | 25 // WebViewTestClient or to the product code (i.e. to RenderViewImpl). |
26 class WebViewTestClient : public blink::WebViewClient { | 26 class WebViewTestClient : public blink::WebViewClient { |
27 public: | 27 public: |
28 // Caller has to ensure that all arguments (i.e. |test_runner| and |delegate|) | 28 // Caller has to ensure |web_view_test_proxy_base| lives longer than |this|. |
29 // live longer than |this|. | 29 WebViewTestClient(WebViewTestProxyBase* web_view_test_proxy_base); |
30 WebViewTestClient(TestRunner* test_runner, | |
31 WebViewTestProxyBase* web_view_test_proxy_base); | |
32 | 30 |
33 virtual ~WebViewTestClient(); | 31 virtual ~WebViewTestClient(); |
34 | 32 |
35 // WebViewClient overrides needed by WebViewTestProxy. | 33 // WebViewClient overrides needed by WebViewTestProxy. |
36 void showValidationMessage(const blink::WebRect& anchor_in_root_view, | 34 void showValidationMessage(const blink::WebRect& anchor_in_root_view, |
37 const blink::WebString& main_message, | 35 const blink::WebString& main_message, |
38 blink::WebTextDirection main_message_hint, | 36 blink::WebTextDirection main_message_hint, |
39 const blink::WebString& sub_message, | 37 const blink::WebString& sub_message, |
40 blink::WebTextDirection sub_message_hint) override; | 38 blink::WebTextDirection sub_message_hint) override; |
41 void startDragging(blink::WebLocalFrame* frame, | 39 void startDragging(blink::WebLocalFrame* frame, |
42 const blink::WebDragData& data, | 40 const blink::WebDragData& data, |
43 blink::WebDragOperationsMask mask, | 41 blink::WebDragOperationsMask mask, |
44 const blink::WebImage& image, | 42 const blink::WebImage& image, |
45 const blink::WebPoint& point) override; | 43 const blink::WebPoint& point) override; |
46 void didChangeContents() override; | 44 void didChangeContents() override; |
47 blink::WebView* createView(blink::WebLocalFrame* creator, | 45 blink::WebView* createView(blink::WebLocalFrame* creator, |
48 const blink::WebURLRequest& request, | 46 const blink::WebURLRequest& request, |
49 const blink::WebWindowFeatures& features, | 47 const blink::WebWindowFeatures& features, |
50 const blink::WebString& frame_name, | 48 const blink::WebString& frame_name, |
51 blink::WebNavigationPolicy policy, | 49 blink::WebNavigationPolicy policy, |
52 bool suppress_opener) override; | 50 bool suppress_opener) override; |
53 void setStatusText(const blink::WebString& text) override; | 51 void setStatusText(const blink::WebString& text) override; |
54 void printPage(blink::WebLocalFrame* frame) override; | 52 void printPage(blink::WebLocalFrame* frame) override; |
55 blink::WebSpeechRecognizer* speechRecognizer() override; | 53 blink::WebSpeechRecognizer* speechRecognizer() override; |
56 blink::WebString acceptLanguages() override; | 54 blink::WebString acceptLanguages() override; |
57 void didFocus() override; | 55 void didFocus() override; |
58 | 56 |
59 private: | 57 private: |
60 WebTestDelegate* delegate(); | 58 WebTestDelegate* delegate(); |
| 59 TestRunner* test_runner(); |
61 | 60 |
62 // Borrowed pointers to other parts of Layout Tests state. | 61 // Borrowed pointer to WebViewTestProxyBase. |
63 TestRunner* test_runner_; | |
64 WebViewTestProxyBase* web_view_test_proxy_base_; | 62 WebViewTestProxyBase* web_view_test_proxy_base_; |
65 | 63 |
66 DISALLOW_COPY_AND_ASSIGN(WebViewTestClient); | 64 DISALLOW_COPY_AND_ASSIGN(WebViewTestClient); |
67 }; | 65 }; |
68 | 66 |
69 } // namespace test_runner | 67 } // namespace test_runner |
70 | 68 |
71 #endif // COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ | 69 #endif // COMPONENTS_TEST_RUNNER_WEB_VIEW_TEST_CLIENT_H_ |
OLD | NEW |