| 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 <initguid.h> | 10 #include <initguid.h> |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 return S_OK; | 465 return S_OK; |
| 466 } | 466 } |
| 467 | 467 |
| 468 void ChromeActiveDocument::OnNavigationStateChanged(int tab_handle, int flags, | 468 void ChromeActiveDocument::OnNavigationStateChanged(int tab_handle, int flags, |
| 469 const IPC::NavigationInfo& nav_info) { | 469 const IPC::NavigationInfo& nav_info) { |
| 470 // TODO(joshia): handle INVALIDATE_TAB,INVALIDATE_LOAD etc. | 470 // TODO(joshia): handle INVALIDATE_TAB,INVALIDATE_LOAD etc. |
| 471 DLOG(INFO) << __FUNCTION__ << std::endl << " Flags: " << flags | 471 DLOG(INFO) << __FUNCTION__ << std::endl << " Flags: " << flags |
| 472 << "Url: " << nav_info.url << | 472 << "Url: " << nav_info.url << |
| 473 ", Title: " << nav_info.title << | 473 ", Title: " << nav_info.title << |
| 474 ", Type: " << nav_info.navigation_type << ", Relative Offset: " << | 474 ", Type: " << nav_info.navigation_type << ", Relative Offset: " << |
| 475 nav_info.relative_offset << ", Index: " << nav_info.navigation_index;; | 475 nav_info.relative_offset << ", Index: " << nav_info.navigation_index; |
| 476 | 476 |
| 477 UpdateNavigationState(nav_info); | 477 UpdateNavigationState(nav_info); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void ChromeActiveDocument::OnUpdateTargetUrl(int tab_handle, | 480 void ChromeActiveDocument::OnUpdateTargetUrl(int tab_handle, |
| 481 const std::wstring& new_target_url) { | 481 const std::wstring& new_target_url) { |
| 482 if (in_place_frame_) { | 482 if (in_place_frame_) { |
| 483 in_place_frame_->SetStatusText(new_target_url.c_str()); | 483 in_place_frame_->SetStatusText(new_target_url.c_str()); |
| 484 } | 484 } |
| 485 } | 485 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 579 |
| 580 if (new_navigation_info.url.is_valid()) { | 580 if (new_navigation_info.url.is_valid()) { |
| 581 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); | 581 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); |
| 582 } | 582 } |
| 583 | 583 |
| 584 if (is_internal_navigation) { | 584 if (is_internal_navigation) { |
| 585 ScopedComPtr<IDocObjectService> doc_object_svc; | 585 ScopedComPtr<IDocObjectService> doc_object_svc; |
| 586 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; | 586 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; |
| 587 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, | 587 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, |
| 588 web_browser_events_svc.Receive()); | 588 web_browser_events_svc.Receive()); |
| 589 DCHECK(web_browser_events_svc); | 589 // web_browser_events_svc can be NULL on IE6. |
| 590 if (web_browser_events_svc) { | 590 if (web_browser_events_svc) { |
| 591 VARIANT_BOOL should_cancel = VARIANT_FALSE; | 591 VARIANT_BOOL should_cancel = VARIANT_FALSE; |
| 592 web_browser_events_svc->FireBeforeNavigate2Event(&should_cancel); | 592 web_browser_events_svc->FireBeforeNavigate2Event(&should_cancel); |
| 593 } | 593 } |
| 594 | 594 |
| 595 // We need to tell IE that we support navigation so that IE will query us | 595 // We need to tell IE that we support navigation so that IE will query us |
| 596 // for IPersistHistory and call GetPositionCookie to save our navigation | 596 // for IPersistHistory and call GetPositionCookie to save our navigation |
| 597 // index. | 597 // index. |
| 598 ScopedVariant html_window(static_cast<IUnknown*>( | 598 ScopedVariant html_window(static_cast<IUnknown*>( |
| 599 static_cast<IHTMLWindow2*>(this))); | 599 static_cast<IHTMLWindow2*>(this))); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 837 |
| 838 if (external_tab_cookie == 0) { | 838 if (external_tab_cookie == 0) { |
| 839 NOTREACHED() << "invalid url for attach tab: " << url; | 839 NOTREACHED() << "invalid url for attach tab: " << url; |
| 840 return false; | 840 return false; |
| 841 } | 841 } |
| 842 | 842 |
| 843 automation_client_->AttachExternalTab(external_tab_cookie); | 843 automation_client_->AttachExternalTab(external_tab_cookie); |
| 844 } else { | 844 } else { |
| 845 // Initiate navigation before launching chrome so that the url will be | 845 // Initiate navigation before launching chrome so that the url will be |
| 846 // cached and sent with launch settings. | 846 // cached and sent with launch settings. |
| 847 if (is_new_navigation) { | 847 url_.Reset(::SysAllocString(url.c_str())); |
| 848 url_.Reset(::SysAllocString(url.c_str())); | 848 if (url_.Length()) { |
| 849 if (url_.Length()) { | 849 std::string utf8_url; |
| 850 std::string utf8_url; | 850 WideToUTF8(url_, url_.Length(), &utf8_url); |
| 851 WideToUTF8(url_, url_.Length(), &utf8_url); | |
| 852 | 851 |
| 853 std::string referrer; | 852 std::string referrer; |
| 854 Bho* chrome_frame_bho = Bho::GetCurrentThreadBhoInstance(); | 853 Bho* chrome_frame_bho = Bho::GetCurrentThreadBhoInstance(); |
| 855 if (chrome_frame_bho) | 854 if (chrome_frame_bho) |
| 856 referrer = chrome_frame_bho->referrer(); | 855 referrer = chrome_frame_bho->referrer(); |
| 857 | 856 |
| 858 if (!automation_client_->InitiateNavigation(utf8_url, | 857 if (!automation_client_->InitiateNavigation(utf8_url, |
| 859 referrer, | 858 referrer, |
| 860 is_privileged_)) { | 859 is_privileged_)) { |
| 861 DLOG(ERROR) << "Invalid URL: " << url; | 860 DLOG(ERROR) << "Invalid URL: " << url; |
| 862 Error(L"Invalid URL"); | 861 Error(L"Invalid URL"); |
| 863 url_.Reset(); | 862 url_.Reset(); |
| 864 return false; | 863 return false; |
| 865 } | 864 } |
| 866 | 865 |
| 867 DLOG(INFO) << "Url is " << url_; | 866 DLOG(INFO) << "Url is " << url_; |
| 868 } | |
| 869 } | 867 } |
| 870 } | 868 } |
| 871 | 869 |
| 872 if (!is_automation_client_reused_ && | 870 if (!is_automation_client_reused_ && |
| 873 !InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate())) { | 871 !InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate())) { |
| 874 return false; | 872 return false; |
| 875 } | 873 } |
| 876 | 874 |
| 877 return true; | 875 return true; |
| 878 } | 876 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 hr = browser_service_local->GetTravelLog(travel_log); | 950 hr = browser_service_local->GetTravelLog(travel_log); |
| 953 DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " | 951 DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " |
| 954 << hr; | 952 << hr; |
| 955 } | 953 } |
| 956 | 954 |
| 957 if (browser_service) | 955 if (browser_service) |
| 958 *browser_service = browser_service_local.Detach(); | 956 *browser_service = browser_service_local.Detach(); |
| 959 | 957 |
| 960 return hr; | 958 return hr; |
| 961 } | 959 } |
| OLD | NEW |