| 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 // Implementation of ChromeActiveDocument | 5 // Implementation of ChromeActiveDocument |
| 6 #include "chrome_frame/chrome_active_document.h" | 6 #include "chrome_frame/chrome_active_document.h" |
| 7 | 7 |
| 8 #include <hlink.h> | 8 #include <hlink.h> |
| 9 #include <htiface.h> | 9 #include <htiface.h> |
| 10 #include <mshtmcid.h> | 10 #include <mshtmcid.h> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/thread.h" | 27 #include "base/thread.h" |
| 28 #include "base/thread_local.h" | 28 #include "base/thread_local.h" |
| 29 | 29 |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "chrome/browser/tab_contents/tab_contents.h" | 31 #include "chrome/browser/tab_contents/tab_contents.h" |
| 32 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
| 33 #include "chrome/common/navigation_types.h" | 33 #include "chrome/common/navigation_types.h" |
| 34 #include "chrome/test/automation/browser_proxy.h" | 34 #include "chrome/test/automation/browser_proxy.h" |
| 35 #include "chrome/test/automation/tab_proxy.h" | 35 #include "chrome/test/automation/tab_proxy.h" |
| 36 #include "chrome_frame/bho.h" |
| 36 #include "chrome_frame/utils.h" | 37 #include "chrome_frame/utils.h" |
| 37 | 38 |
| 38 const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab"; | 39 const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab"; |
| 39 | 40 |
| 40 static const wchar_t kUseChromeNetworking[] = L"UseChromeNetworking"; | 41 static const wchar_t kUseChromeNetworking[] = L"UseChromeNetworking"; |
| 41 static const wchar_t kHandleTopLevelRequests[] = | 42 static const wchar_t kHandleTopLevelRequests[] = |
| 42 L"HandleTopLevelRequests"; | 43 L"HandleTopLevelRequests"; |
| 43 | 44 |
| 44 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; | 45 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; |
| 45 | 46 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } | 515 } |
| 515 | 516 |
| 516 find_dialog_.ShowWindow(SW_SHOW); | 517 find_dialog_.ShowWindow(SW_SHOW); |
| 517 } | 518 } |
| 518 } | 519 } |
| 519 | 520 |
| 520 void ChromeActiveDocument::OnViewSource() { | 521 void ChromeActiveDocument::OnViewSource() { |
| 521 DCHECK(navigation_info_.url.is_valid()); | 522 DCHECK(navigation_info_.url.is_valid()); |
| 522 std::string url_to_open = "view-source:"; | 523 std::string url_to_open = "view-source:"; |
| 523 url_to_open += navigation_info_.url.spec(); | 524 url_to_open += navigation_info_.url.spec(); |
| 524 OnOpenURL(0, GURL(url_to_open), NEW_WINDOW); | 525 OnOpenURL(0, GURL(url_to_open), GURL(), NEW_WINDOW); |
| 525 } | 526 } |
| 526 | 527 |
| 527 void ChromeActiveDocument::OnDetermineSecurityZone(const GUID* cmd_group_guid, | 528 void ChromeActiveDocument::OnDetermineSecurityZone(const GUID* cmd_group_guid, |
| 528 DWORD command_id, | 529 DWORD command_id, |
| 529 DWORD cmd_exec_opt, | 530 DWORD cmd_exec_opt, |
| 530 VARIANT* in_args, | 531 VARIANT* in_args, |
| 531 VARIANT* out_args) { | 532 VARIANT* out_args) { |
| 532 if (out_args != NULL) { | 533 if (out_args != NULL) { |
| 533 out_args->vt = VT_UI4; | 534 out_args->vt = VT_UI4; |
| 534 out_args->ulVal = URLZONE_INTERNET; | 535 out_args->ulVal = URLZONE_INTERNET; |
| 535 } | 536 } |
| 536 } | 537 } |
| 537 | 538 |
| 538 void ChromeActiveDocument::OnOpenURL(int tab_handle, const GURL& url_to_open, | 539 void ChromeActiveDocument::OnOpenURL(int tab_handle, |
| 540 const GURL& url_to_open, |
| 541 const GURL& referrer, |
| 539 int open_disposition) { | 542 int open_disposition) { |
| 540 // If the disposition indicates that we should be opening the URL in the | 543 // If the disposition indicates that we should be opening the URL in the |
| 541 // current tab, then we can reuse the ChromeFrameAutomationClient instance | 544 // current tab, then we can reuse the ChromeFrameAutomationClient instance |
| 542 // maintained by the current ChromeActiveDocument instance. We cache this | 545 // maintained by the current ChromeActiveDocument instance. We cache this |
| 543 // instance so that it can be used by the new ChromeActiveDocument instance | 546 // instance so that it can be used by the new ChromeActiveDocument instance |
| 544 // which may be instantiated for handling the new URL. | 547 // which may be instantiated for handling the new URL. |
| 545 if (open_disposition == CURRENT_TAB) { | 548 if (open_disposition == CURRENT_TAB) { |
| 546 // Grab a reference to ensure that the document remains valid. | 549 // Grab a reference to ensure that the document remains valid. |
| 547 AddRef(); | 550 AddRef(); |
| 548 g_active_doc_cache.Set(this); | 551 g_active_doc_cache.Set(this); |
| 549 } | 552 } |
| 550 | 553 |
| 551 Base::OnOpenURL(tab_handle, url_to_open, open_disposition); | 554 Base::OnOpenURL(tab_handle, url_to_open, referrer, open_disposition); |
| 552 } | 555 } |
| 553 | 556 |
| 554 void ChromeActiveDocument::OnLoad(int tab_handle, const GURL& url) { | 557 void ChromeActiveDocument::OnLoad(int tab_handle, const GURL& url) { |
| 555 if (ready_state_ < READYSTATE_COMPLETE) { | 558 if (ready_state_ < READYSTATE_COMPLETE) { |
| 556 ready_state_ = READYSTATE_COMPLETE; | 559 ready_state_ = READYSTATE_COMPLETE; |
| 557 FireOnChanged(DISPID_READYSTATE); | 560 FireOnChanged(DISPID_READYSTATE); |
| 558 } | 561 } |
| 559 } | 562 } |
| 560 | 563 |
| 561 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { | 564 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 719 |
| 717 automation_client_->AttachExternalTab(external_tab_cookie); | 720 automation_client_->AttachExternalTab(external_tab_cookie); |
| 718 } else { | 721 } else { |
| 719 // Initiate navigation before launching chrome so that the url will be | 722 // Initiate navigation before launching chrome so that the url will be |
| 720 // cached and sent with launch settings. | 723 // cached and sent with launch settings. |
| 721 if (is_new_navigation) { | 724 if (is_new_navigation) { |
| 722 url_.Reset(::SysAllocString(url.c_str())); | 725 url_.Reset(::SysAllocString(url.c_str())); |
| 723 if (url_.Length()) { | 726 if (url_.Length()) { |
| 724 std::string utf8_url; | 727 std::string utf8_url; |
| 725 WideToUTF8(url_, url_.Length(), &utf8_url); | 728 WideToUTF8(url_, url_.Length(), &utf8_url); |
| 726 if (!automation_client_->InitiateNavigation(utf8_url, is_privileged_)) { | 729 |
| 730 std::string referrer; |
| 731 Bho* chrome_frame_bho = Bho::GetCurrentThreadBhoInstance(); |
| 732 DCHECK(chrome_frame_bho != NULL); |
| 733 if (chrome_frame_bho) { |
| 734 referrer = chrome_frame_bho->referrer(); |
| 735 } |
| 736 if (!automation_client_->InitiateNavigation(utf8_url, |
| 737 referrer, |
| 738 is_privileged_)) { |
| 727 DLOG(ERROR) << "Invalid URL: " << url; | 739 DLOG(ERROR) << "Invalid URL: " << url; |
| 728 Error(L"Invalid URL"); | 740 Error(L"Invalid URL"); |
| 729 url_.Reset(); | 741 url_.Reset(); |
| 730 return false; | 742 return false; |
| 731 } | 743 } |
| 732 | 744 |
| 733 DLOG(INFO) << "Url is " << url_; | 745 DLOG(INFO) << "Url is " << url_; |
| 734 } | 746 } |
| 735 } | 747 } |
| 736 } | 748 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 ScopedComPtr<IBrowserService> browser_service; | 808 ScopedComPtr<IBrowserService> browser_service; |
| 797 DoQueryService(SID_SShellBrowser, m_spClientSite, browser_service.Receive()); | 809 DoQueryService(SID_SShellBrowser, m_spClientSite, browser_service.Receive()); |
| 798 if (browser_service) { | 810 if (browser_service) { |
| 799 ScopedComPtr<ITravelLog> travel_log; | 811 ScopedComPtr<ITravelLog> travel_log; |
| 800 browser_service->GetTravelLog(travel_log.Receive()); | 812 browser_service->GetTravelLog(travel_log.Receive()); |
| 801 if (travel_log) { | 813 if (travel_log) { |
| 802 travel_log->Travel(browser_service, offset); | 814 travel_log->Travel(browser_service, offset); |
| 803 } | 815 } |
| 804 } | 816 } |
| 805 } | 817 } |
| OLD | NEW |