| 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 IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ | 6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/observer_list.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "ios/web/public/web_state/url_verification_constants.h" | 14 #include "ios/web/public/web_state/url_verification_constants.h" |
| 14 #include "ios/web/public/web_state/web_state.h" | 15 #include "ios/web/public/web_state/web_state.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace web { | 18 namespace web { |
| 18 | 19 |
| 19 // Minimal implementation of WebState, to be used in tests. | 20 // Minimal implementation of WebState, to be used in tests. |
| 20 class TestWebState : public WebState { | 21 class TestWebState : public WebState { |
| 21 public: | 22 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 50 const GURL& GetLastCommittedURL() const override; | 51 const GURL& GetLastCommittedURL() const override; |
| 51 GURL GetCurrentURL(URLVerificationTrustLevel* trust_level) const override; | 52 GURL GetCurrentURL(URLVerificationTrustLevel* trust_level) const override; |
| 52 void ShowTransientContentView(CRWContentView* content_view) override {} | 53 void ShowTransientContentView(CRWContentView* content_view) override {} |
| 53 void AddScriptCommandCallback(const ScriptCommandCallback& callback, | 54 void AddScriptCommandCallback(const ScriptCommandCallback& callback, |
| 54 const std::string& command_prefix) override {} | 55 const std::string& command_prefix) override {} |
| 55 void RemoveScriptCommandCallback(const std::string& command_prefix) override { | 56 void RemoveScriptCommandCallback(const std::string& command_prefix) override { |
| 56 } | 57 } |
| 57 CRWWebViewProxyType GetWebViewProxy() const override; | 58 CRWWebViewProxyType GetWebViewProxy() const override; |
| 58 bool IsShowingWebInterstitial() const override; | 59 bool IsShowingWebInterstitial() const override; |
| 59 WebInterstitial* GetWebInterstitial() const override; | 60 WebInterstitial* GetWebInterstitial() const override; |
| 60 void AddObserver(WebStateObserver* observer) override {} | 61 |
| 61 void RemoveObserver(WebStateObserver* observer) override {} | 62 void AddObserver(WebStateObserver* observer) override; |
| 63 |
| 64 void RemoveObserver(WebStateObserver* observer) override; |
| 65 |
| 62 void AddPolicyDecider(WebStatePolicyDecider* decider) override {} | 66 void AddPolicyDecider(WebStatePolicyDecider* decider) override {} |
| 63 void RemovePolicyDecider(WebStatePolicyDecider* decider) override {} | 67 void RemovePolicyDecider(WebStatePolicyDecider* decider) override {} |
| 64 int DownloadImage(const GURL& url, | 68 int DownloadImage(const GURL& url, |
| 65 bool is_favicon, | 69 bool is_favicon, |
| 66 uint32_t max_bitmap_size, | 70 uint32_t max_bitmap_size, |
| 67 bool bypass_cache, | 71 bool bypass_cache, |
| 68 const ImageDownloadCallback& callback) override; | 72 const ImageDownloadCallback& callback) override; |
| 69 service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() override; | 73 service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() override; |
| 70 base::WeakPtr<WebState> AsWeakPtr() override; | 74 base::WeakPtr<WebState> AsWeakPtr() override; |
| 71 | 75 |
| 72 // Setters for test data. | 76 // Setters for test data. |
| 73 void SetContentIsHTML(bool content_is_html); | 77 void SetContentIsHTML(bool content_is_html); |
| 74 void SetLoading(bool is_loading); | 78 void SetLoading(bool is_loading); |
| 75 void SetCurrentURL(const GURL& url); | 79 void SetCurrentURL(const GURL& url); |
| 76 void SetTrustLevel(URLVerificationTrustLevel trust_level); | 80 void SetTrustLevel(URLVerificationTrustLevel trust_level); |
| 77 | 81 |
| 78 private: | 82 private: |
| 79 bool web_usage_enabled_; | 83 bool web_usage_enabled_; |
| 80 bool is_loading_; | 84 bool is_loading_; |
| 81 GURL url_; | 85 GURL url_; |
| 82 base::string16 title_; | 86 base::string16 title_; |
| 83 URLVerificationTrustLevel trust_level_; | 87 URLVerificationTrustLevel trust_level_; |
| 84 bool content_is_html_; | 88 bool content_is_html_; |
| 85 std::string mime_type_; | 89 std::string mime_type_; |
| 86 std::string content_language_; | 90 std::string content_language_; |
| 91 |
| 92 // A list of observers notified when page state changes. Weak references. |
| 93 base::ObserverList<WebStateObserver, true> observers_; |
| 87 }; | 94 }; |
| 88 | 95 |
| 89 } // namespace web | 96 } // namespace web |
| 90 | 97 |
| 91 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ | 98 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_ |
| OLD | NEW |