Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: chrome/browser/automation/automation_tab_helper.h

Issue 8294030: Fix snapshotting on linux by creating a separate automation path for (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "content/browser/tab_contents/tab_contents_observer.h" 15 #include "content/browser/tab_contents/tab_contents_observer.h"
16 16
17 class TabContents; 17 class TabContents;
18 class AutomationTabHelper; 18 class AutomationTabHelper;
19 19
20 namespace gfx {
21 class Size;
Paweł Hajdan Jr. 2011/10/18 10:21:35 nit: Is this needed?
kkania 2011/10/18 18:30:19 Done.
22 }
23
20 namespace IPC { 24 namespace IPC {
21 class Message; 25 class Message;
22 } 26 }
23 27
24 // An observer API implemented by classes which are interested in various 28 // An observer API implemented by classes which are interested in various
25 // tab events from AutomationTabHelper(s). 29 // tab events from AutomationTabHelper(s).
26 class TabEventObserver { 30 class TabEventObserver {
27 public: 31 public:
28 // |LOAD_START| and |LOAD_STOP| notifications may occur several times for a 32 // |LOAD_START| and |LOAD_STOP| notifications may occur several times for a
29 // sequence of loads that may appear as one complete navigation to a user. 33 // sequence of loads that may appear as one complete navigation to a user.
(...skipping 11 matching lines...) Expand all
41 // Called when the tab that had no pending loads now has a new pending 45 // Called when the tab that had no pending loads now has a new pending
42 // load. |tab_contents| will always be valid. 46 // load. |tab_contents| will always be valid.
43 virtual void OnFirstPendingLoad(TabContents* tab_contents) { } 47 virtual void OnFirstPendingLoad(TabContents* tab_contents) { }
44 48
45 // Called when the tab that had one or more pending loads now has no 49 // Called when the tab that had one or more pending loads now has no
46 // pending loads. |tab_contents| will always be valid. 50 // pending loads. |tab_contents| will always be valid.
47 // 51 //
48 // This method will always be called if |OnFirstPendingLoad| was called. 52 // This method will always be called if |OnFirstPendingLoad| was called.
49 virtual void OnNoMorePendingLoads(TabContents* tab_contents) { } 53 virtual void OnNoMorePendingLoads(TabContents* tab_contents) { }
50 54
55 // Called as a result of a tab being snapshotted.
56 virtual void OnSnapshotEntirePageACK(
57 bool success,
58 const std::vector<unsigned char>& png_data,
59 const std::string& error_msg) { }
60
51 protected: 61 protected:
52 TabEventObserver(); 62 TabEventObserver();
53 virtual ~TabEventObserver(); 63 virtual ~TabEventObserver();
54 64
55 // On construction, this class does not observe any events. This method 65 // On construction, this class does not observe any events. This method
56 // sets us up to observe events from the given |AutomationTabHelper|. 66 // sets us up to observe events from the given |AutomationTabHelper|.
57 void StartObserving(AutomationTabHelper* tab_helper); 67 void StartObserving(AutomationTabHelper* tab_helper);
58 68
59 // Stop observing events from the given |AutomationTabHelper|. This does not 69 // 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 70 // need to be called before the helper dies, and it is ok if this object is
(...skipping 16 matching lines...) Expand all
77 class AutomationTabHelper 87 class AutomationTabHelper
78 : public TabContentsObserver, 88 : public TabContentsObserver,
79 public base::SupportsWeakPtr<AutomationTabHelper> { 89 public base::SupportsWeakPtr<AutomationTabHelper> {
80 public: 90 public:
81 explicit AutomationTabHelper(TabContents* tab_contents); 91 explicit AutomationTabHelper(TabContents* tab_contents);
82 virtual ~AutomationTabHelper(); 92 virtual ~AutomationTabHelper();
83 93
84 void AddObserver(TabEventObserver* observer); 94 void AddObserver(TabEventObserver* observer);
85 void RemoveObserver(TabEventObserver* observer); 95 void RemoveObserver(TabEventObserver* observer);
86 96
97 // Snapshots the entire page without resizing.
98 void SnapshotEntirePage();
99
87 // Returns true if the tab is loading or the tab is scheduled to load 100 // Returns true if the tab is loading or the tab is scheduled to load
88 // immediately. Note that scheduled loads may be canceled. 101 // immediately. Note that scheduled loads may be canceled.
89 bool has_pending_loads() const; 102 bool has_pending_loads() const;
90 103
91 private: 104 private:
92 friend class AutomationTabHelperTest; 105 friend class AutomationTabHelperTest;
93 106
107 void OnSnapshotEntirePageACK(
108 bool success,
109 const std::vector<unsigned char>& png_data,
110 const std::string& error_msg);
111
94 // TabContentsObserver implementation. 112 // TabContentsObserver implementation.
95 virtual void DidStartLoading(); 113 virtual void DidStartLoading();
96 virtual void DidStopLoading(); 114 virtual void DidStopLoading();
97 virtual void RenderViewGone(); 115 virtual void RenderViewGone();
98 virtual void TabContentsDestroyed(TabContents* tab_contents); 116 virtual void TabContentsDestroyed(TabContents* tab_contents);
99 virtual bool OnMessageReceived(const IPC::Message& message); 117 virtual bool OnMessageReceived(const IPC::Message& message);
100 118
101 void OnWillPerformClientRedirect(int64 frame_id, double delay_seconds); 119 void OnWillPerformClientRedirect(int64 frame_id, double delay_seconds);
102 void OnDidCompleteOrCancelClientRedirect(int64 frame_id); 120 void OnDidCompleteOrCancelClientRedirect(int64 frame_id);
103 void OnTabOrRenderViewDestroyed(TabContents* tab_contents); 121 void OnTabOrRenderViewDestroyed(TabContents* tab_contents);
104 122
105 // True if the tab is currently loading. If a navigation is scheduled but not 123 // True if the tab is currently loading. If a navigation is scheduled but not
106 // yet loading, this will be false. 124 // yet loading, this will be false.
107 bool is_loading_; 125 bool is_loading_;
108 126
109 // Set of all the frames (by frame ID) that are scheduled to perform a client 127 // Set of all the frames (by frame ID) that are scheduled to perform a client
110 // redirect. 128 // redirect.
111 std::set<int64> pending_client_redirects_; 129 std::set<int64> pending_client_redirects_;
112 130
113 // List of all the |TabEventObserver|s, which we broadcast events to. 131 // List of all the |TabEventObserver|s, which we broadcast events to.
114 ObserverList<TabEventObserver> observers_; 132 ObserverList<TabEventObserver> observers_;
115 133
116 DISALLOW_COPY_AND_ASSIGN(AutomationTabHelper); 134 DISALLOW_COPY_AND_ASSIGN(AutomationTabHelper);
117 }; 135 };
118 136
119 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_ 137 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698