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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 void RemoveTabProxy(AutomationHandle tab_proxy) { | 61 void RemoveTabProxy(AutomationHandle tab_proxy) { |
62 AutoLock lock(lock_); | 62 AutoLock lock(lock_); |
63 tabs_list_.remove(tab_proxy); | 63 tabs_list_.remove(tab_proxy); |
64 } | 64 } |
65 | 65 |
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 int tab_handle = 0; | 70 if (!ChromeFrameDelegateImpl::IsTabMessage(message)) |
71 if (!ChromeFrameDelegateImpl::IsTabMessage(message, &tab_handle)) | |
72 return false; | 71 return false; |
73 | 72 |
74 // Get AddRef-ed pointer to corresponding TabProxy object | 73 // Get AddRef-ed pointer to corresponding TabProxy object |
75 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(tab_handle)); | 74 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource( |
| 75 message.routing_id())); |
76 if (tab) { | 76 if (tab) { |
77 tab->OnMessageReceived(message); | 77 tab->OnMessageReceived(message); |
78 tab->Release(); | 78 tab->Release(); |
79 } else { | 79 } else { |
80 DLOG(ERROR) << "Failed to find TabProxy for tab:" << tab_handle; | 80 DLOG(ERROR) << "Failed to find TabProxy for tab:" << message.routing_id(); |
81 } | 81 } |
82 return true; | 82 return true; |
83 } | 83 } |
84 | 84 |
85 virtual void OnChannelError() { | 85 virtual void OnChannelError() { |
86 std::list<AutomationHandle>::const_iterator iter = tabs_list_.begin(); | 86 std::list<AutomationHandle>::const_iterator iter = tabs_list_.begin(); |
87 for (; iter != tabs_list_.end(); ++iter) { | 87 for (; iter != tabs_list_.end(); ++iter) { |
88 // Get AddRef-ed pointer to corresponding TabProxy object | 88 // Get AddRef-ed pointer to corresponding TabProxy object |
89 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(*iter)); | 89 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(*iter)); |
90 if (tab) { | 90 if (tab) { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 return; | 435 return; |
436 } | 436 } |
437 | 437 |
438 if (!proxy_.get()) { | 438 if (!proxy_.get()) { |
439 DLOG(WARNING) << __FUNCTION__ << " NULL proxy, can't send UMA data"; | 439 DLOG(WARNING) << __FUNCTION__ << " NULL proxy, can't send UMA data"; |
440 } else { | 440 } else { |
441 ChromeFrameHistogramSnapshots::HistogramPickledList histograms = | 441 ChromeFrameHistogramSnapshots::HistogramPickledList histograms = |
442 snapshots_->GatherAllHistograms(); | 442 snapshots_->GatherAllHistograms(); |
443 | 443 |
444 if (!histograms.empty()) { | 444 if (!histograms.empty()) { |
445 proxy_->Send(new AutomationMsg_RecordHistograms(0, histograms)); | 445 proxy_->Send(new AutomationMsg_RecordHistograms(histograms)); |
446 } | 446 } |
447 | 447 |
448 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 448 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
449 NewRunnableMethod(this, &AutomationProxyCacheEntry::SendUMAData), | 449 NewRunnableMethod(this, &AutomationProxyCacheEntry::SendUMAData), |
450 uma_send_interval_); | 450 uma_send_interval_); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 | 454 |
455 DISABLE_RUNNABLE_METHOD_REFCOUNT(ProxyFactory); | 455 DISABLE_RUNNABLE_METHOD_REFCOUNT(ProxyFactory); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 bool ChromeFrameAutomationClient::NavigateToIndex(int index) { | 751 bool ChromeFrameAutomationClient::NavigateToIndex(int index) { |
752 // Could be NULL if we failed to launch Chrome in LaunchAutomationServer() | 752 // Could be NULL if we failed to launch Chrome in LaunchAutomationServer() |
753 if (!automation_server_ || !tab_.get() || !tab_->is_valid()) { | 753 if (!automation_server_ || !tab_.get() || !tab_->is_valid()) { |
754 return false; | 754 return false; |
755 } | 755 } |
756 | 756 |
757 DCHECK(::IsWindow(chrome_window_)); | 757 DCHECK(::IsWindow(chrome_window_)); |
758 | 758 |
759 IPC::SyncMessage* msg = new AutomationMsg_NavigateExternalTabAtIndex( | 759 IPC::SyncMessage* msg = new AutomationMsg_NavigateExternalTabAtIndex( |
760 0, tab_->handle(), index, NULL); | 760 tab_->handle(), index, NULL); |
761 automation_server_->SendAsAsync(msg, new BeginNavigateContext(this), | 761 automation_server_->SendAsAsync(msg, new BeginNavigateContext(this), |
762 this); | 762 this); |
763 return true; | 763 return true; |
764 } | 764 } |
765 | 765 |
766 bool ChromeFrameAutomationClient::ForwardMessageFromExternalHost( | 766 bool ChromeFrameAutomationClient::ForwardMessageFromExternalHost( |
767 const std::string& message, const std::string& origin, | 767 const std::string& message, const std::string& origin, |
768 const std::string& target) { | 768 const std::string& target) { |
769 // Could be NULL if we failed to launch Chrome in LaunchAutomationServer() | 769 // Could be NULL if we failed to launch Chrome in LaunchAutomationServer() |
770 if (!is_initialized()) | 770 if (!is_initialized()) |
(...skipping 21 matching lines...) Expand all Loading... |
792 } | 792 } |
793 | 793 |
794 DCHECK(::IsWindow(chrome_window_)); | 794 DCHECK(::IsWindow(chrome_window_)); |
795 | 795 |
796 if (!tab_->is_valid()) { | 796 if (!tab_->is_valid()) { |
797 DLOG(WARNING) << "BeginNavigate - tab isn't valid."; | 797 DLOG(WARNING) << "BeginNavigate - tab isn't valid."; |
798 return; | 798 return; |
799 } | 799 } |
800 | 800 |
801 IPC::SyncMessage* msg = | 801 IPC::SyncMessage* msg = |
802 new AutomationMsg_NavigateInExternalTab(0, tab_->handle(), | 802 new AutomationMsg_NavigateInExternalTab(tab_->handle(), |
803 chrome_launch_params_->url(), chrome_launch_params_->referrer(), | 803 chrome_launch_params_->url(), chrome_launch_params_->referrer(), |
804 NULL); | 804 NULL); |
805 automation_server_->SendAsAsync(msg, new BeginNavigateContext(this), this); | 805 automation_server_->SendAsAsync(msg, new BeginNavigateContext(this), this); |
806 | 806 |
807 RECT client_rect = {0}; | 807 RECT client_rect = {0}; |
808 chrome_frame_delegate_->GetBounds(&client_rect); | 808 chrome_frame_delegate_->GetBounds(&client_rect); |
809 Resize(client_rect.right - client_rect.left, | 809 Resize(client_rect.right - client_rect.left, |
810 client_rect.bottom - client_rect.top, | 810 client_rect.bottom - client_rect.top, |
811 SWP_NOACTIVATE | SWP_NOZORDER); | 811 SWP_NOACTIVATE | SWP_NOZORDER); |
812 } | 812 } |
(...skipping 15 matching lines...) Expand all Loading... |
828 // the SyncMessageReplyDispatcher to avoid concerns about blocking | 828 // the SyncMessageReplyDispatcher to avoid concerns about blocking |
829 // synchronous messages. | 829 // synchronous messages. |
830 AutomationMsg_Find_Params params; | 830 AutomationMsg_Find_Params params; |
831 params.unused = 0; | 831 params.unused = 0; |
832 params.search_string = WideToUTF16Hack(search_string); | 832 params.search_string = WideToUTF16Hack(search_string); |
833 params.find_next = find_next; | 833 params.find_next = find_next; |
834 params.match_case = (match_case == CASE_SENSITIVE); | 834 params.match_case = (match_case == CASE_SENSITIVE); |
835 params.forward = (forward == FWD); | 835 params.forward = (forward == FWD); |
836 | 836 |
837 IPC::SyncMessage* msg = | 837 IPC::SyncMessage* msg = |
838 new AutomationMsg_Find(0, tab_->handle(), params, NULL, NULL); | 838 new AutomationMsg_Find(tab_->handle(), params, NULL, NULL); |
839 automation_server_->SendAsAsync(msg, NULL, this); | 839 automation_server_->SendAsAsync(msg, NULL, this); |
840 } | 840 } |
841 | 841 |
842 void ChromeFrameAutomationClient::InstallExtension( | 842 void ChromeFrameAutomationClient::InstallExtension( |
843 const FilePath& crx_path, | 843 const FilePath& crx_path, |
844 void* user_data) { | 844 void* user_data) { |
845 if (automation_server_ == NULL) { | 845 if (automation_server_ == NULL) { |
846 InstallExtensionComplete(crx_path, | 846 InstallExtensionComplete(crx_path, |
847 user_data, | 847 user_data, |
848 AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 848 AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
849 return; | 849 return; |
850 } | 850 } |
851 | 851 |
852 InstallExtensionContext* ctx = new InstallExtensionContext( | 852 InstallExtensionContext* ctx = new InstallExtensionContext( |
853 this, crx_path, user_data); | 853 this, crx_path, user_data); |
854 | 854 |
855 IPC::SyncMessage* msg = | 855 IPC::SyncMessage* msg = new AutomationMsg_InstallExtension(crx_path, NULL); |
856 new AutomationMsg_InstallExtension(0, crx_path, NULL); | |
857 | 856 |
858 // The context will delete itself after it is called. | 857 // The context will delete itself after it is called. |
859 automation_server_->SendAsAsync(msg, ctx, this); | 858 automation_server_->SendAsAsync(msg, ctx, this); |
860 } | 859 } |
861 | 860 |
862 void ChromeFrameAutomationClient::InstallExtensionComplete( | 861 void ChromeFrameAutomationClient::InstallExtensionComplete( |
863 const FilePath& crx_path, | 862 const FilePath& crx_path, |
864 void* user_data, | 863 void* user_data, |
865 AutomationMsg_ExtensionResponseValues res) { | 864 AutomationMsg_ExtensionResponseValues res) { |
866 DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); | 865 DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); |
867 | 866 |
868 if (chrome_frame_delegate_) { | 867 if (chrome_frame_delegate_) { |
869 chrome_frame_delegate_->OnExtensionInstalled(crx_path, user_data, res); | 868 chrome_frame_delegate_->OnExtensionInstalled(crx_path, user_data, res); |
870 } | 869 } |
871 } | 870 } |
872 | 871 |
873 void ChromeFrameAutomationClient::GetEnabledExtensions(void* user_data) { | 872 void ChromeFrameAutomationClient::GetEnabledExtensions(void* user_data) { |
874 if (automation_server_ == NULL) { | 873 if (automation_server_ == NULL) { |
875 GetEnabledExtensionsComplete(user_data, &std::vector<FilePath>()); | 874 GetEnabledExtensionsComplete(user_data, &std::vector<FilePath>()); |
876 return; | 875 return; |
877 } | 876 } |
878 | 877 |
879 GetEnabledExtensionsContext* ctx = new GetEnabledExtensionsContext( | 878 GetEnabledExtensionsContext* ctx = new GetEnabledExtensionsContext( |
880 this, user_data); | 879 this, user_data); |
881 | 880 |
882 IPC::SyncMessage* msg = new AutomationMsg_GetEnabledExtensions( | 881 IPC::SyncMessage* msg = new AutomationMsg_GetEnabledExtensions( |
883 0, ctx->extension_directories()); | 882 ctx->extension_directories()); |
884 | 883 |
885 // The context will delete itself after it is called. | 884 // The context will delete itself after it is called. |
886 automation_server_->SendAsAsync(msg, ctx, this); | 885 automation_server_->SendAsAsync(msg, ctx, this); |
887 } | 886 } |
888 | 887 |
889 void ChromeFrameAutomationClient::GetEnabledExtensionsComplete( | 888 void ChromeFrameAutomationClient::GetEnabledExtensionsComplete( |
890 void* user_data, | 889 void* user_data, |
891 std::vector<FilePath>* extension_directories) { | 890 std::vector<FilePath>* extension_directories) { |
892 DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); | 891 DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); |
893 | 892 |
(...skipping 26 matching lines...) Expand all Loading... |
920 if (automation_server_ == NULL) { | 919 if (automation_server_ == NULL) { |
921 InstallExtensionComplete(path, | 920 InstallExtensionComplete(path, |
922 user_data, | 921 user_data, |
923 AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 922 AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
924 return; | 923 return; |
925 } | 924 } |
926 | 925 |
927 InstallExtensionContext* ctx = new InstallExtensionContext( | 926 InstallExtensionContext* ctx = new InstallExtensionContext( |
928 this, path, user_data); | 927 this, path, user_data); |
929 | 928 |
930 IPC::SyncMessage* msg = | 929 IPC::SyncMessage* msg = new AutomationMsg_LoadExpandedExtension(path, NULL); |
931 new AutomationMsg_LoadExpandedExtension(0, path, NULL); | |
932 | 930 |
933 // The context will delete itself after it is called. | 931 // The context will delete itself after it is called. |
934 automation_server_->SendAsAsync(msg, ctx, this); | 932 automation_server_->SendAsAsync(msg, ctx, this); |
935 } | 933 } |
936 | 934 |
937 void ChromeFrameAutomationClient::CreateExternalTab() { | 935 void ChromeFrameAutomationClient::CreateExternalTab() { |
938 AutomationLaunchResult launch_result = AUTOMATION_SUCCESS; | 936 AutomationLaunchResult launch_result = AUTOMATION_SUCCESS; |
939 DCHECK(IsWindow()); | 937 DCHECK(IsWindow()); |
940 DCHECK(automation_server_ != NULL); | 938 DCHECK(automation_server_ != NULL); |
941 | 939 |
942 if (chrome_launch_params_->url().is_valid()) { | 940 if (chrome_launch_params_->url().is_valid()) { |
943 navigate_after_initialization_ = false; | 941 navigate_after_initialization_ = false; |
944 } | 942 } |
945 | 943 |
946 const IPC::ExternalTabSettings settings( | 944 const ExternalTabSettings settings( |
947 m_hWnd, | 945 m_hWnd, |
948 gfx::Rect(), | 946 gfx::Rect(), |
949 WS_CHILD, | 947 WS_CHILD, |
950 chrome_launch_params_->incognito(), | 948 chrome_launch_params_->incognito(), |
951 !use_chrome_network_, | 949 !use_chrome_network_, |
952 handle_top_level_requests_, | 950 handle_top_level_requests_, |
953 chrome_launch_params_->url(), | 951 chrome_launch_params_->url(), |
954 chrome_launch_params_->referrer(), | 952 chrome_launch_params_->referrer(), |
955 // Infobars disabled in widget mode. | 953 // Infobars disabled in widget mode. |
956 !chrome_launch_params_->widget_mode(), | 954 !chrome_launch_params_->widget_mode(), |
957 chrome_launch_params_->route_all_top_level_navigations()); | 955 chrome_launch_params_->route_all_top_level_navigations()); |
958 | 956 |
959 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( | 957 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( |
960 "ChromeFrame.HostNetworking", !use_chrome_network_, 0, 1, 2); | 958 "ChromeFrame.HostNetworking", !use_chrome_network_, 0, 1, 2); |
961 | 959 |
962 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( | 960 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( |
963 "ChromeFrame.HandleTopLevelRequests", handle_top_level_requests_, 0, 1, | 961 "ChromeFrame.HandleTopLevelRequests", handle_top_level_requests_, 0, 1, |
964 2); | 962 2); |
965 | 963 |
966 IPC::SyncMessage* message = | 964 IPC::SyncMessage* message = |
967 new AutomationMsg_CreateExternalTab(0, settings, NULL, NULL, 0, 0); | 965 new AutomationMsg_CreateExternalTab(settings, NULL, NULL, 0, 0); |
968 automation_server_->SendAsAsync(message, new CreateExternalTabContext(this), | 966 automation_server_->SendAsAsync(message, new CreateExternalTabContext(this), |
969 this); | 967 this); |
970 } | 968 } |
971 | 969 |
972 AutomationLaunchResult ChromeFrameAutomationClient::CreateExternalTabComplete( | 970 AutomationLaunchResult ChromeFrameAutomationClient::CreateExternalTabComplete( |
973 HWND chrome_window, HWND tab_window, int tab_handle, int session_id) { | 971 HWND chrome_window, HWND tab_window, int tab_handle, int session_id) { |
974 if (!automation_server_) { | 972 if (!automation_server_) { |
975 // If we receive this notification while shutting down, do nothing. | 973 // If we receive this notification while shutting down, do nothing. |
976 DLOG(ERROR) << "CreateExternalTabComplete called when automation server " | 974 DLOG(ERROR) << "CreateExternalTabComplete called when automation server " |
977 << "was null!"; | 975 << "was null!"; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 // If we have a valid tab_handle here it means that we are attaching to | 1024 // If we have a valid tab_handle here it means that we are attaching to |
1027 // an existing ExternalTabContainer instance, in which case we don't | 1025 // an existing ExternalTabContainer instance, in which case we don't |
1028 // want to create an external tab instance in Chrome. | 1026 // want to create an external tab instance in Chrome. |
1029 if (external_tab_cookie_ == 0) { | 1027 if (external_tab_cookie_ == 0) { |
1030 // Continue with Initialization - Create external tab | 1028 // Continue with Initialization - Create external tab |
1031 CreateExternalTab(); | 1029 CreateExternalTab(); |
1032 } else { | 1030 } else { |
1033 // Send a notification to Chrome that we are ready to connect to the | 1031 // Send a notification to Chrome that we are ready to connect to the |
1034 // ExternalTab. | 1032 // ExternalTab. |
1035 IPC::SyncMessage* message = | 1033 IPC::SyncMessage* message = |
1036 new AutomationMsg_ConnectExternalTab(0, external_tab_cookie_, true, | 1034 new AutomationMsg_ConnectExternalTab(external_tab_cookie_, true, |
1037 m_hWnd, NULL, NULL, NULL, 0); | 1035 m_hWnd, NULL, NULL, NULL, 0); |
1038 automation_server_->SendAsAsync(message, | 1036 automation_server_->SendAsAsync(message, |
1039 new CreateExternalTabContext(this), | 1037 new CreateExternalTabContext(this), |
1040 this); | 1038 this); |
1041 DVLOG(1) << __FUNCTION__ << ": sending CreateExternalTabComplete"; | 1039 DVLOG(1) << __FUNCTION__ << ": sending CreateExternalTabComplete"; |
1042 } | 1040 } |
1043 } | 1041 } |
1044 } else { | 1042 } else { |
1045 // Launch failed. Note, we cannot delete proxy here. | 1043 // Launch failed. Note, we cannot delete proxy here. |
1046 PostTask(FROM_HERE, NewRunnableMethod(this, | 1044 PostTask(FROM_HERE, NewRunnableMethod(this, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 uint64 external_tab_cookie) { | 1360 uint64 external_tab_cookie) { |
1363 DCHECK_EQ(static_cast<TabProxy*>(NULL), tab_.get()); | 1361 DCHECK_EQ(static_cast<TabProxy*>(NULL), tab_.get()); |
1364 DCHECK_EQ(-1, tab_handle_); | 1362 DCHECK_EQ(-1, tab_handle_); |
1365 | 1363 |
1366 external_tab_cookie_ = external_tab_cookie; | 1364 external_tab_cookie_ = external_tab_cookie; |
1367 } | 1365 } |
1368 | 1366 |
1369 void ChromeFrameAutomationClient::BlockExternalTab(uint64 cookie) { | 1367 void ChromeFrameAutomationClient::BlockExternalTab(uint64 cookie) { |
1370 // The host does not want this tab to be shown (due popup blocker). | 1368 // The host does not want this tab to be shown (due popup blocker). |
1371 IPC::SyncMessage* message = | 1369 IPC::SyncMessage* message = |
1372 new AutomationMsg_ConnectExternalTab(0, cookie, false, m_hWnd, | 1370 new AutomationMsg_ConnectExternalTab(cookie, false, m_hWnd, |
1373 NULL, NULL, NULL, 0); | 1371 NULL, NULL, NULL, 0); |
1374 automation_server_->SendAsAsync(message, NULL, this); | 1372 automation_server_->SendAsAsync(message, NULL, this); |
1375 } | 1373 } |
1376 | 1374 |
1377 void ChromeFrameAutomationClient::SetPageFontSize( | 1375 void ChromeFrameAutomationClient::SetPageFontSize( |
1378 enum AutomationPageFontSize font_size) { | 1376 enum AutomationPageFontSize font_size) { |
1379 if (font_size < SMALLEST_FONT || | 1377 if (font_size < SMALLEST_FONT || |
1380 font_size > LARGEST_FONT) { | 1378 font_size > LARGEST_FONT) { |
1381 NOTREACHED() << "Invalid font size specified : " | 1379 NOTREACHED() << "Invalid font size specified : " |
1382 << font_size; | 1380 << font_size; |
1383 return; | 1381 return; |
1384 } | 1382 } |
1385 | 1383 |
1386 automation_server_->Send( | 1384 automation_server_->Send( |
1387 new AutomationMsg_SetPageFontSize(0, tab_handle_, font_size)); | 1385 new AutomationMsg_SetPageFontSize(tab_handle_, font_size)); |
1388 } | 1386 } |
1389 | 1387 |
1390 void ChromeFrameAutomationClient::RemoveBrowsingData(int remove_mask) { | 1388 void ChromeFrameAutomationClient::RemoveBrowsingData(int remove_mask) { |
1391 automation_server_->Send( | 1389 automation_server_->Send(new AutomationMsg_RemoveBrowsingData(remove_mask)); |
1392 new AutomationMsg_RemoveBrowsingData(0, remove_mask)); | |
1393 } | 1390 } |
1394 | 1391 |
1395 void ChromeFrameAutomationClient::SetUrlFetcher( | 1392 void ChromeFrameAutomationClient::SetUrlFetcher( |
1396 PluginUrlRequestManager* url_fetcher) { | 1393 PluginUrlRequestManager* url_fetcher) { |
1397 DCHECK(url_fetcher != NULL); | 1394 DCHECK(url_fetcher != NULL); |
1398 url_fetcher_ = url_fetcher; | 1395 url_fetcher_ = url_fetcher; |
1399 url_fetcher_flags_ = url_fetcher->GetThreadSafeFlags(); | 1396 url_fetcher_flags_ = url_fetcher->GetThreadSafeFlags(); |
1400 url_fetcher_->set_delegate(this); | 1397 url_fetcher_->set_delegate(this); |
1401 } | 1398 } |
1402 | 1399 |
1403 void ChromeFrameAutomationClient::SetZoomLevel(PageZoom::Function zoom_level) { | 1400 void ChromeFrameAutomationClient::SetZoomLevel(PageZoom::Function zoom_level) { |
1404 if (automation_server_) { | 1401 if (automation_server_) { |
1405 automation_server_->Send(new AutomationMsg_SetZoomLevel(0, tab_handle_, | 1402 automation_server_->Send(new AutomationMsg_SetZoomLevel(tab_handle_, |
1406 zoom_level)); | 1403 zoom_level)); |
1407 } | 1404 } |
1408 } | 1405 } |
1409 | 1406 |
1410 void ChromeFrameAutomationClient::OnUnload(bool* should_unload) { | 1407 void ChromeFrameAutomationClient::OnUnload(bool* should_unload) { |
1411 *should_unload = true; | 1408 *should_unload = true; |
1412 if (automation_server_) { | 1409 if (automation_server_) { |
1413 const DWORD kUnloadEventTimeout = 20000; | 1410 const DWORD kUnloadEventTimeout = 20000; |
1414 | 1411 |
1415 IPC::SyncMessage* msg = new AutomationMsg_RunUnloadHandlers(0, tab_handle_, | 1412 IPC::SyncMessage* msg = new AutomationMsg_RunUnloadHandlers(tab_handle_, |
1416 should_unload); | 1413 should_unload); |
1417 base::WaitableEvent unload_call_finished(false, false); | 1414 base::WaitableEvent unload_call_finished(false, false); |
1418 UnloadContext* unload_context = new UnloadContext(&unload_call_finished, | 1415 UnloadContext* unload_context = new UnloadContext(&unload_call_finished, |
1419 should_unload); | 1416 should_unload); |
1420 automation_server_->SendAsAsync(msg, unload_context, this); | 1417 automation_server_->SendAsAsync(msg, unload_context, this); |
1421 HANDLE done = unload_call_finished.handle(); | 1418 HANDLE done = unload_call_finished.handle(); |
1422 WaitWithMessageLoop(&done, 1, kUnloadEventTimeout); | 1419 WaitWithMessageLoop(&done, 1, kUnloadEventTimeout); |
1423 } | 1420 } |
1424 } | 1421 } |
1425 | 1422 |
1426 ////////////////////////////////////////////////////////////////////////// | 1423 ////////////////////////////////////////////////////////////////////////// |
1427 // PluginUrlRequestDelegate implementation. | 1424 // PluginUrlRequestDelegate implementation. |
1428 // Forward network related responses to Chrome. | 1425 // Forward network related responses to Chrome. |
1429 | 1426 |
1430 void ChromeFrameAutomationClient::OnResponseStarted(int request_id, | 1427 void ChromeFrameAutomationClient::OnResponseStarted(int request_id, |
1431 const char* mime_type, const char* headers, int size, | 1428 const char* mime_type, const char* headers, int size, |
1432 base::Time last_modified, const std::string& redirect_url, | 1429 base::Time last_modified, const std::string& redirect_url, |
1433 int redirect_status) { | 1430 int redirect_status) { |
1434 const IPC::AutomationURLResponse response( | 1431 const AutomationURLResponse response( |
1435 mime_type, | 1432 mime_type, |
1436 headers ? headers : "", | 1433 headers ? headers : "", |
1437 size, | 1434 size, |
1438 last_modified, | 1435 last_modified, |
1439 redirect_url, | 1436 redirect_url, |
1440 redirect_status); | 1437 redirect_status); |
1441 | 1438 |
1442 automation_server_->Send(new AutomationMsg_RequestStarted(0, | 1439 automation_server_->Send(new AutomationMsg_RequestStarted( |
1443 tab_->handle(), request_id, response)); | 1440 tab_->handle(), request_id, response)); |
1444 } | 1441 } |
1445 | 1442 |
1446 void ChromeFrameAutomationClient::OnReadComplete(int request_id, | 1443 void ChromeFrameAutomationClient::OnReadComplete(int request_id, |
1447 const std::string& data) { | 1444 const std::string& data) { |
1448 automation_server_->Send(new AutomationMsg_RequestData(0, tab_->handle(), | 1445 automation_server_->Send(new AutomationMsg_RequestData( |
1449 request_id, data)); | 1446 tab_->handle(), request_id, data)); |
1450 } | 1447 } |
1451 | 1448 |
1452 void ChromeFrameAutomationClient::OnResponseEnd(int request_id, | 1449 void ChromeFrameAutomationClient::OnResponseEnd(int request_id, |
1453 const URLRequestStatus& status) { | 1450 const URLRequestStatus& status) { |
1454 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), | 1451 automation_server_->Send(new AutomationMsg_RequestEnd( |
1455 request_id, status)); | 1452 tab_->handle(), request_id, status)); |
1456 } | 1453 } |
1457 | 1454 |
1458 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, | 1455 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, |
1459 const GURL& url, const std::string& cookie_string, int cookie_id) { | 1456 const GURL& url, const std::string& cookie_string, int cookie_id) { |
1460 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse(0, | 1457 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse( |
1461 tab_->handle(), success, url, cookie_string, cookie_id)); | 1458 tab_->handle(), success, url, cookie_string, cookie_id)); |
1462 } | 1459 } |
OLD | NEW |