OLD | NEW |
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> |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (client_site) { | 268 if (client_site) { |
269 doc_site_.QueryFrom(client_site); | 269 doc_site_.QueryFrom(client_site); |
270 } | 270 } |
271 | 271 |
272 return CComControlBase::IOleObject_SetClientSite(client_site); | 272 return CComControlBase::IOleObject_SetClientSite(client_site); |
273 } | 273 } |
274 | 274 |
275 bool HandleContextMenuCommand(UINT cmd) { | 275 bool HandleContextMenuCommand(UINT cmd) { |
276 if (cmd == IDC_ABOUT_CHROME_FRAME) { | 276 if (cmd == IDC_ABOUT_CHROME_FRAME) { |
277 int tab_handle = automation_client_->tab()->handle(); | 277 int tab_handle = automation_client_->tab()->handle(); |
278 OnOpenURL(tab_handle, GURL("about:version"), NEW_WINDOW); | 278 OnOpenURL(tab_handle, GURL("about:version"), GURL(), NEW_WINDOW); |
279 return true; | 279 return true; |
280 } | 280 } |
281 | 281 |
282 return false; | 282 return false; |
283 } | 283 } |
284 | 284 |
285 // Should connections initiated by this class try to block | 285 // Should connections initiated by this class try to block |
286 // responses served with the X-Frame-Options header? | 286 // responses served with the X-Frame-Options header? |
287 // ActiveX controls genereally will want to do this, | 287 // ActiveX controls genereally will want to do this, |
288 // returning true, while true top-level documents | 288 // returning true, while true top-level documents |
(...skipping 11 matching lines...) Expand all Loading... |
300 | 300 |
301 HWND parent = ::GetParent(m_hWnd); | 301 HWND parent = ::GetParent(m_hWnd); |
302 ::SetFocus(parent); | 302 ::SetFocus(parent); |
303 ScopedComPtr<IOleControlSite> control_site; | 303 ScopedComPtr<IOleControlSite> control_site; |
304 control_site.QueryFrom(m_spClientSite); | 304 control_site.QueryFrom(m_spClientSite); |
305 if (control_site) | 305 if (control_site) |
306 control_site->OnFocus(FALSE); | 306 control_site->OnFocus(FALSE); |
307 } | 307 } |
308 | 308 |
309 virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, | 309 virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, |
310 int open_disposition) { | 310 const GURL& referrer, int open_disposition) { |
311 ScopedComPtr<IWebBrowser2> web_browser2; | 311 ScopedComPtr<IWebBrowser2> web_browser2; |
312 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 312 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
313 DCHECK(web_browser2); | 313 DCHECK(web_browser2); |
314 | 314 |
315 ScopedVariant url; | 315 ScopedVariant url; |
316 // Check to see if the URL uses a "view-source:" prefix, if so, open it | 316 // Check to see if the URL uses a "view-source:" prefix, if so, open it |
317 // using chrome frame full tab mode by using 'cf:' protocol handler. | 317 // using chrome frame full tab mode by using 'cf:' protocol handler. |
318 // Also change the disposition to NEW_WINDOW since IE6 doesn't have tabs. | 318 // Also change the disposition to NEW_WINDOW since IE6 doesn't have tabs. |
319 if (url_to_open.has_scheme() && (url_to_open.SchemeIs("view-source") || | 319 if (url_to_open.has_scheme() && (url_to_open.SchemeIs("view-source") || |
320 url_to_open.SchemeIs("about"))) { | 320 url_to_open.SchemeIs("about"))) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // CreateUri(UTF8ToWide(open_url_command->url_.spec()).c_str(), | 372 // CreateUri(UTF8ToWide(open_url_command->url_.spec()).c_str(), |
373 // Uri_CREATE_IE_SETTINGS, 0, &uri); | 373 // Uri_CREATE_IE_SETTINGS, 0, &uri); |
374 // CComPtr<IBindCtx> bind_ctx; | 374 // CComPtr<IBindCtx> bind_ctx; |
375 // CreateBindCtx(0, &bind_ctx); | 375 // CreateBindCtx(0, &bind_ctx); |
376 // target_frame->AggregatedNavigation2( | 376 // target_frame->AggregatedNavigation2( |
377 // HLNF_TRUSTFIRSTDOWNLOAD|HLNF_OPENINNEWWINDOW, bind_ctx, NULL, | 377 // HLNF_TRUSTFIRSTDOWNLOAD|HLNF_OPENINNEWWINDOW, bind_ctx, NULL, |
378 // L"No_Name", uri, L""); | 378 // L"No_Name", uri, L""); |
379 // } | 379 // } |
380 // End of MSHTML-like logic | 380 // End of MSHTML-like logic |
381 VARIANT empty = ScopedVariant::kEmptyVariant; | 381 VARIANT empty = ScopedVariant::kEmptyVariant; |
382 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, &empty); | 382 ScopedVariant http_headers; |
| 383 |
| 384 if (referrer.is_valid()) { |
| 385 std::wstring referrer_header = L"Referer: "; |
| 386 referrer_header += UTF8ToWide(referrer.spec()); |
| 387 referrer_header += L"\r\n\r\n"; |
| 388 http_headers.Set(referrer_header.c_str()); |
| 389 } |
| 390 |
| 391 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, |
| 392 http_headers.AsInput()); |
383 web_browser2->put_Visible(VARIANT_TRUE); | 393 web_browser2->put_Visible(VARIANT_TRUE); |
384 } | 394 } |
385 | 395 |
386 virtual void OnRequestStart(int tab_handle, int request_id, | 396 virtual void OnRequestStart(int tab_handle, int request_id, |
387 const IPC::AutomationURLRequest& request_info) { | 397 const IPC::AutomationURLRequest& request_info) { |
388 scoped_refptr<CComObject<UrlmonUrlRequest> > request; | 398 scoped_refptr<CComObject<UrlmonUrlRequest> > request; |
389 if (base_url_request_.get() && | 399 if (base_url_request_.get() && |
390 GURL(base_url_request_->url()) == GURL(request_info.url)) { | 400 GURL(base_url_request_->url()) == GURL(request_info.url)) { |
391 request.swap(base_url_request_); | 401 request.swap(base_url_request_); |
392 } else { | 402 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 data.c_str()); | 445 data.c_str()); |
436 DCHECK(ret) << "InternetSetcookie failed. Error: " << GetLastError(); | 446 DCHECK(ret) << "InternetSetcookie failed. Error: " << GetLastError(); |
437 } | 447 } |
438 | 448 |
439 virtual void OnAttachExternalTab(int tab_handle, | 449 virtual void OnAttachExternalTab(int tab_handle, |
440 intptr_t cookie, | 450 intptr_t cookie, |
441 int disposition) { | 451 int disposition) { |
442 std::string url; | 452 std::string url; |
443 url = StringPrintf("cf:attach_external_tab&%d&%d", | 453 url = StringPrintf("cf:attach_external_tab&%d&%d", |
444 cookie, disposition); | 454 cookie, disposition); |
445 OnOpenURL(tab_handle, GURL(url), disposition); | 455 OnOpenURL(tab_handle, GURL(url), GURL(), disposition); |
446 } | 456 } |
447 | 457 |
448 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, | 458 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, |
449 BOOL& handled) { // NO_LINT | 459 BOOL& handled) { // NO_LINT |
450 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); | 460 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); |
451 automation_client_->SetParentWindow(m_hWnd); | 461 automation_client_->SetParentWindow(m_hWnd); |
452 // Only fire the 'interactive' ready state if we aren't there already. | 462 // Only fire the 'interactive' ready state if we aren't there already. |
453 if (ready_state_ < READYSTATE_INTERACTIVE) { | 463 if (ready_state_ < READYSTATE_INTERACTIVE) { |
454 ready_state_ = READYSTATE_INTERACTIVE; | 464 ready_state_ = READYSTATE_INTERACTIVE; |
455 FireOnChanged(DISPID_READYSTATE); | 465 FireOnChanged(DISPID_READYSTATE); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 std::string src_utf8; | 512 std::string src_utf8; |
503 WideToUTF8(src, SysStringLen(src), &src_utf8); | 513 WideToUTF8(src, SysStringLen(src), &src_utf8); |
504 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); | 514 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); |
505 if (full_url.empty()) { | 515 if (full_url.empty()) { |
506 return E_INVALIDARG; | 516 return E_INVALIDARG; |
507 } | 517 } |
508 | 518 |
509 // We can initiate navigation here even if ready_state is not complete. | 519 // We can initiate navigation here even if ready_state is not complete. |
510 // We do not have to set proxy, and AutomationClient will take care | 520 // We do not have to set proxy, and AutomationClient will take care |
511 // of navigation just after CreateExternalTab is done. | 521 // of navigation just after CreateExternalTab is done. |
512 if (!automation_client_->InitiateNavigation(full_url, is_privileged_)) { | 522 if (!automation_client_->InitiateNavigation(full_url, |
| 523 GetDocumentUrl(), |
| 524 is_privileged_)) { |
513 // TODO(robertshield): Make InitiateNavigation return more useful | 525 // TODO(robertshield): Make InitiateNavigation return more useful |
514 // error information. | 526 // error information. |
515 return E_INVALIDARG; | 527 return E_INVALIDARG; |
516 } | 528 } |
517 | 529 |
518 // Save full URL in BSTR member | 530 // Save full URL in BSTR member |
519 url_.Reset(::SysAllocString(UTF8ToWide(full_url).c_str())); | 531 url_.Reset(::SysAllocString(UTF8ToWide(full_url).c_str())); |
520 | 532 |
521 return S_OK; | 533 return S_OK; |
522 } | 534 } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 EventHandlers onloaderror_; | 895 EventHandlers onloaderror_; |
884 EventHandlers onload_; | 896 EventHandlers onload_; |
885 EventHandlers onreadystatechanged_; | 897 EventHandlers onreadystatechanged_; |
886 EventHandlers onprivatemessage_; | 898 EventHandlers onprivatemessage_; |
887 | 899 |
888 // The UrlmonUrlRequest instance instantiated for downloading the base URL. | 900 // The UrlmonUrlRequest instance instantiated for downloading the base URL. |
889 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_; | 901 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_; |
890 }; | 902 }; |
891 | 903 |
892 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 904 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |