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 #ifndef WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ | 5 #ifndef WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ |
6 #define WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ | 6 #define WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ios/web/public/web_client.h" | 13 #include "ios/web/public/web_client.h" |
14 | 14 |
15 namespace web { | 15 namespace web { |
16 | 16 |
17 class WebViewFactory; | |
18 | |
19 // A WebClient used for testing purposes. | 17 // A WebClient used for testing purposes. |
20 class TestWebClient : public web::WebClient { | 18 class TestWebClient : public web::WebClient { |
21 public: | 19 public: |
22 TestWebClient(); | 20 TestWebClient(); |
23 ~TestWebClient() override; | 21 ~TestWebClient() override; |
24 // WebClient implementation. | 22 // WebClient implementation. |
25 std::string GetUserAgent(bool is_desktop_user_agent) const override; | 23 std::string GetUserAgent(bool is_desktop_user_agent) const override; |
26 NSString* GetEarlyPageScript(web::WebViewType web_view_type) const override; | 24 NSString* GetEarlyPageScript(web::WebViewType web_view_type) const override; |
27 | 25 |
28 // Changes the user agent for testing purposes. Passing true | 26 // Changes the user agent for testing purposes. Passing true |
29 // for |is_desktop_user_agent| affects the result of GetUserAgent(true) call. | 27 // for |is_desktop_user_agent| affects the result of GetUserAgent(true) call. |
30 // Passing false affects the result of GetUserAgent(false). | 28 // Passing false affects the result of GetUserAgent(false). |
31 void SetUserAgent(const std::string& user_agent, bool is_desktop_user_agent); | 29 void SetUserAgent(const std::string& user_agent, bool is_desktop_user_agent); |
32 | 30 |
33 // Changes Early Page Script for testing purposes. | 31 // Changes Early Page Script for testing purposes. |
34 void SetEarlyPageScript(NSString* page_script, | 32 void SetEarlyPageScript(NSString* page_script, |
35 web::WebViewType web_view_type); | 33 web::WebViewType web_view_type); |
36 | 34 |
37 private: | 35 private: |
38 std::string user_agent_; | 36 std::string user_agent_; |
39 std::string desktop_user_agent_; | 37 std::string desktop_user_agent_; |
40 base::scoped_nsobject<NSMutableDictionary> early_page_scripts_; | 38 base::scoped_nsobject<NSMutableDictionary> early_page_scripts_; |
41 }; | 39 }; |
42 | 40 |
43 } // namespace web | 41 } // namespace web |
44 | 42 |
45 #endif // WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ | 43 #endif // WEB_TEST_WEB_PUBLIC_TEST_TEST_WEB_CLIENT_H_ |
OLD | NEW |