| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 // Test instance of WebUI that tracks the data passed to | 17 // Test instance of WebUI that tracks the data passed to |
| 18 // CallJavascriptFunction(). | 18 // CallJavascriptFunctionUnsafe(). |
| 19 class TestWebUI : public WebUI { | 19 class TestWebUI : public WebUI { |
| 20 public: | 20 public: |
| 21 TestWebUI(); | 21 TestWebUI(); |
| 22 ~TestWebUI() override; | 22 ~TestWebUI() override; |
| 23 | 23 |
| 24 void ClearTrackedCalls(); | 24 void ClearTrackedCalls(); |
| 25 void set_web_contents(WebContents* web_contents) { | 25 void set_web_contents(WebContents* web_contents) { |
| 26 web_contents_ = web_contents; | 26 web_contents_ = web_contents; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // WebUI overrides. | 29 // WebUI overrides. |
| 30 WebContents* GetWebContents() const override; | 30 WebContents* GetWebContents() const override; |
| 31 WebUIController* GetController() const override; | 31 WebUIController* GetController() const override; |
| 32 void SetController(WebUIController* controller) override {} | 32 void SetController(WebUIController* controller) override {} |
| 33 float GetDeviceScaleFactor() const override; | 33 float GetDeviceScaleFactor() const override; |
| 34 const base::string16& GetOverriddenTitle() const override; | 34 const base::string16& GetOverriddenTitle() const override; |
| 35 void OverrideTitle(const base::string16& title) override {} | 35 void OverrideTitle(const base::string16& title) override {} |
| 36 ui::PageTransition GetLinkTransitionType() const override; | 36 ui::PageTransition GetLinkTransitionType() const override; |
| 37 void SetLinkTransitionType(ui::PageTransition type) override {} | 37 void SetLinkTransitionType(ui::PageTransition type) override {} |
| 38 int GetBindings() const override; | 38 int GetBindings() const override; |
| 39 void SetBindings(int bindings) override {} | 39 void SetBindings(int bindings) override {} |
| 40 bool HasRenderFrame() override; | 40 bool HasRenderFrame() override; |
| 41 void AddMessageHandler(WebUIMessageHandler* handler) override; | 41 void AddMessageHandler(WebUIMessageHandler* handler) override; |
| 42 void RegisterMessageCallback(const std::string& message, | 42 void RegisterMessageCallback(const std::string& message, |
| 43 const MessageCallback& callback) override {} | 43 const MessageCallback& callback) override {} |
| 44 void ProcessWebUIMessage(const GURL& source_url, | 44 void ProcessWebUIMessage(const GURL& source_url, |
| 45 const std::string& message, | 45 const std::string& message, |
| 46 const base::ListValue& args) override {} | 46 const base::ListValue& args) override {} |
| 47 bool CanCallJavascript() override; | 47 bool CanCallJavascript() override; |
| 48 void CallJavascriptFunction(const std::string& function_name) override; | 48 void CallJavascriptFunctionUnsafe(const std::string& function_name) override; |
| 49 void CallJavascriptFunction(const std::string& function_name, | 49 void CallJavascriptFunctionUnsafe(const std::string& function_name, |
| 50 const base::Value& arg1) override; | 50 const base::Value& arg1) override; |
| 51 void CallJavascriptFunction(const std::string& function_name, | 51 void CallJavascriptFunctionUnsafe(const std::string& function_name, |
| 52 const base::Value& arg1, | 52 const base::Value& arg1, |
| 53 const base::Value& arg2) override; | 53 const base::Value& arg2) override; |
| 54 void CallJavascriptFunction(const std::string& function_name, | 54 void CallJavascriptFunctionUnsafe(const std::string& function_name, |
| 55 const base::Value& arg1, | 55 const base::Value& arg1, |
| 56 const base::Value& arg2, | 56 const base::Value& arg2, |
| 57 const base::Value& arg3) override; | 57 const base::Value& arg3) override; |
| 58 void CallJavascriptFunction(const std::string& function_name, | 58 void CallJavascriptFunctionUnsafe(const std::string& function_name, |
| 59 const base::Value& arg1, | 59 const base::Value& arg1, |
| 60 const base::Value& arg2, | 60 const base::Value& arg2, |
| 61 const base::Value& arg3, | 61 const base::Value& arg3, |
| 62 const base::Value& arg4) override; | 62 const base::Value& arg4) override; |
| 63 void CallJavascriptFunction( | 63 void CallJavascriptFunctionUnsafe( |
| 64 const std::string& function_name, | 64 const std::string& function_name, |
| 65 const std::vector<const base::Value*>& args) override; | 65 const std::vector<const base::Value*>& args) override; |
| 66 | 66 |
| 67 class CallData { | 67 class CallData { |
| 68 public: | 68 public: |
| 69 explicit CallData(const std::string& function_name); | 69 explicit CallData(const std::string& function_name); |
| 70 ~CallData(); | 70 ~CallData(); |
| 71 | 71 |
| 72 void TakeAsArg1(base::Value* arg); | 72 void TakeAsArg1(base::Value* arg); |
| 73 void TakeAsArg2(base::Value* arg); | 73 void TakeAsArg2(base::Value* arg); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 90 private: | 90 private: |
| 91 ScopedVector<CallData> call_data_; | 91 ScopedVector<CallData> call_data_; |
| 92 ScopedVector<WebUIMessageHandler> handlers_; | 92 ScopedVector<WebUIMessageHandler> handlers_; |
| 93 base::string16 temp_string_; | 93 base::string16 temp_string_; |
| 94 WebContents* web_contents_; | 94 WebContents* web_contents_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace content | 97 } // namespace content |
| 98 | 98 |
| 99 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ | 99 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_ |
| OLD | NEW |