| 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 // 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 15 matching lines...) Expand all Loading... |
| 26 #include "base/string_tokenizer.h" | 26 #include "base/string_tokenizer.h" |
| 27 #include "base/string_util.h" | 27 #include "base/string_util.h" |
| 28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
| 29 #include "base/threading/thread_local.h" | 29 #include "base/threading/thread_local.h" |
| 30 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
| 31 #include "base/win/scoped_variant.h" | 31 #include "base/win/scoped_variant.h" |
| 32 #include "base/win/win_util.h" | 32 #include "base/win/win_util.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "chrome/app/chrome_command_ids.h" | 34 #include "chrome/app/chrome_command_ids.h" |
| 35 #include "chrome/app/chrome_dll_resource.h" | 35 #include "chrome/app/chrome_dll_resource.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents.h" |
| 36 #include "chrome/common/chrome_constants.h" | 37 #include "chrome/common/chrome_constants.h" |
| 37 #include "chrome/common/navigation_types.h" | 38 #include "chrome/common/navigation_types.h" |
| 38 #include "chrome/common/page_zoom.h" | 39 #include "chrome/common/page_zoom.h" |
| 39 #include "chrome/test/automation/browser_proxy.h" | 40 #include "chrome/test/automation/browser_proxy.h" |
| 40 #include "chrome/test/automation/tab_proxy.h" | 41 #include "chrome/test/automation/tab_proxy.h" |
| 41 #include "chrome_frame/bho.h" | 42 #include "chrome_frame/bho.h" |
| 42 #include "chrome_frame/bind_context_info.h" | 43 #include "chrome_frame/bind_context_info.h" |
| 43 #include "chrome_frame/buggy_bho_handling.h" | 44 #include "chrome_frame/buggy_bho_handling.h" |
| 44 #include "chrome_frame/crash_reporting/crash_metrics.h" | 45 #include "chrome_frame/crash_reporting/crash_metrics.h" |
| 45 #include "chrome_frame/utils.h" | 46 #include "chrome_frame/utils.h" |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 int flags, const NavigationInfo& nav_info) { | 621 int flags, const NavigationInfo& nav_info) { |
| 621 // TODO(joshia): handle INVALIDATE_TAB,INVALIDATE_LOAD etc. | 622 // TODO(joshia): handle INVALIDATE_TAB,INVALIDATE_LOAD etc. |
| 622 DVLOG(1) << __FUNCTION__ | 623 DVLOG(1) << __FUNCTION__ |
| 623 << "\n Flags: " << flags | 624 << "\n Flags: " << flags |
| 624 << ", Url: " << nav_info.url | 625 << ", Url: " << nav_info.url |
| 625 << ", Title: " << nav_info.title | 626 << ", Title: " << nav_info.title |
| 626 << ", Type: " << nav_info.navigation_type | 627 << ", Type: " << nav_info.navigation_type |
| 627 << ", Relative Offset: " << nav_info.relative_offset | 628 << ", Relative Offset: " << nav_info.relative_offset |
| 628 << ", Index: " << nav_info.navigation_index; | 629 << ", Index: " << nav_info.navigation_index; |
| 629 | 630 |
| 630 UpdateNavigationState(nav_info); | 631 UpdateNavigationState(nav_info, flags); |
| 631 } | 632 } |
| 632 | 633 |
| 633 void ChromeActiveDocument::OnUpdateTargetUrl( | 634 void ChromeActiveDocument::OnUpdateTargetUrl( |
| 634 const std::wstring& new_target_url) { | 635 const std::wstring& new_target_url) { |
| 635 if (in_place_frame_) | 636 if (in_place_frame_) |
| 636 in_place_frame_->SetStatusText(new_target_url.c_str()); | 637 in_place_frame_->SetStatusText(new_target_url.c_str()); |
| 637 } | 638 } |
| 638 | 639 |
| 639 bool IsFindAccelerator(const MSG& msg) { | 640 bool IsFindAccelerator(const MSG& msg) { |
| 640 // TODO(robertshield): This may not stand up to localization. Fix if this | 641 // TODO(robertshield): This may not stand up to localization. Fix if this |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 686 |
| 686 CrashMetricsReporter::GetInstance()->IncrementMetric( | 687 CrashMetricsReporter::GetInstance()->IncrementMetric( |
| 687 CrashMetricsReporter::CHROME_FRAME_NAVIGATION_COUNT); | 688 CrashMetricsReporter::CHROME_FRAME_NAVIGATION_COUNT); |
| 688 | 689 |
| 689 // This could be NULL if the active document instance is being destroyed. | 690 // This could be NULL if the active document instance is being destroyed. |
| 690 if (!m_spInPlaceSite) { | 691 if (!m_spInPlaceSite) { |
| 691 DVLOG(1) << __FUNCTION__ << "m_spInPlaceSite is NULL. Returning"; | 692 DVLOG(1) << __FUNCTION__ << "m_spInPlaceSite is NULL. Returning"; |
| 692 return; | 693 return; |
| 693 } | 694 } |
| 694 | 695 |
| 695 UpdateNavigationState(nav_info); | 696 UpdateNavigationState(nav_info, 0); |
| 696 } | 697 } |
| 697 | 698 |
| 698 void ChromeActiveDocument::OnCloseTab() { | 699 void ChromeActiveDocument::OnCloseTab() { |
| 699 // Base class will fire DIChromeFrameEvents::onclose. | 700 // Base class will fire DIChromeFrameEvents::onclose. |
| 700 BaseActiveX::OnCloseTab(); | 701 BaseActiveX::OnCloseTab(); |
| 701 | 702 |
| 702 // Close the container window. | 703 // Close the container window. |
| 703 ScopedComPtr<IWebBrowser2> web_browser2; | 704 ScopedComPtr<IWebBrowser2> web_browser2; |
| 704 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 705 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
| 705 if (web_browser2) | 706 if (web_browser2) |
| 706 web_browser2->Quit(); | 707 web_browser2->Quit(); |
| 707 } | 708 } |
| 708 | 709 |
| 709 void ChromeActiveDocument::UpdateNavigationState( | 710 void ChromeActiveDocument::UpdateNavigationState( |
| 710 const NavigationInfo& new_navigation_info) { | 711 const NavigationInfo& new_navigation_info, int flags) { |
| 711 HRESULT hr = S_OK; | 712 HRESULT hr = S_OK; |
| 712 bool is_title_changed = (navigation_info_.title != new_navigation_info.title); | 713 bool is_title_changed = (navigation_info_.title != new_navigation_info.title); |
| 713 bool is_ssl_state_changed = | 714 bool is_ssl_state_changed = |
| 714 (navigation_info_.security_style != new_navigation_info.security_style) || | 715 (navigation_info_.security_style != new_navigation_info.security_style) || |
| 715 (navigation_info_.displayed_insecure_content != | 716 (navigation_info_.displayed_insecure_content != |
| 716 new_navigation_info.displayed_insecure_content) || | 717 new_navigation_info.displayed_insecure_content) || |
| 717 (navigation_info_.ran_insecure_content != | 718 (navigation_info_.ran_insecure_content != |
| 718 new_navigation_info.ran_insecure_content); | 719 new_navigation_info.ran_insecure_content); |
| 719 | 720 |
| 720 if (is_ssl_state_changed) { | 721 if (is_ssl_state_changed) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 747 // We get notified after the fact, when navigations are initiated within | 748 // We get notified after the fact, when navigations are initiated within |
| 748 // Chrome via window.open calls. These navigations are handled by creating | 749 // Chrome via window.open calls. These navigations are handled by creating |
| 749 // an external tab container within chrome and then connecting to it from IE. | 750 // an external tab container within chrome and then connecting to it from IE. |
| 750 // We still want to update the address bar/history, etc, to ensure that | 751 // We still want to update the address bar/history, etc, to ensure that |
| 751 // the special URL used by Chrome to indicate this is updated correctly. | 752 // the special URL used by Chrome to indicate this is updated correctly. |
| 752 ChromeFrameUrl cf_url; | 753 ChromeFrameUrl cf_url; |
| 753 bool is_attach_external_tab_url = cf_url.Parse(std::wstring(url_)) && | 754 bool is_attach_external_tab_url = cf_url.Parse(std::wstring(url_)) && |
| 754 cf_url.attach_to_external_tab(); | 755 cf_url.attach_to_external_tab(); |
| 755 | 756 |
| 756 bool is_internal_navigation = | 757 bool is_internal_navigation = |
| 757 IsNewNavigation(new_navigation_info) || is_attach_external_tab_url; | 758 IsNewNavigation(new_navigation_info, flags) || is_attach_external_tab_url; |
| 758 | 759 |
| 759 if (new_navigation_info.url.is_valid()) | 760 if (new_navigation_info.url.is_valid()) |
| 760 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); | 761 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); |
| 761 | 762 |
| 762 if (is_internal_navigation) { | 763 if (is_internal_navigation) { |
| 763 ScopedComPtr<IDocObjectService> doc_object_svc; | 764 ScopedComPtr<IDocObjectService> doc_object_svc; |
| 764 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; | 765 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; |
| 765 | 766 |
| 766 buggy_bho::BuggyBhoTls bad_bho_tls; | 767 buggy_bho::BuggyBhoTls bad_bho_tls; |
| 767 if (GetConfigBool(true, kEnableBuggyBhoIntercept)) { | 768 if (GetConfigBool(true, kEnableBuggyBhoIntercept)) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 web_browser2->put_Height(dimensions_.height()); | 1358 web_browser2->put_Height(dimensions_.height()); |
| 1358 web_browser2->put_Left(dimensions_.x()); | 1359 web_browser2->put_Left(dimensions_.x()); |
| 1359 web_browser2->put_Top(dimensions_.y()); | 1360 web_browser2->put_Top(dimensions_.y()); |
| 1360 | 1361 |
| 1361 dimensions_.set_height(0); | 1362 dimensions_.set_height(0); |
| 1362 dimensions_.set_width(0); | 1363 dimensions_.set_width(0); |
| 1363 } | 1364 } |
| 1364 } | 1365 } |
| 1365 | 1366 |
| 1366 bool ChromeActiveDocument::IsNewNavigation( | 1367 bool ChromeActiveDocument::IsNewNavigation( |
| 1367 const NavigationInfo& new_navigation_info) const { | 1368 const NavigationInfo& new_navigation_info, int flags) const { |
| 1368 // A new navigation is typically an internal navigation which is initiated by | 1369 // A new navigation is typically an internal navigation which is initiated by |
| 1369 // the renderer(WebKit). Condition 1 below has to be true along with the | 1370 // the renderer(WebKit). Condition 1 below has to be true along with the |
| 1370 // any of the other conditions below. | 1371 // any of the other conditions below. |
| 1371 // 1. The navigation index is greater than 0 which means that a top level | 1372 // 1. The navigation notification flags passed in as the flags parameter |
| 1373 // is not INVALIDATE_LOAD which indicates that the loading state of the |
| 1374 // tab changed. |
| 1375 // 2. The navigation index is greater than 0 which means that a top level |
| 1372 // navigation was initiated on the current external tab. | 1376 // navigation was initiated on the current external tab. |
| 1373 // 2. The navigation type has changed. | 1377 // 3. The navigation type has changed. |
| 1374 // 3. The url or the referrer are different. | 1378 // 4. The url or the referrer are different. |
| 1379 if (flags == TabContents::INVALIDATE_LOAD) |
| 1380 return false; |
| 1381 |
| 1375 if (new_navigation_info.navigation_index <= 0) | 1382 if (new_navigation_info.navigation_index <= 0) |
| 1376 return false; | 1383 return false; |
| 1377 | 1384 |
| 1378 if (new_navigation_info.navigation_index == | 1385 if (new_navigation_info.navigation_index == |
| 1379 navigation_info_.navigation_index) | 1386 navigation_info_.navigation_index) |
| 1380 return false; | 1387 return false; |
| 1381 | 1388 |
| 1382 if (new_navigation_info.navigation_type != navigation_info_.navigation_type) | 1389 if (new_navigation_info.navigation_type != navigation_info_.navigation_type) |
| 1383 return true; | 1390 return true; |
| 1384 | 1391 |
| 1385 if (new_navigation_info.url != navigation_info_.url) | 1392 if (new_navigation_info.url != navigation_info_.url) |
| 1386 return true; | 1393 return true; |
| 1387 | 1394 |
| 1388 if (new_navigation_info.referrer != navigation_info_.referrer) | 1395 if (new_navigation_info.referrer != navigation_info_.referrer) |
| 1389 return true; | 1396 return true; |
| 1390 | 1397 |
| 1391 return false; | 1398 return false; |
| 1392 } | 1399 } |
| OLD | NEW |