| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_RENDERER_AUTOMATION_AUTOMATION_RENDERER_HELPER_H_ | |
| 6 #define CHROME_RENDERER_AUTOMATION_AUTOMATION_RENDERER_HELPER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "content/public/renderer/render_view_observer.h" | |
| 13 #include "content/public/renderer/render_view_observer_tracker.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class DictionaryValue; | |
| 17 } | |
| 18 | |
| 19 namespace WebKit { | |
| 20 class WebFrame; | |
| 21 class WebURL; | |
| 22 class WebView; | |
| 23 } | |
| 24 | |
| 25 struct AutomationMouseEvent; | |
| 26 struct ScriptEvaluationRequest; | |
| 27 | |
| 28 // Filters automation/testing messages sent to a |RenderView| and sends | |
| 29 // automation/testing messages to the browser. | |
| 30 class AutomationRendererHelper : public content::RenderViewObserver { | |
| 31 public: | |
| 32 explicit AutomationRendererHelper(content::RenderView* render_view); | |
| 33 virtual ~AutomationRendererHelper(); | |
| 34 | |
| 35 // Takes a snapshot of the entire page without changing layout size. | |
| 36 bool SnapshotEntirePage(WebKit::WebView* view, | |
| 37 std::vector<unsigned char>* png_data, | |
| 38 std::string* error_msg); | |
| 39 | |
| 40 // Evaluates a list of scripts. Each script must result in exactly | |
| 41 // one JavaScript object, which is passed to the next script as input. | |
| 42 // The final output is returned in |result|. If any JavaScript object | |
| 43 // contains an 'error' key, |error_msg| will be set to the corresponding | |
| 44 // value and the method will return false. If any script throws an exception, | |
| 45 // this method will return false with an appropriate error message. | |
| 46 // |script_chain| must not be empty. | |
| 47 bool EvaluateScriptChain( | |
| 48 const std::vector<ScriptEvaluationRequest>& script_chain, | |
| 49 scoped_ptr<base::DictionaryValue>* result, | |
| 50 std::string* error_msg); | |
| 51 | |
| 52 // Processes the given event. On error, returns false and sets |error_msg|. | |
| 53 bool ProcessMouseEvent(const AutomationMouseEvent& event, | |
| 54 std::string* error_msg); | |
| 55 | |
| 56 private: | |
| 57 void OnSnapshotEntirePage(); | |
| 58 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | |
| 59 void OnHeapProfilerDump(const std::string& reason); | |
| 60 #endif | |
| 61 | |
| 62 // RenderViewObserver implementation. | |
| 63 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 64 virtual void WillPerformClientRedirect( | |
| 65 WebKit::WebFrame* frame, const WebKit::WebURL& from, | |
| 66 const WebKit::WebURL& to, double interval, double fire_time); | |
| 67 virtual void DidCancelClientRedirect(WebKit::WebFrame* frame); | |
| 68 virtual void DidCompleteClientRedirect(WebKit::WebFrame* frame, | |
| 69 const WebKit::WebURL& from); | |
| 70 virtual void OnProcessMouseEvent(const AutomationMouseEvent& event); | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(AutomationRendererHelper); | |
| 73 }; | |
| 74 | |
| 75 #endif // CHROME_RENDERER_AUTOMATION_AUTOMATION_RENDERER_HELPER_H_ | |
| OLD | NEW |