OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/browser/host_zoom_map_impl.h" | 30 #include "content/browser/host_zoom_map_impl.h" |
31 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 31 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 32 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
33 #include "content/browser/renderer_host/render_process_host_impl.h" | 33 #include "content/browser/renderer_host/render_process_host_impl.h" |
34 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
36 #include "content/browser/site_instance_impl.h" | 36 #include "content/browser/site_instance_impl.h" |
37 #include "content/browser/web_contents/interstitial_page_impl.h" | 37 #include "content/browser/web_contents/interstitial_page_impl.h" |
38 #include "content/browser/web_contents/navigation_entry_impl.h" | 38 #include "content/browser/web_contents/navigation_entry_impl.h" |
39 #include "content/browser/web_contents/web_contents_view_guest.h" | 39 #include "content/browser/web_contents/web_contents_view_guest.h" |
| 40 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
40 #include "content/browser/webui/web_ui_impl.h" | 41 #include "content/browser/webui/web_ui_impl.h" |
41 #include "content/common/browser_plugin_messages.h" | 42 #include "content/common/browser_plugin_messages.h" |
42 #include "content/common/icon_messages.h" | 43 #include "content/common/icon_messages.h" |
43 #include "content/common/intents_messages.h" | 44 #include "content/common/intents_messages.h" |
44 #include "content/common/ssl_status_serialization.h" | 45 #include "content/common/ssl_status_serialization.h" |
45 #include "content/common/view_messages.h" | 46 #include "content/common/view_messages.h" |
46 #include "content/port/browser/render_view_host_delegate_view.h" | 47 #include "content/port/browser/render_view_host_delegate_view.h" |
47 #include "content/port/browser/render_widget_host_view_port.h" | 48 #include "content/port/browser/render_widget_host_view_port.h" |
48 #include "content/public/browser/browser_context.h" | 49 #include "content/public/browser/browser_context.h" |
49 #include "content/public/browser/color_chooser.h" | 50 #include "content/public/browser/color_chooser.h" |
50 #include "content/public/browser/compositor_util.h" | 51 #include "content/public/browser/compositor_util.h" |
51 #include "content/public/browser/content_browser_client.h" | 52 #include "content/public/browser/content_browser_client.h" |
52 #include "content/public/browser/devtools_agent_host.h" | 53 #include "content/public/browser/devtools_agent_host.h" |
53 #include "content/public/browser/download_manager.h" | 54 #include "content/public/browser/download_manager.h" |
54 #include "content/public/browser/download_url_parameters.h" | 55 #include "content/public/browser/download_url_parameters.h" |
55 #include "content/public/browser/invalidate_type.h" | 56 #include "content/public/browser/invalidate_type.h" |
56 #include "content/public/browser/javascript_dialogs.h" | 57 #include "content/public/browser/javascript_dialogs.h" |
57 #include "content/public/browser/load_from_memory_cache_details.h" | 58 #include "content/public/browser/load_from_memory_cache_details.h" |
58 #include "content/public/browser/load_notification_details.h" | 59 #include "content/public/browser/load_notification_details.h" |
59 #include "content/public/browser/navigation_details.h" | 60 #include "content/public/browser/navigation_details.h" |
60 #include "content/public/browser/notification_details.h" | 61 #include "content/public/browser/notification_details.h" |
61 #include "content/public/browser/notification_service.h" | 62 #include "content/public/browser/notification_service.h" |
62 #include "content/public/browser/resource_request_details.h" | 63 #include "content/public/browser/resource_request_details.h" |
63 #include "content/public/browser/storage_partition.h" | 64 #include "content/public/browser/storage_partition.h" |
64 #include "content/public/browser/user_metrics.h" | 65 #include "content/public/browser/user_metrics.h" |
65 #include "content/public/browser/web_contents_delegate.h" | 66 #include "content/public/browser/web_contents_delegate.h" |
66 #include "content/public/browser/web_contents_observer.h" | 67 #include "content/public/browser/web_contents_observer.h" |
67 #include "content/public/browser/web_contents_view.h" | 68 #include "content/public/browser/web_contents_view.h" |
68 #include "content/public/browser/web_ui_controller_factory.h" | |
69 #include "content/public/common/bindings_policy.h" | 69 #include "content/public/common/bindings_policy.h" |
70 #include "content/public/common/content_constants.h" | 70 #include "content/public/common/content_constants.h" |
71 #include "content/public/common/content_restriction.h" | 71 #include "content/public/common/content_restriction.h" |
72 #include "content/public/common/content_switches.h" | 72 #include "content/public/common/content_switches.h" |
73 #include "content/public/common/url_constants.h" | 73 #include "content/public/common/url_constants.h" |
74 #include "net/base/mime_util.h" | 74 #include "net/base/mime_util.h" |
75 #include "net/base/net_util.h" | 75 #include "net/base/net_util.h" |
76 #include "net/base/network_change_notifier.h" | 76 #include "net/base/network_change_notifier.h" |
77 #include "net/url_request/url_request_context_getter.h" | 77 #include "net/url_request/url_request_context_getter.h" |
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 | 849 |
850 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 850 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
851 return render_manager_.GetRenderWidgetHostView(); | 851 return render_manager_.GetRenderWidgetHostView(); |
852 } | 852 } |
853 | 853 |
854 WebContentsView* WebContentsImpl::GetView() const { | 854 WebContentsView* WebContentsImpl::GetView() const { |
855 return view_.get(); | 855 return view_.get(); |
856 } | 856 } |
857 | 857 |
858 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 858 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
859 WebUIControllerFactory* factory = | |
860 GetContentClient()->browser()->GetWebUIControllerFactory(); | |
861 if (!factory) | |
862 return NULL; | |
863 WebUIImpl* web_ui = new WebUIImpl(this); | 859 WebUIImpl* web_ui = new WebUIImpl(this); |
864 WebUIController* controller = | 860 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> |
865 factory->CreateWebUIControllerForURL(web_ui, url); | 861 CreateWebUIControllerForURL(web_ui, url); |
866 if (controller) { | 862 if (controller) { |
867 web_ui->SetController(controller); | 863 web_ui->SetController(controller); |
868 return web_ui; | 864 return web_ui; |
869 } | 865 } |
870 | 866 |
871 delete web_ui; | 867 delete web_ui; |
872 return NULL; | 868 return NULL; |
873 } | 869 } |
874 | 870 |
875 WebUI* WebContentsImpl::GetWebUI() const { | 871 WebUI* WebContentsImpl::GetWebUI() const { |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 return false; | 1619 return false; |
1624 | 1620 |
1625 RenderViewHostImpl* dest_render_view_host = | 1621 RenderViewHostImpl* dest_render_view_host = |
1626 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1622 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
1627 if (!dest_render_view_host) | 1623 if (!dest_render_view_host) |
1628 return false; // Unable to create the desired render view host. | 1624 return false; // Unable to create the desired render view host. |
1629 | 1625 |
1630 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1626 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
1631 // Double check that here. | 1627 // Double check that here. |
1632 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1628 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
1633 WebUIControllerFactory* factory = | |
1634 GetContentClient()->browser()->GetWebUIControllerFactory(); | |
1635 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1629 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
1636 bool is_allowed_in_web_ui_renderer = | 1630 bool is_allowed_in_web_ui_renderer = |
1637 factory && | 1631 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
1638 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), | 1632 GetBrowserContext(), entry.GetURL(), data_urls_allowed); |
1639 data_urls_allowed); | |
1640 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 1633 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
1641 !is_allowed_in_web_ui_renderer) { | 1634 !is_allowed_in_web_ui_renderer) { |
1642 // Log the URL to help us diagnose any future failures of this CHECK. | 1635 // Log the URL to help us diagnose any future failures of this CHECK. |
1643 GetContentClient()->SetActiveURL(entry.GetURL()); | 1636 GetContentClient()->SetActiveURL(entry.GetURL()); |
1644 CHECK(0); | 1637 CHECK(0); |
1645 } | 1638 } |
1646 | 1639 |
1647 // Notify observers that we will navigate in this RV. | 1640 // Notify observers that we will navigate in this RV. |
1648 FOR_EACH_OBSERVER(WebContentsObserver, | 1641 FOR_EACH_OBSERVER(WebContentsObserver, |
1649 observers_, | 1642 observers_, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 | 1899 |
1907 gfx::Size WebContentsImpl::GetPreferredSize() const { | 1900 gfx::Size WebContentsImpl::GetPreferredSize() const { |
1908 return preferred_size_; | 1901 return preferred_size_; |
1909 } | 1902 } |
1910 | 1903 |
1911 int WebContentsImpl::GetContentRestrictions() const { | 1904 int WebContentsImpl::GetContentRestrictions() const { |
1912 return content_restrictions_; | 1905 return content_restrictions_; |
1913 } | 1906 } |
1914 | 1907 |
1915 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { | 1908 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { |
1916 WebUIControllerFactory* factory = | 1909 return WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
1917 GetContentClient()->browser()->GetWebUIControllerFactory(); | 1910 GetBrowserContext(), GetURL()); |
1918 if (!factory) | |
1919 return WebUI::kNoWebUI; | |
1920 return factory->GetWebUIType(GetBrowserContext(), GetURL()); | |
1921 } | 1911 } |
1922 | 1912 |
1923 WebUI* WebContentsImpl::GetWebUIForCurrentState() { | 1913 WebUI* WebContentsImpl::GetWebUIForCurrentState() { |
1924 // When there is a pending navigation entry, we want to use the pending WebUI | 1914 // When there is a pending navigation entry, we want to use the pending WebUI |
1925 // that goes along with it to control the basic flags. For example, we want to | 1915 // that goes along with it to control the basic flags. For example, we want to |
1926 // show the pending URL in the URL bar, so we want the display_url flag to | 1916 // show the pending URL in the URL bar, so we want the display_url flag to |
1927 // be from the pending entry. | 1917 // be from the pending entry. |
1928 // | 1918 // |
1929 // The confusion comes because there are multiple possibilities for the | 1919 // The confusion comes because there are multiple possibilities for the |
1930 // initial load in a tab as a side effect of the way the RenderViewHostManager | 1920 // initial load in a tab as a side effect of the way the RenderViewHostManager |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3457 | 3447 |
3458 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3448 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3459 return browser_plugin_guest_.get(); | 3449 return browser_plugin_guest_.get(); |
3460 } | 3450 } |
3461 | 3451 |
3462 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3452 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3463 return browser_plugin_embedder_.get(); | 3453 return browser_plugin_embedder_.get(); |
3464 } | 3454 } |
3465 | 3455 |
3466 } // namespace content | 3456 } // namespace content |
OLD | NEW |