| 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 <vector> | 7 #include <vector> |
| 8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 } // switch | 87 } // switch |
| 88 | 88 |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 } // namespace | 91 } // namespace |
| 92 | 92 |
| 93 // Itf2IPCMessage | 93 // Itf2IPCMessage |
| 94 // Converts and sends trivial messages. | 94 // Converts and sends trivial messages. |
| 95 void Interface2IPCMessage::RemoveBrowsingData(int mask) { | 95 void Interface2IPCMessage::RemoveBrowsingData(int mask) { |
| 96 sender_->Send(new AutomationMsg_RemoveBrowsingData(0, mask)); | 96 sender_->Send(new AutomationMsg_RemoveBrowsingData(mask)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void Interface2IPCMessage::SetProxyConfig( | 99 void Interface2IPCMessage::SetProxyConfig( |
| 100 const std::string& json_encoded_proxy_cfg) { | 100 const std::string& json_encoded_proxy_cfg) { |
| 101 sender_->Send(new AutomationMsg_SetProxyConfig(0, json_encoded_proxy_cfg)); | 101 sender_->Send(new AutomationMsg_SetProxyConfig(json_encoded_proxy_cfg)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Tab related. | 104 // Tab related. |
| 105 void Interface2IPCMessage::Tab_PostMessage(int tab, const std::string& message, | 105 void Interface2IPCMessage::Tab_PostMessage(int tab, const std::string& message, |
| 106 const std::string& origin, const std::string& target) { | 106 const std::string& origin, const std::string& target) { |
| 107 sender_->Send(new AutomationMsg_HandleMessageFromExternalHost( | 107 sender_->Send(new AutomationMsg_HandleMessageFromExternalHost( |
| 108 0, tab, message, origin, target)); | 108 tab, message, origin, target)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void Interface2IPCMessage::Tab_Reload(int tab) { | 111 void Interface2IPCMessage::Tab_Reload(int tab) { |
| 112 sender_->Send(new AutomationMsg_ReloadAsync(0, tab)); | 112 sender_->Send(new AutomationMsg_ReloadAsync(tab)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void Interface2IPCMessage::Tab_Stop(int tab) { | 115 void Interface2IPCMessage::Tab_Stop(int tab) { |
| 116 sender_->Send(new AutomationMsg_StopAsync(0, tab)); | 116 sender_->Send(new AutomationMsg_StopAsync(tab)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Interface2IPCMessage::Tab_SaveAs(int tab) { | 119 void Interface2IPCMessage::Tab_SaveAs(int tab) { |
| 120 sender_->Send(new AutomationMsg_SaveAsAsync(0, tab)); | 120 sender_->Send(new AutomationMsg_SaveAsAsync(tab)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void Interface2IPCMessage::Tab_Print(int tab) { | 123 void Interface2IPCMessage::Tab_Print(int tab) { |
| 124 sender_->Send(new AutomationMsg_PrintAsync(0, tab)); | 124 sender_->Send(new AutomationMsg_PrintAsync(tab)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void Interface2IPCMessage::Tab_Cut(int tab) { | 127 void Interface2IPCMessage::Tab_Cut(int tab) { |
| 128 sender_->Send(new AutomationMsg_Cut(0, tab)); | 128 sender_->Send(new AutomationMsg_Cut(tab)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void Interface2IPCMessage::Tab_Copy(int tab) { | 131 void Interface2IPCMessage::Tab_Copy(int tab) { |
| 132 sender_->Send(new AutomationMsg_Copy(0, tab)); | 132 sender_->Send(new AutomationMsg_Copy(tab)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void Interface2IPCMessage::Tab_Paste(int tab) { | 135 void Interface2IPCMessage::Tab_Paste(int tab) { |
| 136 sender_->Send(new AutomationMsg_Paste(0, tab)); | 136 sender_->Send(new AutomationMsg_Paste(tab)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void Interface2IPCMessage::Tab_SelectAll(int tab) { | 139 void Interface2IPCMessage::Tab_SelectAll(int tab) { |
| 140 sender_->Send(new AutomationMsg_SelectAll(0, tab)); | 140 sender_->Send(new AutomationMsg_SelectAll(tab)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void Interface2IPCMessage::Tab_MenuCommand(int tab, int selected_command) { | 143 void Interface2IPCMessage::Tab_MenuCommand(int tab, int selected_command) { |
| 144 sender_->Send(new AutomationMsg_ForwardContextMenuCommandToChrome( | 144 sender_->Send(new AutomationMsg_ForwardContextMenuCommandToChrome( |
| 145 0, tab, selected_command)); | 145 tab, selected_command)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void Interface2IPCMessage::Tab_Zoom(int tab, PageZoom::Function zoom_level) { | 148 void Interface2IPCMessage::Tab_Zoom(int tab, PageZoom::Function zoom_level) { |
| 149 sender_->Send(new AutomationMsg_SetZoomLevel(0, tab, zoom_level)); | 149 sender_->Send(new AutomationMsg_SetZoomLevel(tab, zoom_level)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void Interface2IPCMessage::Tab_FontSize(int tab, | 152 void Interface2IPCMessage::Tab_FontSize(int tab, |
| 153 enum AutomationPageFontSize font_size) { | 153 enum AutomationPageFontSize font_size) { |
| 154 sender_->Send(new AutomationMsg_SetPageFontSize(0, tab, font_size)); | 154 sender_->Send(new AutomationMsg_SetPageFontSize(tab, font_size)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void Interface2IPCMessage::Tab_SetInitialFocus(int tab, bool reverse, | 157 void Interface2IPCMessage::Tab_SetInitialFocus(int tab, bool reverse, |
| 158 bool restore_focus_to_view) { | 158 bool restore_focus_to_view) { |
| 159 sender_->Send(new AutomationMsg_SetInitialFocus(0, tab, reverse, | 159 sender_->Send(new AutomationMsg_SetInitialFocus(tab, reverse, |
| 160 restore_focus_to_view)); | 160 restore_focus_to_view)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void Interface2IPCMessage::Tab_SetParentWindow(int tab) { | 163 void Interface2IPCMessage::Tab_SetParentWindow(int tab) { |
| 164 CHECK(0) << "Implement me"; | 164 CHECK(0) << "Implement me"; |
| 165 // AutomationMsg_TabReposition | 165 // AutomationMsg_TabReposition |
| 166 } | 166 } |
| 167 | 167 |
| 168 void Interface2IPCMessage::Tab_Resize(int tab) { | 168 void Interface2IPCMessage::Tab_Resize(int tab) { |
| 169 CHECK(0) << "Implement me"; | 169 CHECK(0) << "Implement me"; |
| 170 // AutomationMsg_TabReposition | 170 // AutomationMsg_TabReposition |
| 171 } | 171 } |
| 172 | 172 |
| 173 void Interface2IPCMessage::Tab_ProcessAccelerator(int tab, const MSG& msg) { | 173 void Interface2IPCMessage::Tab_ProcessAccelerator(int tab, const MSG& msg) { |
| 174 sender_->Send(new AutomationMsg_ProcessUnhandledAccelerator(0, tab, msg)); | 174 sender_->Send(new AutomationMsg_ProcessUnhandledAccelerator(tab, msg)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // Misc. | 177 // Misc. |
| 178 void Interface2IPCMessage::Tab_OnHostMoved(int tab) { | 178 void Interface2IPCMessage::Tab_OnHostMoved(int tab) { |
| 179 sender_->Send(new AutomationMsg_BrowserMove(0, tab)); | 179 sender_->Send(new AutomationMsg_BrowserMove(tab)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void Interface2IPCMessage::Tab_SetEnableExtensionAutomation(int tab, | 182 void Interface2IPCMessage::Tab_SetEnableExtensionAutomation(int tab, |
| 183 const std::vector<std::string>& functions_enabled) { | 183 const std::vector<std::string>& functions_enabled) { |
| 184 sender_->Send(new AutomationMsg_SetEnableExtensionAutomation(0, tab, | 184 sender_->Send(new AutomationMsg_SetEnableExtensionAutomation(tab, |
| 185 functions_enabled)); | 185 functions_enabled)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void DelegateHolder::AddDelegate(ChromeProxyDelegate* p) { | 188 void DelegateHolder::AddDelegate(ChromeProxyDelegate* p) { |
| 189 delegate_list_.insert(p); | 189 delegate_list_.insert(p); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void DelegateHolder::RemoveDelegate(ChromeProxyDelegate* p) { | 192 void DelegateHolder::RemoveDelegate(ChromeProxyDelegate* p) { |
| 193 // DCHECK(CalledOnValidThread()); | 193 // DCHECK(CalledOnValidThread()); |
| 194 int tab_handle = p->tab_handle(); // Could be 0. | 194 int tab_handle = p->tab_handle(); // Could be 0. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 command_line->AppendSwitchPath(switches::kUserDataDir, profile_path); | 336 command_line->AppendSwitchPath(switches::kUserDataDir, profile_path); |
| 337 | 337 |
| 338 std::wstring command_line_string(command_line->command_line_string()); | 338 std::wstring command_line_string(command_line->command_line_string()); |
| 339 if (!extra_args.empty()) { | 339 if (!extra_args.empty()) { |
| 340 command_line_string.append(L" "); | 340 command_line_string.append(L" "); |
| 341 command_line_string.append(extra_args); | 341 command_line_string.append(extra_args); |
| 342 } | 342 } |
| 343 return command_line_string; | 343 return command_line_string; |
| 344 } | 344 } |
| 345 | |
| 346 int IsTabMessage(const IPC::Message& message) { | |
| 347 switch (message.type()) { | |
| 348 case AutomationMsg_NavigationStateChanged::ID: | |
| 349 case AutomationMsg_UpdateTargetUrl::ID: | |
| 350 case AutomationMsg_HandleAccelerator::ID: | |
| 351 case AutomationMsg_TabbedOut::ID: | |
| 352 case AutomationMsg_OpenURL::ID: | |
| 353 case AutomationMsg_NavigationFailed::ID: | |
| 354 case AutomationMsg_DidNavigate::ID: | |
| 355 case AutomationMsg_TabLoaded::ID: | |
| 356 case AutomationMsg_ForwardMessageToExternalHost::ID: | |
| 357 case AutomationMsg_ForwardContextMenuToExternalHost::ID: | |
| 358 case AutomationMsg_RequestStart::ID: | |
| 359 case AutomationMsg_RequestRead::ID: | |
| 360 case AutomationMsg_RequestEnd::ID: | |
| 361 case AutomationMsg_DownloadRequestInHost::ID: | |
| 362 case AutomationMsg_SetCookieAsync::ID: | |
| 363 case AutomationMsg_AttachExternalTab::ID: | |
| 364 case AutomationMsg_RequestGoToHistoryEntryOffset::ID: | |
| 365 case AutomationMsg_GetCookiesFromHost::ID: | |
| 366 case AutomationMsg_CloseExternalTab::ID: { | |
| 367 // Read tab handle from the message. | |
| 368 void* iter = NULL; | |
| 369 int tab_handle = 0; | |
| 370 message.ReadInt(&iter, &tab_handle); | |
| 371 return tab_handle; | |
| 372 } | |
| 373 } | |
| 374 | |
| 375 return 0; | |
| 376 } | |
| 377 | |
| 378 bool DispatchTabMessageToDelegate(ChromeProxyDelegate* delegate, | |
| 379 const IPC::Message& m) { | |
| 380 // The first argument of the message is always the tab handle. | |
| 381 void* iter = 0; | |
| 382 switch (m.type()) { | |
| 383 case AutomationMsg_NavigationStateChanged::ID: { | |
| 384 // Tuple3<int, int, IPC::NavigationInfo> | |
| 385 AutomationMsg_NavigationStateChanged::Param params; | |
| 386 if (ReadParam(&m, &iter, ¶ms)) | |
| 387 delegate->NavigationStateChanged(params.b, params.c); | |
| 388 return true; | |
| 389 } | |
| 390 | |
| 391 case AutomationMsg_UpdateTargetUrl::ID: { | |
| 392 // Tuple2<int, std::wstring> | |
| 393 AutomationMsg_UpdateTargetUrl::Param params; | |
| 394 if (ReadParam(&m, &iter, ¶ms)) | |
| 395 delegate->UpdateTargetUrl(params.b); | |
| 396 return true; | |
| 397 } | |
| 398 | |
| 399 case AutomationMsg_HandleAccelerator::ID: { | |
| 400 // Tuple2<int, MSG> | |
| 401 AutomationMsg_HandleAccelerator::Param params; | |
| 402 if (ReadParam(&m, &iter, ¶ms)) | |
| 403 delegate->HandleAccelerator(params.b); | |
| 404 return true; | |
| 405 } | |
| 406 | |
| 407 case AutomationMsg_TabbedOut::ID: { | |
| 408 // Tuple2<int, bool> | |
| 409 AutomationMsg_TabbedOut::Param params; | |
| 410 if (ReadParam(&m, &iter, ¶ms)) | |
| 411 delegate->TabbedOut(params.b); | |
| 412 return true; | |
| 413 } | |
| 414 | |
| 415 case AutomationMsg_OpenURL::ID: { | |
| 416 // Tuple4<int, GURL, GURL, int> | |
| 417 AutomationMsg_OpenURL::Param params; | |
| 418 if (ReadParam(&m, &iter, ¶ms)) | |
| 419 delegate->OpenURL(params.b, params.c, params.d); | |
| 420 return true; | |
| 421 } | |
| 422 | |
| 423 case AutomationMsg_NavigationFailed::ID: { | |
| 424 // Tuple3<int, int, GURL> | |
| 425 AutomationMsg_NavigationFailed::Param params; | |
| 426 if (ReadParam(&m, &iter, ¶ms)) | |
| 427 delegate->NavigationFailed(params.b, params.c); | |
| 428 return true; | |
| 429 } | |
| 430 | |
| 431 case AutomationMsg_DidNavigate::ID: { | |
| 432 // Tuple2<int, IPC::NavigationInfo> | |
| 433 AutomationMsg_DidNavigate::Param params; | |
| 434 if (ReadParam(&m, &iter, ¶ms)) | |
| 435 delegate->DidNavigate(params.b); | |
| 436 return true; | |
| 437 } | |
| 438 | |
| 439 case AutomationMsg_TabLoaded::ID: { | |
| 440 // Tuple2<int, GURL> | |
| 441 AutomationMsg_TabLoaded::Param params; | |
| 442 if (ReadParam(&m, &iter, ¶ms)) | |
| 443 delegate->TabLoaded(params.b); | |
| 444 return true; | |
| 445 } | |
| 446 | |
| 447 case AutomationMsg_ForwardMessageToExternalHost::ID: { | |
| 448 // Tuple4<int, string, string, string> | |
| 449 AutomationMsg_ForwardMessageToExternalHost::Param params; | |
| 450 if (ReadParam(&m, &iter, ¶ms)) | |
| 451 delegate->MessageToHost(params.b, params.c, params.d); | |
| 452 return true; | |
| 453 } | |
| 454 | |
| 455 case AutomationMsg_ForwardContextMenuToExternalHost::ID: { | |
| 456 // Tuple4<int, HANDLE, int, IPC::ContextMenuParams> | |
| 457 AutomationMsg_ForwardContextMenuToExternalHost::Param params; | |
| 458 if (ReadParam(&m, &iter, ¶ms)) | |
| 459 delegate->HandleContextMenu(params.b, params.c, params.d); | |
| 460 return true; | |
| 461 } | |
| 462 | |
| 463 case AutomationMsg_RequestStart::ID: { | |
| 464 // Tuple3<int, int, IPC::AutomationURLRequest> | |
| 465 AutomationMsg_RequestStart::Param params; | |
| 466 if (ReadParam(&m, &iter, ¶ms)) | |
| 467 delegate->Network_Start(params.b, params.c); | |
| 468 return true; | |
| 469 } | |
| 470 | |
| 471 case AutomationMsg_RequestRead::ID: { | |
| 472 // Tuple3<int, int, int> | |
| 473 AutomationMsg_RequestRead::Param params; | |
| 474 if (ReadParam(&m, &iter, ¶ms)) | |
| 475 delegate->Network_Read(params.b, params.c); | |
| 476 return true; | |
| 477 } | |
| 478 | |
| 479 case AutomationMsg_RequestEnd::ID: { | |
| 480 // Tuple3<int, int, URLRequestStatus> | |
| 481 AutomationMsg_RequestEnd::Param params; | |
| 482 if (ReadParam(&m, &iter, ¶ms)) | |
| 483 delegate->Network_End(params.b, params.c); | |
| 484 return true; | |
| 485 } | |
| 486 | |
| 487 case AutomationMsg_DownloadRequestInHost::ID: { | |
| 488 // Tuple2<int, int> | |
| 489 AutomationMsg_DownloadRequestInHost::Param params; | |
| 490 if (ReadParam(&m, &iter, ¶ms)) | |
| 491 delegate->Network_DownloadInHost(params.b); | |
| 492 return true; | |
| 493 } | |
| 494 | |
| 495 case AutomationMsg_SetCookieAsync::ID: { | |
| 496 // Tuple3<int, GURL, string> | |
| 497 AutomationMsg_SetCookieAsync::Param params; | |
| 498 if (ReadParam(&m, &iter, ¶ms)) | |
| 499 delegate->SetCookie(params.b, params.c); | |
| 500 return true; | |
| 501 } | |
| 502 | |
| 503 case AutomationMsg_AttachExternalTab::ID: { | |
| 504 // Tuple2<int, IPC::AttachExternalTabParams> | |
| 505 AutomationMsg_AttachExternalTab::Param params; | |
| 506 if (ReadParam(&m, &iter, ¶ms)) | |
| 507 delegate->AttachTab(params.b); | |
| 508 return true; | |
| 509 } | |
| 510 | |
| 511 case AutomationMsg_RequestGoToHistoryEntryOffset::ID: { | |
| 512 // Tuple2<int, int> | |
| 513 AutomationMsg_RequestGoToHistoryEntryOffset::Param params; | |
| 514 if (ReadParam(&m, &iter, ¶ms)) | |
| 515 delegate->GoToHistoryOffset(params.b); | |
| 516 return true; | |
| 517 } | |
| 518 | |
| 519 case AutomationMsg_GetCookiesFromHost::ID: { | |
| 520 // Tuple3<int, GURL, int> | |
| 521 AutomationMsg_GetCookiesFromHost::Param params; | |
| 522 if (ReadParam(&m, &iter, ¶ms)) | |
| 523 delegate->GetCookies(params.b, params.c); | |
| 524 return true; | |
| 525 } | |
| 526 | |
| 527 case AutomationMsg_CloseExternalTab::ID: { | |
| 528 // Tuple1<int> | |
| 529 delegate->TabClosed(); | |
| 530 return true; | |
| 531 } | |
| 532 } | |
| 533 | |
| 534 return false; | |
| 535 } | |
| OLD | NEW |