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

Side by Side Diff: chrome_frame/chrome_frame_activex_base.h

Issue 385108: Transfer CF downloads to the host browser.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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_active_document.cc ('k') | chrome_frame/extra_system_apis.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 #include <atlctl.h> 10 #include <atlctl.h>
11 11
12 // Copied min/max defs from windows headers to appease atlimage.h. 12 // Copied min/max defs from windows headers to appease atlimage.h.
13 // TODO(slightlyoff): Figure out of more recent platform SDK's (> 6.1) 13 // TODO(slightlyoff): Figure out of more recent platform SDK's (> 6.1)
14 // undo the janky "#define NOMINMAX" train wreck. See: 14 // undo the janky "#define NOMINMAX" train wreck. See:
15 // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedback ID=100703 15 // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedback ID=100703
16 #ifndef max 16 #ifndef max
17 #define max(a,b) (((a) > (b)) ? (a) : (b)) 17 #define max(a,b) (((a) > (b)) ? (a) : (b)) // NOLINT
18 #endif 18 #endif
19 #ifndef min 19 #ifndef min
20 #define min(a,b) (((a) < (b)) ? (a) : (b)) 20 #define min(a,b) (((a) < (b)) ? (a) : (b)) // NOLINT
21 #endif 21 #endif
22 #include <atlimage.h> 22 #include <atlimage.h>
23 #undef max 23 #undef max
24 #undef min 24 #undef min
25 25
26 #include <shdeprecated.h> // for IBrowserService2 26 #include <shdeprecated.h> // for IBrowserService2
27 #include <shlguid.h> 27 #include <shlguid.h>
28 28
29 #include <set> 29 #include <set>
30 #include <string> 30 #include <string>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 var.pdispVal = event; 92 var.pdispVal = event;
93 FireMethodWithParam(CF_EVENT_DISPID_ONLOADERROR, var); 93 FireMethodWithParam(CF_EVENT_DISPID_ONLOADERROR, var);
94 } 94 }
95 95
96 void Fire_onmessage(IDispatch* event) { 96 void Fire_onmessage(IDispatch* event) {
97 VARIANT var = { VT_DISPATCH }; 97 VARIANT var = { VT_DISPATCH };
98 var.pdispVal = event; 98 var.pdispVal = event;
99 FireMethodWithParam(CF_EVENT_DISPID_ONMESSAGE, var); 99 FireMethodWithParam(CF_EVENT_DISPID_ONMESSAGE, var);
100 } 100 }
101 101
102 void Fire_onreadystatechanged(long readystate) { 102 void Fire_onreadystatechanged(long readystate) { // NOLINT
103 VARIANT var = { VT_I4 }; 103 VARIANT var = { VT_I4 };
104 var.lVal = readystate; 104 var.lVal = readystate;
105 FireMethodWithParam(CF_EVENT_DISPID_ONREADYSTATECHANGED, var); 105 FireMethodWithParam(CF_EVENT_DISPID_ONREADYSTATECHANGED, var);
106 } 106 }
107 107
108 void Fire_onprivatemessage(IDispatch* event, BSTR target) { 108 void Fire_onprivatemessage(IDispatch* event, BSTR target) {
109 // Arguments in reverse order to the function declaration, because 109 // Arguments in reverse order to the function declaration, because
110 // that's what DISPPARAMS requires. 110 // that's what DISPPARAMS requires.
111 VARIANT args[2] = { { VT_BSTR, }, {VT_DISPATCH, } }; 111 VARIANT args[2] = { { VT_BSTR, }, {VT_DISPATCH, } };
112 args[0].bstrVal = target; 112 args[0].bstrVal = target;
113 args[1].pdispVal = event; 113 args[1].pdispVal = event;
114 114
115 FireMethodWithParams(CF_EVENT_DISPID_ONPRIVATEMESSAGE, 115 FireMethodWithParams(CF_EVENT_DISPID_ONPRIVATEMESSAGE,
116 args, 116 args,
117 arraysize(args)); 117 arraysize(args));
118 } 118 }
119 119
120 void Fire_onextensionready(BSTR path, long response) { 120 void Fire_onextensionready(BSTR path, long response) { // NOLINT
121 // Arguments in reverse order to the function declaration, because 121 // Arguments in reverse order to the function declaration, because
122 // that's what DISPPARAMS requires. 122 // that's what DISPPARAMS requires.
123 VARIANT args[2] = { { VT_I4, }, { VT_BSTR, } }; 123 VARIANT args[2] = { { VT_I4, }, { VT_BSTR, } };
124 args[0].lVal = response; 124 args[0].lVal = response;
125 args[1].bstrVal = path; 125 args[1].bstrVal = path;
126 126
127 FireMethodWithParams(CF_EVENT_DISPID_ONEXTENSIONREADY, 127 FireMethodWithParams(CF_EVENT_DISPID_ONEXTENSIONREADY,
128 args, 128 args,
129 arraysize(args)); 129 arraysize(args));
130 } 130 }
131 }; 131 };
132 132
133 extern bool g_first_launch_by_process_; 133 extern bool g_first_launch_by_process_;
134 134
135 // Common implementation for ActiveX and Active Document 135 // Common implementation for ActiveX and Active Document
136 template <class T, const CLSID& class_id> 136 template <class T, const CLSID& class_id>
137 class ATL_NO_VTABLE ChromeFrameActivexBase : 137 class ATL_NO_VTABLE ChromeFrameActivexBase : // NOLINT
138 public CComObjectRootEx<CComMultiThreadModel>, 138 public CComObjectRootEx<CComMultiThreadModel>,
139 public IOleControlImpl<T>, 139 public IOleControlImpl<T>,
140 public IOleObjectImpl<T>, 140 public IOleObjectImpl<T>,
141 public IOleInPlaceActiveObjectImpl<T>, 141 public IOleInPlaceActiveObjectImpl<T>,
142 public IViewObjectExImpl<T>, 142 public IViewObjectExImpl<T>,
143 public IOleInPlaceObjectWindowlessImpl<T>, 143 public IOleInPlaceObjectWindowlessImpl<T>,
144 public ISupportErrorInfo, 144 public ISupportErrorInfo,
145 public IQuickActivateImpl<T>, 145 public IQuickActivateImpl<T>,
146 public com_util::IProvideClassInfo2Impl<class_id, 146 public com_util::IProvideClassInfo2Impl<class_id,
147 DIID_DIChromeFrameEvents>, 147 DIID_DIChromeFrameEvents>,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 }; 259 };
260 260
261 for (int i = 0; i < arraysize(interfaces); ++i) { 261 for (int i = 0; i < arraysize(interfaces); ++i) {
262 if (InlineIsEqualGUID(*interfaces[i], riid)) 262 if (InlineIsEqualGUID(*interfaces[i], riid))
263 return S_OK; 263 return S_OK;
264 } 264 }
265 return S_FALSE; 265 return S_FALSE;
266 } 266 }
267 267
268 // Called to draw our control when chrome hasn't been initialized. 268 // Called to draw our control when chrome hasn't been initialized.
269 virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info) { // NO_LINT 269 virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info) { // NOLINT
270 if (NULL == draw_info.prcBounds) { 270 if (NULL == draw_info.prcBounds) {
271 NOTREACHED(); 271 NOTREACHED();
272 return E_FAIL; 272 return E_FAIL;
273 } 273 }
274 // Don't draw anything. 274 // Don't draw anything.
275 return S_OK; 275 return S_OK;
276 } 276 }
277 277
278 278
279 // Used to setup the document_url_ member needed for completing navigation. 279 // Used to setup the document_url_ member needed for completing navigation.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 automation_client_->ReadRequest(request_id, bytes_to_read); 483 automation_client_->ReadRequest(request_id, bytes_to_read);
484 } 484 }
485 485
486 virtual void OnRequestEnd(int tab_handle, int request_id, 486 virtual void OnRequestEnd(int tab_handle, int request_id,
487 const URLRequestStatus& status) { 487 const URLRequestStatus& status) {
488 automation_client_->RemoveRequest(request_id, true); 488 automation_client_->RemoveRequest(request_id, true);
489 } 489 }
490 490
491 virtual void OnDownloadRequestInHost(int tab_handle, int request_id) { 491 virtual void OnDownloadRequestInHost(int tab_handle, int request_id) {
492 DLOG(INFO) << "TODO: Let the host browser handle this download"; 492 DLOG(INFO) << "TODO: Let the host browser handle this download";
493 PluginUrlRequest* request = automation_client_->LookupRequest(request_id);
494 if (request) {
495 static_cast<UrlmonUrlRequest*>(request)->TransferToHost(doc_site_);
496 }
493 automation_client_->RemoveRequest(request_id, false); 497 automation_client_->RemoveRequest(request_id, false);
494 } 498 }
495 499
496 virtual void OnSetCookieAsync(int tab_handle, const GURL& url, 500 virtual void OnSetCookieAsync(int tab_handle, const GURL& url,
497 const std::string& cookie) { 501 const std::string& cookie) {
498 std::string name; 502 std::string name;
499 std::string data; 503 std::string data;
500 size_t name_end = cookie.find('='); 504 size_t name_end = cookie.find('=');
501 if (std::string::npos != name_end) { 505 if (std::string::npos != name_end) {
502 name = cookie.substr(0, name_end); 506 name = cookie.substr(0, name_end);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 911 }
908 912
909 return hr; 913 return hr;
910 } 914 }
911 915
912 // Creates a new event object that supports the |data| property. 916 // Creates a new event object that supports the |data| property.
913 // Note: you should supply an empty string for |origin| unless you're 917 // Note: you should supply an empty string for |origin| unless you're
914 // creating a "message" event. 918 // creating a "message" event.
915 HRESULT CreateDomEvent(const std::string& event_type, const std::string& data, 919 HRESULT CreateDomEvent(const std::string& event_type, const std::string& data,
916 const std::string& origin, IDispatch** event) { 920 const std::string& origin, IDispatch** event) {
917 DCHECK(event_type.length() > 0); 921 DCHECK(event_type.length() > 0); // NOLINT
918 DCHECK(event != NULL); 922 DCHECK(event != NULL);
919 923
920 CComObject<ComMessageEvent>* ev = NULL; 924 CComObject<ComMessageEvent>* ev = NULL;
921 HRESULT hr = CComObject<ComMessageEvent>::CreateInstance(&ev); 925 HRESULT hr = CComObject<ComMessageEvent>::CreateInstance(&ev);
922 if (SUCCEEDED(hr)) { 926 if (SUCCEEDED(hr)) {
923 ev->AddRef(); 927 ev->AddRef();
924 928
925 ScopedComPtr<IOleContainer> container; 929 ScopedComPtr<IOleContainer> container;
926 m_spClientSite->GetContainer(container.Receive()); 930 m_spClientSite->GetContainer(container.Receive());
927 if (ev->Initialize(container, data, origin, event_type)) { 931 if (ev->Initialize(container, data, origin, event_type)) {
(...skipping 14 matching lines...) Expand all
942 ScopedVariant script_arg(UTF8ToWide(param.c_str()).c_str()); 946 ScopedVariant script_arg(UTF8ToWide(param.c_str()).c_str());
943 return InvokeScriptFunction(script_object, script_arg.AsInput()); 947 return InvokeScriptFunction(script_object, script_arg.AsInput());
944 } 948 }
945 949
946 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* param) { 950 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* param) {
947 return InvokeScriptFunction(script_object, param, 1); 951 return InvokeScriptFunction(script_object, param, 1);
948 } 952 }
949 953
950 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* params, 954 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* params,
951 int param_count) { 955 int param_count) {
952 DCHECK(param_count >= 0); 956 DCHECK_GE(param_count, 0);
953 DCHECK(params); 957 DCHECK(params);
954 958
955 if (V_VT(&script_object) != VT_DISPATCH) { 959 if (V_VT(&script_object) != VT_DISPATCH) {
956 return S_FALSE; 960 return S_FALSE;
957 } 961 }
958 962
959 CComPtr<IDispatch> script(script_object.pdispVal); 963 CComPtr<IDispatch> script(script_object.pdispVal);
960 HRESULT hr = script.InvokeN(static_cast<DISPID>(DISPID_VALUE), 964 HRESULT hr = script.InvokeN(static_cast<DISPID>(DISPID_VALUE),
961 params, 965 params,
962 param_count); 966 param_count);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 // should have first dibs anyway. 1059 // should have first dibs anyway.
1056 if (hr != S_OK && automation_client_.get()) { 1060 if (hr != S_OK && automation_client_.get()) {
1057 TabProxy* tab = automation_client_->tab(); 1061 TabProxy* tab = automation_client_->tab();
1058 if (tab) { 1062 if (tab) {
1059 tab->ProcessUnhandledAccelerator(accel_message); 1063 tab->ProcessUnhandledAccelerator(accel_message);
1060 } 1064 }
1061 } 1065 }
1062 } 1066 }
1063 1067
1064 protected: 1068 protected:
1065 // The following functions are called to initialize and uninitialize the 1069 // The following functions are called to initialize and uninitialize the
1066 // worker thread. 1070 // worker thread.
1067 void OnWorkerStart() { 1071 void OnWorkerStart() {
1068 CoInitialize(NULL); 1072 CoInitialize(NULL);
1069 } 1073 }
1070 1074
1071 void OnWorkerStop() { 1075 void OnWorkerStop() {
1072 CoUninitialize(); 1076 CoUninitialize();
1073 } 1077 }
1074 1078
1075 ScopedBstr url_; 1079 ScopedBstr url_;
1076 ScopedComPtr<IOleDocumentSite> doc_site_; 1080 ScopedComPtr<IOleDocumentSite> doc_site_;
1077 1081
1078 // For more information on the ready_state_ property see: 1082 // For more information on the ready_state_ property see:
1079 // http://msdn.microsoft.com/en-us/library/aa768179(VS.85).aspx# 1083 // http://msdn.microsoft.com/en-us/library/aa768179(VS.85).aspx#
1080 READYSTATE ready_state_; 1084 READYSTATE ready_state_;
1081 1085
1082 // The following members contain IDispatch interfaces representing the 1086 // The following members contain IDispatch interfaces representing the
1083 // onload/onerror/onmessage handlers on the page. 1087 // onload/onerror/onmessage handlers on the page.
1084 ScopedVariant onload_handler_; 1088 ScopedVariant onload_handler_;
1085 ScopedVariant onerror_handler_; 1089 ScopedVariant onerror_handler_;
1086 ScopedVariant onmessage_handler_; 1090 ScopedVariant onmessage_handler_;
1087 1091
1088 EventHandlers onmessage_; 1092 EventHandlers onmessage_;
1089 EventHandlers onloaderror_; 1093 EventHandlers onloaderror_;
1090 EventHandlers onload_; 1094 EventHandlers onload_;
1091 EventHandlers onreadystatechanged_; 1095 EventHandlers onreadystatechanged_;
1092 EventHandlers onprivatemessage_; 1096 EventHandlers onprivatemessage_;
1093 EventHandlers onextensionready_; 1097 EventHandlers onextensionready_;
1094 1098
1095 // The UrlmonUrlRequest instance instantiated for downloading the base URL. 1099 // The UrlmonUrlRequest instance instantiated for downloading the base URL.
1096 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_; 1100 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_;
1097 1101
1098 base::Thread worker_thread_; 1102 base::Thread worker_thread_;
1099 }; 1103 };
1100 1104
1101 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 1105 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
OLDNEW
« no previous file with comments | « chrome_frame/chrome_active_document.cc ('k') | chrome_frame/extra_system_apis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698