OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Called when the tab that had no pending loads now has a new pending | 41 // Called when the tab that had no pending loads now has a new pending |
42 // load. |tab_contents| will always be valid. | 42 // load. |tab_contents| will always be valid. |
43 virtual void OnFirstPendingLoad(TabContents* tab_contents) { } | 43 virtual void OnFirstPendingLoad(TabContents* tab_contents) { } |
44 | 44 |
45 // Called when the tab that had one or more pending loads now has no | 45 // Called when the tab that had one or more pending loads now has no |
46 // pending loads. |tab_contents| will always be valid. | 46 // pending loads. |tab_contents| will always be valid. |
47 // | 47 // |
48 // This method will always be called if |OnFirstPendingLoad| was called. | 48 // This method will always be called if |OnFirstPendingLoad| was called. |
49 virtual void OnNoMorePendingLoads(TabContents* tab_contents) { } | 49 virtual void OnNoMorePendingLoads(TabContents* tab_contents) { } |
50 | 50 |
| 51 // Called as a result of a tab being snapshotted. |
| 52 virtual void OnSnapshotEntirePageACK( |
| 53 bool success, |
| 54 const std::vector<unsigned char>& png_data, |
| 55 const std::string& error_msg) { } |
| 56 |
51 protected: | 57 protected: |
52 TabEventObserver(); | 58 TabEventObserver(); |
53 virtual ~TabEventObserver(); | 59 virtual ~TabEventObserver(); |
54 | 60 |
55 // On construction, this class does not observe any events. This method | 61 // On construction, this class does not observe any events. This method |
56 // sets us up to observe events from the given |AutomationTabHelper|. | 62 // sets us up to observe events from the given |AutomationTabHelper|. |
57 void StartObserving(AutomationTabHelper* tab_helper); | 63 void StartObserving(AutomationTabHelper* tab_helper); |
58 | 64 |
59 // Stop observing events from the given |AutomationTabHelper|. This does not | 65 // Stop observing events from the given |AutomationTabHelper|. This does not |
60 // need to be called before the helper dies, and it is ok if this object is | 66 // need to be called before the helper dies, and it is ok if this object is |
(...skipping 16 matching lines...) Expand all Loading... |
77 class AutomationTabHelper | 83 class AutomationTabHelper |
78 : public TabContentsObserver, | 84 : public TabContentsObserver, |
79 public base::SupportsWeakPtr<AutomationTabHelper> { | 85 public base::SupportsWeakPtr<AutomationTabHelper> { |
80 public: | 86 public: |
81 explicit AutomationTabHelper(TabContents* tab_contents); | 87 explicit AutomationTabHelper(TabContents* tab_contents); |
82 virtual ~AutomationTabHelper(); | 88 virtual ~AutomationTabHelper(); |
83 | 89 |
84 void AddObserver(TabEventObserver* observer); | 90 void AddObserver(TabEventObserver* observer); |
85 void RemoveObserver(TabEventObserver* observer); | 91 void RemoveObserver(TabEventObserver* observer); |
86 | 92 |
| 93 // Snapshots the entire page without resizing. |
| 94 void SnapshotEntirePage(); |
| 95 |
87 // Returns true if the tab is loading or the tab is scheduled to load | 96 // Returns true if the tab is loading or the tab is scheduled to load |
88 // immediately. Note that scheduled loads may be canceled. | 97 // immediately. Note that scheduled loads may be canceled. |
89 bool has_pending_loads() const; | 98 bool has_pending_loads() const; |
90 | 99 |
91 private: | 100 private: |
92 friend class AutomationTabHelperTest; | 101 friend class AutomationTabHelperTest; |
93 | 102 |
| 103 void OnSnapshotEntirePageACK( |
| 104 bool success, |
| 105 const std::vector<unsigned char>& png_data, |
| 106 const std::string& error_msg); |
| 107 |
94 // TabContentsObserver implementation. | 108 // TabContentsObserver implementation. |
95 virtual void DidStartLoading(); | 109 virtual void DidStartLoading(); |
96 virtual void DidStopLoading(); | 110 virtual void DidStopLoading(); |
97 virtual void RenderViewGone(); | 111 virtual void RenderViewGone(); |
98 virtual void TabContentsDestroyed(TabContents* tab_contents); | 112 virtual void TabContentsDestroyed(TabContents* tab_contents); |
99 virtual bool OnMessageReceived(const IPC::Message& message); | 113 virtual bool OnMessageReceived(const IPC::Message& message); |
100 | 114 |
101 void OnWillPerformClientRedirect(int64 frame_id, double delay_seconds); | 115 void OnWillPerformClientRedirect(int64 frame_id, double delay_seconds); |
102 void OnDidCompleteOrCancelClientRedirect(int64 frame_id); | 116 void OnDidCompleteOrCancelClientRedirect(int64 frame_id); |
103 void OnTabOrRenderViewDestroyed(TabContents* tab_contents); | 117 void OnTabOrRenderViewDestroyed(TabContents* tab_contents); |
104 | 118 |
105 // True if the tab is currently loading. If a navigation is scheduled but not | 119 // True if the tab is currently loading. If a navigation is scheduled but not |
106 // yet loading, this will be false. | 120 // yet loading, this will be false. |
107 bool is_loading_; | 121 bool is_loading_; |
108 | 122 |
109 // Set of all the frames (by frame ID) that are scheduled to perform a client | 123 // Set of all the frames (by frame ID) that are scheduled to perform a client |
110 // redirect. | 124 // redirect. |
111 std::set<int64> pending_client_redirects_; | 125 std::set<int64> pending_client_redirects_; |
112 | 126 |
113 // List of all the |TabEventObserver|s, which we broadcast events to. | 127 // List of all the |TabEventObserver|s, which we broadcast events to. |
114 ObserverList<TabEventObserver> observers_; | 128 ObserverList<TabEventObserver> observers_; |
115 | 129 |
116 DISALLOW_COPY_AND_ASSIGN(AutomationTabHelper); | 130 DISALLOW_COPY_AND_ASSIGN(AutomationTabHelper); |
117 }; | 131 }; |
118 | 132 |
119 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ | 133 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ |
OLD | NEW |