| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "content/browser/browser_context.h" | 16 #include "content/browser/browser_context.h" |
| 17 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" |
| 18 #include "content/browser/debugger/devtools_manager.h" | 18 #include "content/browser/debugger/devtools_manager_impl.h" |
| 19 #include "content/browser/download/download_manager.h" | 19 #include "content/browser/download/download_manager.h" |
| 20 #include "content/browser/download/download_stats.h" | 20 #include "content/browser/download/download_stats.h" |
| 21 #include "content/browser/host_zoom_map.h" | 21 #include "content/browser/host_zoom_map.h" |
| 22 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 22 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
| 23 #include "content/browser/load_from_memory_cache_details.h" | 23 #include "content/browser/load_from_memory_cache_details.h" |
| 24 #include "content/browser/load_notification_details.h" | 24 #include "content/browser/load_notification_details.h" |
| 25 #include "content/browser/renderer_host/render_process_host_impl.h" | 25 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 26 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
| 27 #include "content/browser/renderer_host/render_widget_host_view.h" | 27 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 29 #include "content/browser/renderer_host/resource_request_details.h" | 29 #include "content/browser/renderer_host/resource_request_details.h" |
| 30 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
| 31 #include "content/browser/tab_contents/interstitial_page.h" | 31 #include "content/browser/tab_contents/interstitial_page.h" |
| 32 #include "content/browser/tab_contents/navigation_details.h" | 32 #include "content/browser/tab_contents/navigation_details.h" |
| 33 #include "content/browser/tab_contents/navigation_entry.h" | 33 #include "content/browser/tab_contents/navigation_entry.h" |
| 34 #include "content/browser/tab_contents/provisional_load_details.h" | 34 #include "content/browser/tab_contents/provisional_load_details.h" |
| 35 #include "content/browser/tab_contents/tab_contents_delegate.h" | 35 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 36 #include "content/browser/tab_contents/tab_contents_observer.h" | 36 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 37 #include "content/browser/tab_contents/tab_contents_view.h" | 37 #include "content/browser/tab_contents/tab_contents_view.h" |
| 38 #include "content/browser/tab_contents/title_updated_details.h" | 38 #include "content/browser/tab_contents/title_updated_details.h" |
| 39 #include "content/browser/user_metrics.h" | 39 #include "content/browser/user_metrics.h" |
| 40 #include "content/browser/webui/web_ui_factory.h" | 40 #include "content/browser/webui/web_ui_factory.h" |
| 41 #include "content/common/intents_messages.h" | 41 #include "content/common/intents_messages.h" |
| 42 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
| 43 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/devtools/devtools_agent_host_registry.h" |
| 44 #include "content/public/browser/navigation_types.h" | 45 #include "content/public/browser/navigation_types.h" |
| 45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/common/bindings_policy.h" | 47 #include "content/public/common/bindings_policy.h" |
| 47 #include "content/public/common/content_constants.h" | 48 #include "content/public/common/content_constants.h" |
| 48 #include "content/public/common/content_restriction.h" | 49 #include "content/public/common/content_restriction.h" |
| 49 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
| 50 #include "net/base/net_util.h" | 51 #include "net/base/net_util.h" |
| 51 #include "net/url_request/url_request_context_getter.h" | 52 #include "net/url_request/url_request_context_getter.h" |
| 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 53 #include "ui/gfx/codec/png_codec.h" | 54 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to | 94 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to |
| 94 // the ResourceDispatcherHost, who unpauses the response. Data is then sent | 95 // the ResourceDispatcherHost, who unpauses the response. Data is then sent |
| 95 // to the pending RVH. | 96 // to the pending RVH. |
| 96 // - The pending renderer sends a FrameNavigate message that invokes the | 97 // - The pending renderer sends a FrameNavigate message that invokes the |
| 97 // DidNavigate method. This replaces the current RVH with the | 98 // DidNavigate method. This replaces the current RVH with the |
| 98 // pending RVH. | 99 // pending RVH. |
| 99 // - The previous renderer is kept swapped out in RenderViewHostManager in case | 100 // - The previous renderer is kept swapped out in RenderViewHostManager in case |
| 100 // the user goes back. The process only stays live if another tab is using | 101 // the user goes back. The process only stays live if another tab is using |
| 101 // it, but if so, the existing frame relationships will be maintained. | 102 // it, but if so, the existing frame relationships will be maintained. |
| 102 | 103 |
| 104 using content::DevToolsAgentHost; |
| 105 using content::DevToolsAgentHostRegistry; |
| 106 using content::DevToolsManagerImpl; |
| 107 |
| 103 namespace { | 108 namespace { |
| 104 | 109 |
| 105 // Amount of time we wait between when a key event is received and the renderer | 110 // Amount of time we wait between when a key event is received and the renderer |
| 106 // is queried for its state and pushed to the NavigationEntry. | 111 // is queried for its state and pushed to the NavigationEntry. |
| 107 const int kQueryStateDelay = 5000; | 112 const int kQueryStateDelay = 5000; |
| 108 | 113 |
| 109 const int kSyncWaitDelay = 40; | 114 const int kSyncWaitDelay = 40; |
| 110 | 115 |
| 111 static const char kDotGoogleDotCom[] = ".google.com"; | 116 static const char kDotGoogleDotCom[] = ".google.com"; |
| 112 | 117 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> | 606 bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> |
| 602 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(), | 607 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(), |
| 603 entry.url()); | 608 entry.url()); |
| 604 #if defined(OS_CHROMEOS) | 609 #if defined(OS_CHROMEOS) |
| 605 is_allowed_in_web_ui_renderer |= entry.url().SchemeIs(chrome::kDataScheme); | 610 is_allowed_in_web_ui_renderer |= entry.url().SchemeIs(chrome::kDataScheme); |
| 606 #endif | 611 #endif |
| 607 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || | 612 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || |
| 608 is_allowed_in_web_ui_renderer); | 613 is_allowed_in_web_ui_renderer); |
| 609 | 614 |
| 610 // Tell DevTools agent that it is attached prior to the navigation. | 615 // Tell DevTools agent that it is attached prior to the navigation. |
| 611 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 616 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( |
| 612 if (devtools_manager) { // NULL in unit tests. | 617 render_view_host(), |
| 613 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 618 dest_render_view_host, |
| 614 dest_render_view_host, | 619 entry.url()); |
| 615 entry.url()); | |
| 616 } | |
| 617 | 620 |
| 618 // Used for page load time metrics. | 621 // Used for page load time metrics. |
| 619 current_load_start_ = base::TimeTicks::Now(); | 622 current_load_start_ = base::TimeTicks::Now(); |
| 620 | 623 |
| 621 // Navigate in the desired RenderViewHost. | 624 // Navigate in the desired RenderViewHost. |
| 622 ViewMsg_Navigate_Params navigate_params; | 625 ViewMsg_Navigate_Params navigate_params; |
| 623 MakeNavigateParams(entry, controller_, delegate_, reload_type, | 626 MakeNavigateParams(entry, controller_, delegate_, reload_type, |
| 624 &navigate_params); | 627 &navigate_params); |
| 625 dest_render_view_host->Navigate(navigate_params); | 628 dest_render_view_host->Navigate(navigate_params); |
| 626 | 629 |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 | 1873 |
| 1871 void TabContents::RendererUnresponsive(RenderViewHost* rvh, | 1874 void TabContents::RendererUnresponsive(RenderViewHost* rvh, |
| 1872 bool is_during_unload) { | 1875 bool is_during_unload) { |
| 1873 // Don't show hung renderer dialog for a swapped out RVH. | 1876 // Don't show hung renderer dialog for a swapped out RVH. |
| 1874 if (rvh != render_view_host()) | 1877 if (rvh != render_view_host()) |
| 1875 return; | 1878 return; |
| 1876 | 1879 |
| 1877 // Ignore renderer unresponsive event if debugger is attached to the tab | 1880 // Ignore renderer unresponsive event if debugger is attached to the tab |
| 1878 // since the event may be a result of the renderer sitting on a breakpoint. | 1881 // since the event may be a result of the renderer sitting on a breakpoint. |
| 1879 // See http://crbug.com/65458 | 1882 // See http://crbug.com/65458 |
| 1880 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 1883 DevToolsAgentHost* agent = |
| 1881 if (devtools_manager && | 1884 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); |
| 1882 devtools_manager->GetDevToolsClientHostFor(rvh) != NULL) | 1885 if (agent && |
| 1886 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) |
| 1883 return; | 1887 return; |
| 1884 | 1888 |
| 1885 if (is_during_unload) { | 1889 if (is_during_unload) { |
| 1886 // Hang occurred while firing the beforeunload/unload handler. | 1890 // Hang occurred while firing the beforeunload/unload handler. |
| 1887 // Pretend the handler fired so tab closing continues as if it had. | 1891 // Pretend the handler fired so tab closing continues as if it had. |
| 1888 rvh->set_sudden_termination_allowed(true); | 1892 rvh->set_sudden_termination_allowed(true); |
| 1889 | 1893 |
| 1890 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) | 1894 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) |
| 1891 return; | 1895 return; |
| 1892 | 1896 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 | 2034 |
| 2031 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2035 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2032 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2036 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2033 rwh_view->SetSize(view()->GetContainerSize()); | 2037 rwh_view->SetSize(view()->GetContainerSize()); |
| 2034 } | 2038 } |
| 2035 | 2039 |
| 2036 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2040 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
| 2037 return render_view_host() ? | 2041 return render_view_host() ? |
| 2038 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2042 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
| 2039 } | 2043 } |
| OLD | NEW |