| 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 #include "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/stats_counters.h" |
| 13 #include "base/string16.h" | 14 #include "base/string16.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/autocomplete_history_manager.h" | 18 #include "chrome/browser/autocomplete_history_manager.h" |
| 18 #include "chrome/browser/autofill/autofill_manager.h" | 19 #include "chrome/browser/autofill/autofill_manager.h" |
| 19 #include "chrome/browser/blocked_content_container.h" | 20 #include "chrome/browser/blocked_content_container.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_model.h" | 21 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/browser_shutdown.h" | 23 #include "chrome/browser/browser_shutdown.h" |
| 23 #include "chrome/browser/character_encoding.h" | 24 #include "chrome/browser/character_encoding.h" |
| 25 #include "chrome/browser/child_process_security_policy.h" |
| 24 #include "chrome/browser/content_settings/content_settings_details.h" | 26 #include "chrome/browser/content_settings/content_settings_details.h" |
| 25 #include "chrome/browser/content_settings/host_content_settings_map.h" | 27 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 26 #include "chrome/browser/debugger/devtools_manager.h" | 28 #include "chrome/browser/debugger/devtools_manager.h" |
| 27 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
| 28 #include "chrome/browser/dom_operation_notification_details.h" | 30 #include "chrome/browser/dom_operation_notification_details.h" |
| 29 #include "chrome/browser/dom_ui/dom_ui.h" | 31 #include "chrome/browser/dom_ui/dom_ui.h" |
| 30 #include "chrome/browser/download/download_item_model.h" | 32 #include "chrome/browser/download/download_item_model.h" |
| 31 #include "chrome/browser/download/download_manager.h" | 33 #include "chrome/browser/download/download_manager.h" |
| 32 #include "chrome/browser/download/download_request_limiter.h" | 34 #include "chrome/browser/download/download_request_limiter.h" |
| 33 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
| 34 #include "chrome/browser/external_protocol_handler.h" | 36 #include "chrome/browser/external_protocol_handler.h" |
| 35 #include "chrome/browser/favicon_service.h" | 37 #include "chrome/browser/favicon_service.h" |
| 36 #include "chrome/browser/file_select_helper.h" | 38 #include "chrome/browser/file_select_helper.h" |
| 37 #include "chrome/browser/google/google_util.h" | 39 #include "chrome/browser/google/google_util.h" |
| 38 #include "chrome/browser/history/history.h" | 40 #include "chrome/browser/history/history.h" |
| 39 #include "chrome/browser/history/history_types.h" | 41 #include "chrome/browser/history/history_types.h" |
| 40 #include "chrome/browser/history/top_sites.h" | 42 #include "chrome/browser/history/top_sites.h" |
| 41 #include "chrome/browser/host_zoom_map.h" | 43 #include "chrome/browser/host_zoom_map.h" |
| 42 #include "chrome/browser/hung_renderer_dialog.h" | 44 #include "chrome/browser/hung_renderer_dialog.h" |
| 43 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" | 45 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" |
| 44 #include "chrome/browser/load_from_memory_cache_details.h" | 46 #include "chrome/browser/load_from_memory_cache_details.h" |
| 45 #include "chrome/browser/load_notification_details.h" | 47 #include "chrome/browser/load_notification_details.h" |
| 46 #include "chrome/browser/metrics/metric_event_duration_details.h" | 48 #include "chrome/browser/metrics/metric_event_duration_details.h" |
| 49 #include "chrome/browser/metrics/user_metrics.h" |
| 47 #include "chrome/browser/modal_html_dialog_delegate.h" | 50 #include "chrome/browser/modal_html_dialog_delegate.h" |
| 48 #include "chrome/browser/omnibox_search_hint.h" | 51 #include "chrome/browser/omnibox_search_hint.h" |
| 49 #include "chrome/browser/platform_util.h" | 52 #include "chrome/browser/platform_util.h" |
| 50 #include "chrome/browser/plugin_installer.h" | 53 #include "chrome/browser/plugin_installer.h" |
| 51 #include "chrome/browser/prefs/pref_service.h" | 54 #include "chrome/browser/prefs/pref_service.h" |
| 52 #include "chrome/browser/prerender/prerender_manager.h" | 55 #include "chrome/browser/prerender/prerender_manager.h" |
| 53 #include "chrome/browser/printing/print_preview_tab_controller.h" | 56 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 54 #include "chrome/browser/printing/print_view_manager.h" | 57 #include "chrome/browser/printing/print_view_manager.h" |
| 55 #include "chrome/browser/profiles/profile.h" | 58 #include "chrome/browser/profiles/profile.h" |
| 56 #include "chrome/browser/renderer_host/render_process_host.h" | 59 #include "chrome/browser/renderer_host/render_process_host.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, | 544 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, |
| 542 IDS_MINIMUM_FONT_SIZE); | 545 IDS_MINIMUM_FONT_SIZE); |
| 543 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, | 546 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, |
| 544 IDS_MINIMUM_LOGICAL_FONT_SIZE); | 547 IDS_MINIMUM_LOGICAL_FONT_SIZE); |
| 545 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector, | 548 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector, |
| 546 IDS_USES_UNIVERSAL_DETECTOR); | 549 IDS_USES_UNIVERSAL_DETECTOR); |
| 547 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, | 550 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, |
| 548 IDS_STATIC_ENCODING_LIST); | 551 IDS_STATIC_ENCODING_LIST); |
| 549 } | 552 } |
| 550 | 553 |
| 554 bool TabContents::OnMessageReceived(const IPC::Message& message) { |
| 555 bool handled = true; |
| 556 bool message_is_ok = true; |
| 557 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) |
| 558 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, |
| 559 OnDidStartProvisionalLoadForFrame) |
| 560 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, |
| 561 OnDidRedirectProvisionalLoad) |
| 562 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, |
| 563 OnDidFailProvisionalLoadWithError) |
| 564 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 565 OnDidLoadResourceFromMemoryCache) |
| 566 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, |
| 567 OnDidDisplayInsecureContent) |
| 568 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
| 569 OnDidRunInsecureContent) |
| 570 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
| 571 OnDocumentLoadedInFrame) |
| 572 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 573 IPC_MESSAGE_UNHANDLED(handled = false) |
| 574 IPC_END_MESSAGE_MAP_EX() |
| 575 |
| 576 if (!message_is_ok) { |
| 577 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 578 GetRenderProcessHost()->ReceivedBadMessage(); |
| 579 } |
| 580 |
| 581 return handled; |
| 582 } |
| 583 |
| 551 // Returns true if contains content rendered by an extension. | 584 // Returns true if contains content rendered by an extension. |
| 552 bool TabContents::HostsExtension() const { | 585 bool TabContents::HostsExtension() const { |
| 553 return GetURL().SchemeIs(chrome::kExtensionScheme); | 586 return GetURL().SchemeIs(chrome::kExtensionScheme); |
| 554 } | 587 } |
| 555 | 588 |
| 556 AutoFillManager* TabContents::GetAutoFillManager() { | 589 AutoFillManager* TabContents::GetAutoFillManager() { |
| 557 if (autofill_manager_.get() == NULL) | 590 if (autofill_manager_.get() == NULL) |
| 558 autofill_manager_.reset(new AutoFillManager(this)); | 591 autofill_manager_.reset(new AutoFillManager(this)); |
| 559 return autofill_manager_.get(); | 592 return autofill_manager_.get(); |
| 560 } | 593 } |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 if (!delegate_) | 1581 if (!delegate_) |
| 1549 return; | 1582 return; |
| 1550 | 1583 |
| 1551 NavigationEntry* active_entry = controller().GetActiveEntry(); | 1584 NavigationEntry* active_entry = controller().GetActiveEntry(); |
| 1552 if (!active_entry) | 1585 if (!active_entry) |
| 1553 return; | 1586 return; |
| 1554 | 1587 |
| 1555 delegate_->ViewSourceForTab(this, active_entry->url()); | 1588 delegate_->ViewSourceForTab(this, active_entry->url()); |
| 1556 } | 1589 } |
| 1557 | 1590 |
| 1591 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 1592 bool is_main_frame, |
| 1593 const GURL& url) { |
| 1594 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
| 1595 GURL validated_url(url); |
| 1596 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 1597 GetRenderProcessHost()->id(), &validated_url); |
| 1598 |
| 1599 ProvisionalLoadDetails details( |
| 1600 is_main_frame, |
| 1601 controller_.IsURLInPageNavigation(validated_url), |
| 1602 validated_url, std::string(), false, is_error_page, frame_id); |
| 1603 NotificationService::current()->Notify( |
| 1604 NotificationType::FRAME_PROVISIONAL_LOAD_START, |
| 1605 Source<NavigationController>(&controller_), |
| 1606 Details<ProvisionalLoadDetails>(&details)); |
| 1607 if (is_main_frame) { |
| 1608 // If we're displaying a network error page do not reset the content |
| 1609 // settings delegate's cookies so the user has a chance to modify cookie |
| 1610 // settings. |
| 1611 if (!is_error_page) |
| 1612 content_settings_delegate_->ClearCookieSpecificContentSettings(); |
| 1613 content_settings_delegate_->ClearGeolocationContentSettings(); |
| 1614 } |
| 1615 } |
| 1616 |
| 1617 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, |
| 1618 const GURL& source_url, |
| 1619 const GURL& target_url) { |
| 1620 NavigationEntry* entry; |
| 1621 if (page_id == -1) |
| 1622 entry = controller_.pending_entry(); |
| 1623 else |
| 1624 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); |
| 1625 if (!entry || entry->url() != source_url) |
| 1626 return; |
| 1627 entry->set_url(target_url); |
| 1628 } |
| 1629 |
| 1630 void TabContents::OnDidFailProvisionalLoadWithError( |
| 1631 int64 frame_id, |
| 1632 bool is_main_frame, |
| 1633 int error_code, |
| 1634 const GURL& url, |
| 1635 bool showing_repost_interstitial) { |
| 1636 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() |
| 1637 << ", error_code: " << error_code |
| 1638 << " is_main_frame: " << is_main_frame |
| 1639 << " showing_repost_interstitial: " << showing_repost_interstitial |
| 1640 << " frame_id: " << frame_id; |
| 1641 GURL validated_url(url); |
| 1642 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 1643 GetRenderProcessHost()->id(), &validated_url); |
| 1644 |
| 1645 if (net::ERR_ABORTED == error_code) { |
| 1646 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
| 1647 // This means that the interstitial won't be torn down properly, which is |
| 1648 // bad. But if we have an interstitial, go back to another tab type, and |
| 1649 // then load the same interstitial again, we could end up getting the first |
| 1650 // interstitial's "failed" message (as a result of the cancel) when we're on |
| 1651 // the second one. |
| 1652 // |
| 1653 // We can't tell this apart, so we think we're tearing down the current page |
| 1654 // which will cause a crash later one. There is also some code in |
| 1655 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented |
| 1656 // out because of this problem. |
| 1657 // |
| 1658 // http://code.google.com/p/chromium/issues/detail?id=2855 |
| 1659 // Because this will not tear down the interstitial properly, if "back" is |
| 1660 // back to another tab type, the interstitial will still be somewhat alive |
| 1661 // in the previous tab type. If you navigate somewhere that activates the |
| 1662 // tab with the interstitial again, you'll see a flash before the new load |
| 1663 // commits of the interstitial page. |
| 1664 if (showing_interstitial_page()) { |
| 1665 LOG(WARNING) << "Discarding message during interstitial."; |
| 1666 return; |
| 1667 } |
| 1668 |
| 1669 // This will discard our pending entry if we cancelled the load (e.g., if we |
| 1670 // decided to download the file instead of load it). Only discard the |
| 1671 // pending entry if the URLs match, otherwise the user initiated a navigate |
| 1672 // before the page loaded so that the discard would discard the wrong entry. |
| 1673 NavigationEntry* pending_entry = controller_.pending_entry(); |
| 1674 if (pending_entry && pending_entry->url() == validated_url) { |
| 1675 controller_.DiscardNonCommittedEntries(); |
| 1676 // Update the URL display. |
| 1677 NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); |
| 1678 } |
| 1679 |
| 1680 render_manager_.RendererAbortedProvisionalLoad(render_view_host()); |
| 1681 } |
| 1682 |
| 1683 // Send out a notification that we failed a provisional load with an error. |
| 1684 ProvisionalLoadDetails details( |
| 1685 is_main_frame, controller_.IsURLInPageNavigation(validated_url), |
| 1686 validated_url, std::string(), false, false, frame_id); |
| 1687 details.set_error_code(error_code); |
| 1688 |
| 1689 NotificationService::current()->Notify( |
| 1690 NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
| 1691 Source<NavigationController>(&controller_), |
| 1692 Details<ProvisionalLoadDetails>(&details)); |
| 1693 } |
| 1694 |
| 1695 void TabContents::OnDidLoadResourceFromMemoryCache( |
| 1696 const GURL& url, |
| 1697 const std::string& frame_origin, |
| 1698 const std::string& main_frame_origin, |
| 1699 const std::string& security_info) { |
| 1700 static base::StatsCounter cache("WebKit.CacheHit"); |
| 1701 cache.Increment(); |
| 1702 |
| 1703 // Send out a notification that we loaded a resource from our memory cache. |
| 1704 int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; |
| 1705 SSLManager::DeserializeSecurityInfo(security_info, |
| 1706 &cert_id, &cert_status, |
| 1707 &security_bits, |
| 1708 &connection_status); |
| 1709 LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, |
| 1710 GetRenderProcessHost()->id(), cert_id, |
| 1711 cert_status); |
| 1712 |
| 1713 NotificationService::current()->Notify( |
| 1714 NotificationType::LOAD_FROM_MEMORY_CACHE, |
| 1715 Source<NavigationController>(&controller_), |
| 1716 Details<LoadFromMemoryCacheDetails>(&details)); |
| 1717 } |
| 1718 |
| 1719 void TabContents::OnDidDisplayInsecureContent() { |
| 1720 displayed_insecure_content_ = true; |
| 1721 SSLManager::NotifySSLInternalStateChanged(); |
| 1722 } |
| 1723 |
| 1724 void TabContents::OnDidRunInsecureContent( |
| 1725 const std::string& security_origin) { |
| 1726 controller_.ssl_manager()->DidRunInsecureContent(security_origin); |
| 1727 } |
| 1728 |
| 1729 void TabContents::OnDocumentLoadedInFrame(int64 frame_id) { |
| 1730 controller_.DocumentLoadedInFrame(); |
| 1731 NotificationService::current()->Notify( |
| 1732 NotificationType::FRAME_DOM_CONTENT_LOADED, |
| 1733 Source<NavigationController>(&controller_), |
| 1734 Details<int64>(&frame_id)); |
| 1735 } |
| 1736 |
| 1737 void TabContents::OnDidFinishLoad(int64 frame_id) { |
| 1738 NotificationService::current()->Notify( |
| 1739 NotificationType::FRAME_DID_FINISH_LOAD, |
| 1740 Source<NavigationController>(&controller_), |
| 1741 Details<int64>(&frame_id)); |
| 1742 } |
| 1743 |
| 1558 // Notifies the RenderWidgetHost instance about the fact that the page is | 1744 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 1559 // loading, or done loading and calls the base implementation. | 1745 // loading, or done loading and calls the base implementation. |
| 1560 void TabContents::SetIsLoading(bool is_loading, | 1746 void TabContents::SetIsLoading(bool is_loading, |
| 1561 LoadNotificationDetails* details) { | 1747 LoadNotificationDetails* details) { |
| 1562 if (is_loading == is_loading_) | 1748 if (is_loading == is_loading_) |
| 1563 return; | 1749 return; |
| 1564 | 1750 |
| 1565 if (!is_loading) { | 1751 if (!is_loading) { |
| 1566 load_state_ = net::LOAD_STATE_IDLE; | 1752 load_state_ = net::LOAD_STATE_IDLE; |
| 1567 load_state_host_.clear(); | 1753 load_state_host_.clear(); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 const std::vector<std::string>& suggestions) { | 2368 const std::vector<std::string>& suggestions) { |
| 2183 if (delegate()) | 2369 if (delegate()) |
| 2184 delegate()->OnSetSuggestions(page_id, suggestions); | 2370 delegate()->OnSetSuggestions(page_id, suggestions); |
| 2185 } | 2371 } |
| 2186 | 2372 |
| 2187 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { | 2373 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { |
| 2188 if (delegate()) | 2374 if (delegate()) |
| 2189 delegate()->OnInstantSupportDetermined(page_id, result); | 2375 delegate()->OnInstantSupportDetermined(page_id, result); |
| 2190 } | 2376 } |
| 2191 | 2377 |
| 2192 void TabContents::DidStartProvisionalLoadForFrame( | |
| 2193 RenderViewHost* render_view_host, | |
| 2194 int64 frame_id, | |
| 2195 bool is_main_frame, | |
| 2196 bool is_error_page, | |
| 2197 const GURL& url) { | |
| 2198 ProvisionalLoadDetails details(is_main_frame, | |
| 2199 controller_.IsURLInPageNavigation(url), | |
| 2200 url, std::string(), false, | |
| 2201 is_error_page, frame_id); | |
| 2202 NotificationService::current()->Notify( | |
| 2203 NotificationType::FRAME_PROVISIONAL_LOAD_START, | |
| 2204 Source<NavigationController>(&controller_), | |
| 2205 Details<ProvisionalLoadDetails>(&details)); | |
| 2206 if (is_main_frame) { | |
| 2207 // If we're displaying a network error page do not reset the content | |
| 2208 // settings delegate's cookies so the user has a chance to modify cookie | |
| 2209 // settings. | |
| 2210 if (!is_error_page) | |
| 2211 content_settings_delegate_->ClearCookieSpecificContentSettings(); | |
| 2212 content_settings_delegate_->ClearGeolocationContentSettings(); | |
| 2213 } | |
| 2214 } | |
| 2215 | |
| 2216 void TabContents::DidStartReceivingResourceResponse( | |
| 2217 const ResourceRequestDetails& details) { | |
| 2218 NotificationService::current()->Notify( | |
| 2219 NotificationType::RESOURCE_RESPONSE_STARTED, | |
| 2220 Source<NavigationController>(&controller()), | |
| 2221 Details<const ResourceRequestDetails>(&details)); | |
| 2222 } | |
| 2223 | |
| 2224 void TabContents::DidRedirectResource( | |
| 2225 const ResourceRedirectDetails& details) { | |
| 2226 NotificationService::current()->Notify( | |
| 2227 NotificationType::RESOURCE_RECEIVED_REDIRECT, | |
| 2228 Source<NavigationController>(&controller()), | |
| 2229 Details<const ResourceRequestDetails>(&details)); | |
| 2230 } | |
| 2231 | |
| 2232 void TabContents::DidLoadResourceFromMemoryCache( | |
| 2233 const GURL& url, | |
| 2234 const std::string& frame_origin, | |
| 2235 const std::string& main_frame_origin, | |
| 2236 const std::string& security_info) { | |
| 2237 // Send out a notification that we loaded a resource from our memory cache. | |
| 2238 int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; | |
| 2239 SSLManager::DeserializeSecurityInfo(security_info, | |
| 2240 &cert_id, &cert_status, | |
| 2241 &security_bits, | |
| 2242 &connection_status); | |
| 2243 LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, | |
| 2244 GetRenderProcessHost()->id(), cert_id, | |
| 2245 cert_status); | |
| 2246 | |
| 2247 NotificationService::current()->Notify( | |
| 2248 NotificationType::LOAD_FROM_MEMORY_CACHE, | |
| 2249 Source<NavigationController>(&controller_), | |
| 2250 Details<LoadFromMemoryCacheDetails>(&details)); | |
| 2251 } | |
| 2252 | |
| 2253 void TabContents::DidDisplayInsecureContent() { | |
| 2254 displayed_insecure_content_ = true; | |
| 2255 SSLManager::NotifySSLInternalStateChanged(); | |
| 2256 } | |
| 2257 | |
| 2258 void TabContents::DidRunInsecureContent(const std::string& security_origin) { | |
| 2259 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | |
| 2260 } | |
| 2261 | |
| 2262 void TabContents::DidFailProvisionalLoadWithError( | |
| 2263 RenderViewHost* render_view_host, | |
| 2264 int64 frame_id, | |
| 2265 bool is_main_frame, | |
| 2266 int error_code, | |
| 2267 const GURL& url, | |
| 2268 bool showing_repost_interstitial) { | |
| 2269 if (net::ERR_ABORTED == error_code) { | |
| 2270 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | |
| 2271 // This means that the interstitial won't be torn down properly, which is | |
| 2272 // bad. But if we have an interstitial, go back to another tab type, and | |
| 2273 // then load the same interstitial again, we could end up getting the first | |
| 2274 // interstitial's "failed" message (as a result of the cancel) when we're on | |
| 2275 // the second one. | |
| 2276 // | |
| 2277 // We can't tell this apart, so we think we're tearing down the current page | |
| 2278 // which will cause a crash later one. There is also some code in | |
| 2279 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented | |
| 2280 // out because of this problem. | |
| 2281 // | |
| 2282 // http://code.google.com/p/chromium/issues/detail?id=2855 | |
| 2283 // Because this will not tear down the interstitial properly, if "back" is | |
| 2284 // back to another tab type, the interstitial will still be somewhat alive | |
| 2285 // in the previous tab type. If you navigate somewhere that activates the | |
| 2286 // tab with the interstitial again, you'll see a flash before the new load | |
| 2287 // commits of the interstitial page. | |
| 2288 if (showing_interstitial_page()) { | |
| 2289 LOG(WARNING) << "Discarding message during interstitial."; | |
| 2290 return; | |
| 2291 } | |
| 2292 | |
| 2293 // This will discard our pending entry if we cancelled the load (e.g., if we | |
| 2294 // decided to download the file instead of load it). Only discard the | |
| 2295 // pending entry if the URLs match, otherwise the user initiated a navigate | |
| 2296 // before the page loaded so that the discard would discard the wrong entry. | |
| 2297 NavigationEntry* pending_entry = controller_.pending_entry(); | |
| 2298 if (pending_entry && pending_entry->url() == url) { | |
| 2299 controller_.DiscardNonCommittedEntries(); | |
| 2300 // Update the URL display. | |
| 2301 NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); | |
| 2302 } | |
| 2303 | |
| 2304 render_manager_.RendererAbortedProvisionalLoad(render_view_host); | |
| 2305 } | |
| 2306 | |
| 2307 // Send out a notification that we failed a provisional load with an error. | |
| 2308 ProvisionalLoadDetails details(is_main_frame, | |
| 2309 controller_.IsURLInPageNavigation(url), | |
| 2310 url, std::string(), false, false, frame_id); | |
| 2311 details.set_error_code(error_code); | |
| 2312 | |
| 2313 NotificationService::current()->Notify( | |
| 2314 NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, | |
| 2315 Source<NavigationController>(&controller_), | |
| 2316 Details<ProvisionalLoadDetails>(&details)); | |
| 2317 } | |
| 2318 | |
| 2319 void TabContents::DocumentLoadedInFrame(int64 frame_id) { | |
| 2320 controller_.DocumentLoadedInFrame(); | |
| 2321 NotificationService::current()->Notify( | |
| 2322 NotificationType::FRAME_DOM_CONTENT_LOADED, | |
| 2323 Source<NavigationController>(&controller_), | |
| 2324 Details<int64>(&frame_id)); | |
| 2325 } | |
| 2326 | |
| 2327 void TabContents::DidFinishLoad(int64 frame_id) { | |
| 2328 NotificationService::current()->Notify( | |
| 2329 NotificationType::FRAME_DID_FINISH_LOAD, | |
| 2330 Source<NavigationController>(&controller_), | |
| 2331 Details<int64>(&frame_id)); | |
| 2332 } | |
| 2333 | |
| 2334 void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { | 2378 void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { |
| 2335 if (delegate_) | 2379 if (delegate_) |
| 2336 delegate_->OnContentSettingsChange(this); | 2380 delegate_->OnContentSettingsChange(this); |
| 2337 } | 2381 } |
| 2338 | 2382 |
| 2339 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { | 2383 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { |
| 2340 return view_.get(); | 2384 return view_.get(); |
| 2341 } | 2385 } |
| 2342 | 2386 |
| 2343 RenderViewHostDelegate::RendererManagement* | 2387 RenderViewHostDelegate::RendererManagement* |
| 2344 TabContents::GetRendererManagementDelegate() { | 2388 TabContents::GetRendererManagementDelegate() { |
| 2345 return &render_manager_; | 2389 return &render_manager_; |
| 2346 } | 2390 } |
| 2347 | 2391 |
| 2348 RenderViewHostDelegate::BrowserIntegration* | 2392 RenderViewHostDelegate::BrowserIntegration* |
| 2349 TabContents::GetBrowserIntegrationDelegate() { | 2393 TabContents::GetBrowserIntegrationDelegate() { |
| 2350 return this; | 2394 return this; |
| 2351 } | 2395 } |
| 2352 | 2396 |
| 2353 RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() { | |
| 2354 return this; | |
| 2355 } | |
| 2356 | |
| 2357 RenderViewHostDelegate::ContentSettings* | 2397 RenderViewHostDelegate::ContentSettings* |
| 2358 TabContents::GetContentSettingsDelegate() { | 2398 TabContents::GetContentSettingsDelegate() { |
| 2359 return content_settings_delegate_.get(); | 2399 return content_settings_delegate_.get(); |
| 2360 } | 2400 } |
| 2361 | 2401 |
| 2362 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { | 2402 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { |
| 2363 return save_package_.get(); // May be NULL, but we can return NULL. | 2403 return save_package_.get(); // May be NULL, but we can return NULL. |
| 2364 } | 2404 } |
| 2365 | 2405 |
| 2366 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { | 2406 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2766 | 2806 |
| 2767 void TabContents::DocumentOnLoadCompletedInMainFrame( | 2807 void TabContents::DocumentOnLoadCompletedInMainFrame( |
| 2768 RenderViewHost* render_view_host, | 2808 RenderViewHost* render_view_host, |
| 2769 int32 page_id) { | 2809 int32 page_id) { |
| 2770 NotificationService::current()->Notify( | 2810 NotificationService::current()->Notify( |
| 2771 NotificationType::LOAD_COMPLETED_MAIN_FRAME, | 2811 NotificationType::LOAD_COMPLETED_MAIN_FRAME, |
| 2772 Source<TabContents>(this), | 2812 Source<TabContents>(this), |
| 2773 Details<int>(&page_id)); | 2813 Details<int>(&page_id)); |
| 2774 } | 2814 } |
| 2775 | 2815 |
| 2776 void TabContents::DidRedirectProvisionalLoad(int32 page_id, | |
| 2777 const GURL& source_url, | |
| 2778 const GURL& target_url) { | |
| 2779 NavigationEntry* entry; | |
| 2780 if (page_id == -1) | |
| 2781 entry = controller_.pending_entry(); | |
| 2782 else | |
| 2783 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); | |
| 2784 if (!entry || entry->url() != source_url) | |
| 2785 return; | |
| 2786 entry->set_url(target_url); | |
| 2787 } | |
| 2788 | |
| 2789 void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, | 2816 void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, |
| 2790 WindowOpenDisposition disposition) { | 2817 WindowOpenDisposition disposition) { |
| 2791 if (render_manager_.dom_ui()) { | 2818 if (render_manager_.dom_ui()) { |
| 2792 // When we're a DOM UI, it will provide a page transition type for us (this | 2819 // When we're a DOM UI, it will provide a page transition type for us (this |
| 2793 // is so the new tab page can specify AUTO_BOOKMARK for automatically | 2820 // is so the new tab page can specify AUTO_BOOKMARK for automatically |
| 2794 // generated suggestions). | 2821 // generated suggestions). |
| 2795 // | 2822 // |
| 2796 // Note also that we hide the referrer for DOM UI pages. We don't really | 2823 // Note also that we hide the referrer for DOM UI pages. We don't really |
| 2797 // want web sites to see a referrer of "chrome://blah" (and some | 2824 // want web sites to see a referrer of "chrome://blah" (and some |
| 2798 // chrome: URLs might have search terms or other stuff we don't want to | 2825 // chrome: URLs might have search terms or other stuff we don't want to |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3339 } | 3366 } |
| 3340 | 3367 |
| 3341 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3368 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 3342 render_manager_.SwapInRenderViewHost(rvh); | 3369 render_manager_.SwapInRenderViewHost(rvh); |
| 3343 } | 3370 } |
| 3344 | 3371 |
| 3345 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3372 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3346 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3373 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3347 rwh_view->SetSize(view()->GetContainerSize()); | 3374 rwh_view->SetSize(view()->GetContainerSize()); |
| 3348 } | 3375 } |
| OLD | NEW |