OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome_frame/cfproxy_private.h" | 5 #include "chrome_frame/cfproxy_private.h" |
6 | 6 |
7 #include "base/tuple.h" | 7 #include "base/tuple.h" |
8 #include "ipc/ipc_sync_message.h" | 8 #include "ipc/ipc_sync_message.h" |
9 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } else { | 121 } else { |
122 delete m; | 122 delete m; |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 ////////////////////////////////////////////////////////////////////////// | 126 ////////////////////////////////////////////////////////////////////////// |
127 // Sync messages. | 127 // Sync messages. |
128 void CFProxy::InstallExtension(ChromeProxyDelegate* delegate, | 128 void CFProxy::InstallExtension(ChromeProxyDelegate* delegate, |
129 const FilePath& crx_path, | 129 const FilePath& crx_path, |
130 SyncMessageContext* ctx) { | 130 SyncMessageContext* ctx) { |
131 IPC::SyncMessage* m = new AutomationMsg_InstallExtension(0, crx_path, NULL); | 131 IPC::SyncMessage* m = new AutomationMsg_InstallExtension(crx_path, NULL); |
132 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); | 132 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); |
133 SendIpcMessage(m); | 133 SendIpcMessage(m); |
134 } | 134 } |
135 | 135 |
136 void CFProxy::LoadExtension(ChromeProxyDelegate* delegate, | 136 void CFProxy::LoadExtension(ChromeProxyDelegate* delegate, |
137 const FilePath& path, SyncMessageContext* ctx) { | 137 const FilePath& path, SyncMessageContext* ctx) { |
138 IPC::SyncMessage* m = new AutomationMsg_LoadExpandedExtension(0, path, 0); | 138 IPC::SyncMessage* m = new AutomationMsg_LoadExpandedExtension(path, 0); |
139 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); | 139 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); |
140 SendIpcMessage(m); | 140 SendIpcMessage(m); |
141 } | 141 } |
142 | 142 |
143 void CFProxy::GetEnabledExtensions(ChromeProxyDelegate* delegate, | 143 void CFProxy::GetEnabledExtensions(ChromeProxyDelegate* delegate, |
144 SyncMessageContext* ctx) { | 144 SyncMessageContext* ctx) { |
145 IPC::SyncMessage* m = new AutomationMsg_GetEnabledExtensions(0, NULL); | 145 IPC::SyncMessage* m = new AutomationMsg_GetEnabledExtensions(NULL); |
146 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); | 146 sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); |
147 SendIpcMessage(m); | 147 SendIpcMessage(m); |
148 } | 148 } |
149 | 149 |
150 void CFProxy::Tab_Find(int tab, const string16& search_string, | 150 void CFProxy::Tab_Find(int tab, const string16& search_string, |
151 FindInPageDirection forward, FindInPageCase match_case, | 151 FindInPageDirection forward, FindInPageCase match_case, |
152 bool find_next) { | 152 bool find_next) { |
153 AutomationMsg_Find_Params params; | 153 AutomationMsg_Find_Params params; |
154 params.unused = 0; | 154 params.unused = 0; |
155 params.search_string = search_string; | 155 params.search_string = search_string; |
156 params.find_next = find_next; | 156 params.find_next = find_next; |
157 params.match_case = (match_case == CASE_SENSITIVE); | 157 params.match_case = (match_case == CASE_SENSITIVE); |
158 params.forward = (forward == FWD); | 158 params.forward = (forward == FWD); |
159 IPC::SyncMessage* m = new AutomationMsg_Find(0, tab, params, NULL, NULL); | 159 IPC::SyncMessage* m = new AutomationMsg_Find(tab, params, NULL, NULL); |
160 // Not interested in result. | 160 // Not interested in result. |
161 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); | 161 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); |
162 SendIpcMessage(m); | 162 SendIpcMessage(m); |
163 } | 163 } |
164 | 164 |
165 void CFProxy::Tab_OverrideEncoding(int tab, const char* encoding) { | 165 void CFProxy::Tab_OverrideEncoding(int tab, const char* encoding) { |
166 IPC::SyncMessage* m = new AutomationMsg_OverrideEncoding(0, tab, encoding, | 166 IPC::SyncMessage* m = new AutomationMsg_OverrideEncoding(tab, encoding, NULL); |
167 NULL); | |
168 // Not interested in result. | 167 // Not interested in result. |
169 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); | 168 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); |
170 SendIpcMessage(m); | 169 SendIpcMessage(m); |
171 } | 170 } |
172 | 171 |
173 void CFProxy::Tab_Navigate(int tab, const GURL& url, const GURL& referrer) { | 172 void CFProxy::Tab_Navigate(int tab, const GURL& url, const GURL& referrer) { |
174 IPC::SyncMessage* m = new AutomationMsg_NavigateInExternalTab(0, | 173 IPC::SyncMessage* m = new AutomationMsg_NavigateInExternalTab( |
175 tab, url, referrer, NULL); | 174 tab, url, referrer, NULL); |
176 // We probably are not interested in result since provider just checks | 175 // We probably are not interested in result since provider just checks |
177 // whether tab handle is valid. | 176 // whether tab handle is valid. |
178 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); | 177 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); |
179 SendIpcMessage(m); | 178 SendIpcMessage(m); |
180 } | 179 } |
181 | 180 |
182 void CFProxy::CreateTab(ChromeProxyDelegate* delegate, | 181 void CFProxy::CreateTab(ChromeProxyDelegate* delegate, |
183 const IPC::ExternalTabSettings& p) { | 182 const ExternalTabSettings& p) { |
184 IPC::SyncMessage* m = new AutomationMsg_CreateExternalTab(0, p, 0, 0, 0, 0); | 183 IPC::SyncMessage* m = new AutomationMsg_CreateExternalTab(p, 0, 0, 0, 0); |
185 sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); | 184 sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); |
186 SendIpcMessage(m); | 185 SendIpcMessage(m); |
187 } | 186 } |
188 | 187 |
189 void CFProxy::ConnectTab(ChromeProxyDelegate* delegate, HWND hwnd, | 188 void CFProxy::ConnectTab(ChromeProxyDelegate* delegate, HWND hwnd, |
190 uint64 cookie) { | 189 uint64 cookie) { |
191 IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(0, cookie, true, | 190 IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(cookie, true, |
192 hwnd, NULL, NULL, NULL, 0); | 191 hwnd, NULL, NULL, NULL, 0); |
193 sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); | 192 sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); |
194 SendIpcMessage(m); | 193 SendIpcMessage(m); |
195 } | 194 } |
196 | 195 |
197 void CFProxy::BlockTab(uint64 cookie) { | 196 void CFProxy::BlockTab(uint64 cookie) { |
198 IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(0, cookie, false, | 197 IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(cookie, false, |
199 NULL, NULL, NULL, NULL, 0); | 198 NULL, NULL, NULL, NULL, 0); |
200 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); | 199 sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); |
201 SendIpcMessage(m); | 200 SendIpcMessage(m); |
202 } | 201 } |
203 | 202 |
204 void CFProxy::Tab_RunUnloadHandlers(int tab) { | 203 void CFProxy::Tab_RunUnloadHandlers(int tab) { |
205 IPC::SyncMessage* m = new AutomationMsg_RunUnloadHandlers(0, tab, 0); | 204 IPC::SyncMessage* m = new AutomationMsg_RunUnloadHandlers(tab, 0); |
206 ChromeProxyDelegate* p = Tab2Delegate(tab); | 205 ChromeProxyDelegate* p = Tab2Delegate(tab); |
207 sync_dispatcher_.QueueSyncMessage(m, p, NULL); | 206 sync_dispatcher_.QueueSyncMessage(m, p, NULL); |
208 SendIpcMessage(m); | 207 SendIpcMessage(m); |
209 } | 208 } |
210 | 209 |
211 // IPC::Channel::Listener | 210 // IPC::Channel::Listener |
212 void CFProxy::OnMessageReceived(const IPC::Message& message) { | 211 void CFProxy::OnMessageReceived(const IPC::Message& message) { |
213 // Handle sync message reply. | 212 // Handle sync message reply. |
214 bool done = sync_dispatcher_.OnReplyReceived(&message); | 213 bool done = sync_dispatcher_.OnReplyReceived(&message); |
215 if (done) | 214 if (done) |
216 return; | 215 return; |
217 | 216 |
218 // Handle tab related message. | 217 // Handle tab related message. |
219 int tab_handle = IsTabMessage(message); | 218 ChromeProxyDelegate* d = Tab2Delegate(message.routing_id()); |
220 if (tab_handle != 0) { | 219 if (d) |
221 ChromeProxyDelegate* d = Tab2Delegate(tab_handle); | 220 return d->OnMessageReceived(message); |
222 if (d) | |
223 DispatchTabMessageToDelegate(d, message); | |
224 return; | |
225 } | |
226 | 221 |
227 DLOG(WARNING) << "Unknown message received!"; | 222 DLOG(WARNING) << "Unknown message received!"; |
228 } | 223 } |
229 | 224 |
230 void CFProxy::OnChannelConnected(int32 peer_pid) { | 225 void CFProxy::OnChannelConnected(int32 peer_pid) { |
231 is_connected_ = true; | 226 is_connected_ = true; |
232 // TODO(stoyan): May be we should wait for Hello message. | 227 // TODO(stoyan): May be we should wait for Hello message. |
233 for (DelegateList::iterator it = delegate_list_.begin(); | 228 for (DelegateList::iterator it = delegate_list_.begin(); |
234 it != delegate_list_.end(); ++it) { | 229 it != delegate_list_.end(); ++it) { |
235 (*it)->Connected(this); | 230 (*it)->Connected(this); |
236 } | 231 } |
237 } | 232 } |
238 | 233 |
239 void CFProxy::OnChannelError() { | 234 void CFProxy::OnChannelError() { |
240 is_connected_ = false; | 235 is_connected_ = false; |
241 | 236 |
242 // Inform the sync message callbacks that there are not going to see | 237 // Inform the sync message callbacks that there are not going to see |
243 // any reply. | 238 // any reply. |
244 sync_dispatcher_.OnChannelClosed(); | 239 sync_dispatcher_.OnChannelClosed(); |
245 OnPeerLost(ChromeProxyDelegate::CHANNEL_ERROR); | 240 OnPeerLost(ChromeProxyDelegate::CHANNEL_ERROR); |
246 | 241 |
247 // TODO(stoyan): Relaunch? | 242 // TODO(stoyan): Relaunch? |
248 } | 243 } |
OLD | NEW |