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