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

Side by Side Diff: chrome_frame/external_tab.h

Issue 9838102: Remove ChromeProxy and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « chrome_frame/chrome_frame.gyp ('k') | chrome_frame/external_tab.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_FRAME_EXTERNAL_TAB_H_
6 #define CHROME_FRAME_EXTERNAL_TAB_H_
7 #pragma once
8
9 #include <windows.h>
10 #include <atlbase.h>
11 #include <atlwin.h>
12
13 #include <string>
14 #include <vector>
15
16 #include "base/memory/scoped_ptr.h"
17 #include "base/time.h"
18 #include "base/win/scoped_comptr.h"
19 #include "chrome/common/automation_constants.h"
20 #include "chrome_frame/cfproxy.h"
21 #include "chrome_frame/task_marshaller.h"
22 #include "content/public/common/page_zoom.h"
23 #include "googleurl/src/gurl.h"
24
25 struct AttachExternalTabParams;
26 struct AutomationURLRequest;
27 struct ContextMenuModel;
28 struct MiniContextMenuParams;
29 struct NavigationInfo;
30 class Task;
31
32 namespace base {
33 class WaitableEvent;
34 }
35
36 namespace gfx {
37 class Rect;
38 }
39
40 namespace net {
41 class URLRequestStatus;
42 }
43
44 // This is the delegate/callback interface that has to be implemented
45 // by the customers of ExternalTabProxy class.
46 class UIDelegate {
47 public:
48 virtual void OnNavigationStateChanged(
49 int flags, const NavigationInfo& nav_info) = 0;
50 virtual void OnUpdateTargetUrl(const std::wstring& new_target_url) = 0;
51 virtual void OnLoad(const GURL& url) = 0;
52 virtual void OnMoveWindow(const gfx::Rect& pos) = 0;
53
54 virtual void OnMessageFromChromeFrame(
55 const std::string& message, const std::string& origin,
56 const std::string& target) = 0;
57 virtual void OnHandleContextMenu(
58 const ContextMenuModel& context_menu_model, int align_flags,
59 const MiniContextMenuParams& params) = 0;
60 virtual void OnHandleAccelerator(const MSG& accel_message) = 0;
61 virtual void OnTabbedOut(bool reverse) = 0;
62 virtual void OnGoToHistoryOffset(int offset) = 0;
63 virtual void OnOpenURL(
64 const GURL& url_to_open, const GURL& referrer, int open_disposition) = 0;
65 protected:
66 ~UIDelegate() {}
67 };
68
69 struct CreateTabParams {
70 struct ProxyParams proxy_params;
71 bool is_incognito;
72 bool is_widget_mode;
73 GURL url;
74 GURL referrer;
75 };
76
77 class NavigationConstraints;
78
79 /////////////////////////////////////////////////////////////////////////
80 // ExternalTabProxy is a mediator between ChromeProxy (which runs mostly in the
81 // background IPC-channel thread) and the UI object (ActiveX, ActiveDocument).
82 // The lifetime of ExternalTabProxy is determined by the UI object.
83 //
84 // When ExternalTabProxy dies:
85 // 1. Remove itself as a ChromeProxyDelegate. This blocks until _Disconnected()
86 // is received.
87 // 2. Kills all posted tasks to the UI thread.
88 // 3. Stop all network requests
89 // => It does not have to (and should not) be a refcount-ed object.
90
91 // Non-public inheritance is not allowed by the style-guide.
92 class ExternalTabProxy : public CWindowImpl<ExternalTabProxy>,
93 public ChromeProxyDelegate {
94 public:
95 ExternalTabProxy();
96 ~ExternalTabProxy();
97
98 #ifdef UNIT_TEST
99 void set_proxy_factory(ChromeProxyFactory* factory) {
100 proxy_factory_ = factory;
101 }
102 #endif
103
104 // IPC::Channel::Listener implementation.
105 bool OnMessageReceived(const IPC::Message& message);
106
107 //
108 virtual void CreateTab(const CreateTabParams& create_params,
109 UIDelegate* delegate);
110 virtual void Navigate(const std::string& url, const std::string& referrer,
111 NavigationConstraints* navigation_constraints);
112 virtual void NavigateToIndex(int index);
113 virtual void ForwardMessageFromExternalHost(const std::string& message,
114 const std::string& origin, const std::string& target);
115 virtual void ChromeFrameHostMoved();
116
117 // Attaches an existing external tab to this automation client instance.
118 virtual void ConnectToExternalTab(uint64 external_tab_cookie);
119 virtual void BlockExternalTab(uint64 cookie);
120
121 void SetZoomLevel(content::PageZoom zoom_level);
122
123 private:
124 BEGIN_MSG_MAP(ExternalTabProxy)
125 CHAIN_MSG_MAP_MEMBER(ui_);
126 END_MSG_MAP()
127
128 //////////////////////////////////////////////////////////////////////////
129 // ChromeProxyDelegate implementation
130 virtual int tab_handle() {
131 return tab_;
132 }
133 virtual void Connected(ChromeProxy* proxy);
134 virtual void PeerLost(ChromeProxy* proxy, DisconnectReason reason);
135 virtual void Disconnected();
136
137 // Sync message responses.
138 virtual void Completed_CreateTab(bool success, HWND chrome_wnd,
139 HWND tab_window, int tab_handle, int session_id);
140 virtual void Completed_ConnectToTab(bool success, HWND chrome_window,
141 HWND tab_window, int tab_handle, int session_id);
142 virtual void Completed_Navigate(bool success,
143 enum AutomationMsg_NavigationResponseValues res);
144
145 // Network requests from Chrome.
146 virtual void OnNetwork_Start(
147 int request_id, const AutomationURLRequest& request_info);
148 virtual void OnNetwork_Read(int request_id, int bytes_to_read);
149 virtual void OnNetwork_End(int request_id, const net::URLRequestStatus& s);
150 virtual void OnNetwork_DownloadInHost(int request_id);
151 virtual void OnGetCookies(const GURL& url, int cookie_id);
152 virtual void OnSetCookie(const GURL& url, const std::string& cookie);
153
154 // Navigation progress notifications.
155 virtual void OnNavigationStateChanged(
156 int flags, const NavigationInfo& nav_info);
157 virtual void OnUpdateTargetUrl(const std::wstring& url);
158 virtual void OnNavigationFailed(int error_code, const GURL& gurl);
159 virtual void OnDidNavigate(const NavigationInfo& navigation_info);
160 virtual void OnTabLoaded(const GURL& url);
161 virtual void OnMoveWindow(const gfx::Rect& pos);
162
163 virtual void OnOpenURL(const GURL& url_to_open, const GURL& referrer,
164 int open_disposition);
165 virtual void OnGoToHistoryOffset(int offset);
166 virtual void OnMessageToHost(
167 const std::string& message, const std::string& origin,
168 const std::string& target);
169
170 // Misc. UI.
171 virtual void OnHandleAccelerator(const MSG& accel_message);
172 virtual void OnHandleContextMenu(const ContextMenuModel& context_menu_model,
173 int align_flags,
174 const MiniContextMenuParams& params);
175 virtual void OnTabbedOut(bool reverse);
176
177 // Other
178 virtual void OnTabClosed();
179 virtual void OnAttachTab(const AttachExternalTabParams& attach_params);
180
181 // end of ChromeProxyDelegate methods
182 //////////////////////////////////////////////////////////////////////////
183 void Init();
184 void Destroy();
185
186 // The UiXXXX are the ChromeProxyDelegate methods but on UI thread.
187 void UiConnected(ChromeProxy* proxy);
188 void UiPeerLost(ChromeProxy* proxy, DisconnectReason reason);
189 void UiCompleted_CreateTab(bool success, HWND chrome_window,
190 HWND tab_window, int tab_handle, int session_id);
191
192 // With the present state of affairs the only response we can possibly handle
193 // in the background IPC thread is Completed_CreateTab() where we can
194 // initiate a navigation (if there is a pending one).
195 // To simplify - will handle Completed_CreateTab in UI thread and avoid
196 // the need of lock when accessing members.
197 enum {
198 NONE,
199 INIT_IN_PROGRESS,
200 CREATE_TAB_IN_PROGRESS,
201 READY,
202 RELEASE_CF_PROXY_IN_PROGRESS
203 } state_;
204 int tab_;
205 HWND tab_wnd_;
206 HWND chrome_wnd_;
207 ChromeProxyFactory* proxy_factory_;
208 // Accessed only in the UI thread for simplicity.
209 ChromeProxy* proxy_;
210 // Accessed from ipc thread as well. It's safe if the object goes away
211 // because this should be preceded by destruction of the window and
212 // therefore all queued tasks should be destroyed.
213 UIDelegate* ui_delegate_;
214 TaskMarshallerThroughMessageQueue ui_;
215
216 scoped_ptr<base::WaitableEvent> done_;
217
218 CreateTabParams tab_params_;
219 struct PendingNavigation {
220 GURL url;
221 GURL referrer;
222 void Set(const GURL& gurl, const GURL& ref) {
223 url = gurl;
224 referrer = ref;
225 }
226 } pending_navigation_;
227 };
228
229 #endif // CHROME_FRAME_EXTERNAL_TAB_H_
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame.gyp ('k') | chrome_frame/external_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698