| 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/chrome_frame_automation.h" | 5 #include "chrome_frame/chrome_frame_automation.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 virtual bool OnMessageReceived(const IPC::Message& message) { | 66 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 67 if (message.is_reply()) | 67 if (message.is_reply()) |
| 68 return false; | 68 return false; |
| 69 | 69 |
| 70 if (!ChromeFrameDelegateImpl::IsTabMessage(message)) | 70 if (!ChromeFrameDelegateImpl::IsTabMessage(message)) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 // Get AddRef-ed pointer to corresponding TabProxy object | 73 // Get AddRef-ed pointer to corresponding TabProxy object |
| 74 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource( | 74 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource( |
| 75 message.routing_id())); | 75 message.routing_id())); |
| 76 bool handled = false; |
| 76 if (tab) { | 77 if (tab) { |
| 77 tab->OnMessageReceived(message); | 78 tab->OnMessageReceived(message); |
| 78 tab->Release(); | 79 handled = tab->Release(); |
| 79 } else { | 80 } else { |
| 80 DLOG(ERROR) << "Failed to find TabProxy for tab:" << message.routing_id(); | 81 DLOG(ERROR) << "Failed to find TabProxy for tab:" << message.routing_id(); |
| 81 } | 82 } |
| 82 return true; | 83 return handled; |
| 83 } | 84 } |
| 84 | 85 |
| 85 virtual void OnChannelError() { | 86 virtual void OnChannelError() { |
| 86 std::list<AutomationHandle>::const_iterator iter = tabs_list_.begin(); | 87 std::list<AutomationHandle>::const_iterator iter = tabs_list_.begin(); |
| 87 for (; iter != tabs_list_.end(); ++iter) { | 88 for (; iter != tabs_list_.end(); ++iter) { |
| 88 // Get AddRef-ed pointer to corresponding TabProxy object | 89 // Get AddRef-ed pointer to corresponding TabProxy object |
| 89 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(*iter)); | 90 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(*iter)); |
| 90 if (tab) { | 91 if (tab) { |
| 91 tab->OnChannelError(); | 92 tab->OnChannelError(); |
| 92 tab->Release(); | 93 tab->Release(); |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 PostTask(FROM_HERE, NewRunnableMethod(this, | 1162 PostTask(FROM_HERE, NewRunnableMethod(this, |
| 1162 &ChromeFrameAutomationClient::ProcessUrlRequestMessage, tab, msg, true)); | 1163 &ChromeFrameAutomationClient::ProcessUrlRequestMessage, tab, msg, true)); |
| 1163 return true; | 1164 return true; |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 // These are invoked in channel's background thread. | 1167 // These are invoked in channel's background thread. |
| 1167 // Cannot call any method of the activex/npapi here since they are STA | 1168 // Cannot call any method of the activex/npapi here since they are STA |
| 1168 // kind of beings. | 1169 // kind of beings. |
| 1169 // By default we marshal the IPC message to the main/GUI thread and from there | 1170 // By default we marshal the IPC message to the main/GUI thread and from there |
| 1170 // we safely invoke chrome_frame_delegate_->OnMessageReceived(msg). | 1171 // we safely invoke chrome_frame_delegate_->OnMessageReceived(msg). |
| 1171 void ChromeFrameAutomationClient::OnMessageReceived(TabProxy* tab, | 1172 bool ChromeFrameAutomationClient::OnMessageReceived(TabProxy* tab, |
| 1172 const IPC::Message& msg) { | 1173 const IPC::Message& msg) { |
| 1173 DCHECK(tab == tab_.get()); | 1174 DCHECK(tab == tab_.get()); |
| 1174 // Quickly process network related messages. | 1175 // Quickly process network related messages. |
| 1175 if (url_fetcher_ && ProcessUrlRequestMessage(tab, msg, false)) | 1176 if (url_fetcher_ && ProcessUrlRequestMessage(tab, msg, false)) |
| 1176 return; | 1177 return true; |
| 1177 | 1178 |
| 1178 // Early check to avoid needless marshaling | 1179 // Early check to avoid needless marshaling |
| 1179 if (chrome_frame_delegate_ == NULL) | 1180 if (chrome_frame_delegate_ == NULL) |
| 1180 return; | 1181 return false; |
| 1181 | 1182 |
| 1182 PostTask(FROM_HERE, NewRunnableMethod(this, | 1183 PostTask(FROM_HERE, NewRunnableMethod(this, |
| 1183 &ChromeFrameAutomationClient::OnMessageReceivedUIThread, msg)); | 1184 &ChromeFrameAutomationClient::OnMessageReceivedUIThread, msg)); |
| 1185 return true; |
| 1184 } | 1186 } |
| 1185 | 1187 |
| 1186 void ChromeFrameAutomationClient::OnChannelError(TabProxy* tab) { | 1188 void ChromeFrameAutomationClient::OnChannelError(TabProxy* tab) { |
| 1187 DCHECK(tab == tab_.get()); | 1189 DCHECK(tab == tab_.get()); |
| 1188 // Early check to avoid needless marshaling | 1190 // Early check to avoid needless marshaling |
| 1189 if (chrome_frame_delegate_ == NULL) | 1191 if (chrome_frame_delegate_ == NULL) |
| 1190 return; | 1192 return; |
| 1191 | 1193 |
| 1192 PostTask(FROM_HERE, NewRunnableMethod(this, | 1194 PostTask(FROM_HERE, NewRunnableMethod(this, |
| 1193 &ChromeFrameAutomationClient::OnChannelErrorUIThread)); | 1195 &ChromeFrameAutomationClient::OnChannelErrorUIThread)); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 const URLRequestStatus& status) { | 1457 const URLRequestStatus& status) { |
| 1456 automation_server_->Send(new AutomationMsg_RequestEnd( | 1458 automation_server_->Send(new AutomationMsg_RequestEnd( |
| 1457 tab_->handle(), request_id, status)); | 1459 tab_->handle(), request_id, status)); |
| 1458 } | 1460 } |
| 1459 | 1461 |
| 1460 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, | 1462 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, |
| 1461 const GURL& url, const std::string& cookie_string, int cookie_id) { | 1463 const GURL& url, const std::string& cookie_string, int cookie_id) { |
| 1462 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse( | 1464 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse( |
| 1463 tab_->handle(), success, url, cookie_string, cookie_id)); | 1465 tab_->handle(), success, url, cookie_string, cookie_id)); |
| 1464 } | 1466 } |
| OLD | NEW |