Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 8549022: Define DevTools content API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed pfeldman's comments Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 //
103 // It is possible that we trigger a new navigation after we have received 104 // It is possible that we trigger a new navigation after we have received
104 // a SwapOut_ACK message but before the FrameNavigation has been confirmed. 105 // a SwapOut_ACK message but before the FrameNavigation has been confirmed.
105 // In this case the old RVH has been swapped out but the new one has not 106 // In this case the old RVH has been swapped out but the new one has not
106 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading 107 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading
107 // of the old RVH. 108 // of the old RVH.
108 109
110 using content::DevToolsAgentHost;
111 using content::DevToolsAgentHostRegistry;
112 using content::DevToolsManagerImpl;
113
109 namespace { 114 namespace {
110 115
111 // Amount of time we wait between when a key event is received and the renderer 116 // Amount of time we wait between when a key event is received and the renderer
112 // is queried for its state and pushed to the NavigationEntry. 117 // is queried for its state and pushed to the NavigationEntry.
113 const int kQueryStateDelay = 5000; 118 const int kQueryStateDelay = 5000;
114 119
115 const int kSyncWaitDelay = 40; 120 const int kSyncWaitDelay = 40;
116 121
117 static const char kDotGoogleDotCom[] = ".google.com"; 122 static const char kDotGoogleDotCom[] = ".google.com";
118 123
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> 612 bool is_allowed_in_web_ui_renderer = content::GetContentClient()->
608 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(), 613 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(),
609 entry.url()); 614 entry.url());
610 #if defined(OS_CHROMEOS) 615 #if defined(OS_CHROMEOS)
611 is_allowed_in_web_ui_renderer |= entry.url().SchemeIs(chrome::kDataScheme); 616 is_allowed_in_web_ui_renderer |= entry.url().SchemeIs(chrome::kDataScheme);
612 #endif 617 #endif
613 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || 618 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) ||
614 is_allowed_in_web_ui_renderer); 619 is_allowed_in_web_ui_renderer);
615 620
616 // Tell DevTools agent that it is attached prior to the navigation. 621 // Tell DevTools agent that it is attached prior to the navigation.
617 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 622 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry(
618 if (devtools_manager) { // NULL in unit tests. 623 render_view_host(),
619 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), 624 dest_render_view_host,
620 dest_render_view_host, 625 entry.url());
621 entry.url());
622 }
623 626
624 // Used for page load time metrics. 627 // Used for page load time metrics.
625 current_load_start_ = base::TimeTicks::Now(); 628 current_load_start_ = base::TimeTicks::Now();
626 629
627 // Navigate in the desired RenderViewHost. 630 // Navigate in the desired RenderViewHost.
628 ViewMsg_Navigate_Params navigate_params; 631 ViewMsg_Navigate_Params navigate_params;
629 MakeNavigateParams(entry, controller_, delegate_, reload_type, 632 MakeNavigateParams(entry, controller_, delegate_, reload_type,
630 &navigate_params); 633 &navigate_params);
631 dest_render_view_host->Navigate(navigate_params); 634 dest_render_view_host->Navigate(navigate_params);
632 635
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 1888
1886 void TabContents::RendererUnresponsive(RenderViewHost* rvh, 1889 void TabContents::RendererUnresponsive(RenderViewHost* rvh,
1887 bool is_during_unload) { 1890 bool is_during_unload) {
1888 // Don't show hung renderer dialog for a swapped out RVH. 1891 // Don't show hung renderer dialog for a swapped out RVH.
1889 if (rvh != render_view_host()) 1892 if (rvh != render_view_host())
1890 return; 1893 return;
1891 1894
1892 // Ignore renderer unresponsive event if debugger is attached to the tab 1895 // Ignore renderer unresponsive event if debugger is attached to the tab
1893 // since the event may be a result of the renderer sitting on a breakpoint. 1896 // since the event may be a result of the renderer sitting on a breakpoint.
1894 // See http://crbug.com/65458 1897 // See http://crbug.com/65458
1895 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 1898 DevToolsAgentHost* agent =
1896 if (devtools_manager && 1899 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh);
1897 devtools_manager->GetDevToolsClientHostFor(rvh) != NULL) 1900 if (agent &&
1901 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent))
1898 return; 1902 return;
1899 1903
1900 if (is_during_unload) { 1904 if (is_during_unload) {
1901 // Hang occurred while firing the beforeunload/unload handler. 1905 // Hang occurred while firing the beforeunload/unload handler.
1902 // Pretend the handler fired so tab closing continues as if it had. 1906 // Pretend the handler fired so tab closing continues as if it had.
1903 rvh->set_sudden_termination_allowed(true); 1907 rvh->set_sudden_termination_allowed(true);
1904 1908
1905 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) 1909 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer())
1906 return; 1910 return;
1907 1911
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2055 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2052 // Can be NULL during tests. 2056 // Can be NULL during tests.
2053 if (rwh_view) 2057 if (rwh_view)
2054 rwh_view->SetSize(view()->GetContainerSize()); 2058 rwh_view->SetSize(view()->GetContainerSize());
2055 } 2059 }
2056 2060
2057 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { 2061 bool TabContents::GotResponseToLockMouseRequest(bool allowed) {
2058 return render_view_host() ? 2062 return render_view_host() ?
2059 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; 2063 render_view_host()->GotResponseToLockMouseRequest(allowed) : false;
2060 } 2064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698