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/content_browser_client.h" | 51 #include "content/public/browser/content_browser_client.h" |
51 #include "content/public/browser/devtools_agent_host.h" | 52 #include "content/public/browser/devtools_agent_host.h" |
52 #include "content/public/browser/download_manager.h" | 53 #include "content/public/browser/download_manager.h" |
53 #include "content/public/browser/download_url_parameters.h" | 54 #include "content/public/browser/download_url_parameters.h" |
54 #include "content/public/browser/invalidate_type.h" | 55 #include "content/public/browser/invalidate_type.h" |
55 #include "content/public/browser/javascript_dialogs.h" | 56 #include "content/public/browser/javascript_dialogs.h" |
56 #include "content/public/browser/load_from_memory_cache_details.h" | 57 #include "content/public/browser/load_from_memory_cache_details.h" |
57 #include "content/public/browser/load_notification_details.h" | 58 #include "content/public/browser/load_notification_details.h" |
58 #include "content/public/browser/navigation_details.h" | 59 #include "content/public/browser/navigation_details.h" |
59 #include "content/public/browser/notification_details.h" | 60 #include "content/public/browser/notification_details.h" |
60 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
61 #include "content/public/browser/resource_request_details.h" | 62 #include "content/public/browser/resource_request_details.h" |
62 #include "content/public/browser/storage_partition.h" | 63 #include "content/public/browser/storage_partition.h" |
63 #include "content/public/browser/user_metrics.h" | 64 #include "content/public/browser/user_metrics.h" |
64 #include "content/public/browser/web_contents_delegate.h" | 65 #include "content/public/browser/web_contents_delegate.h" |
65 #include "content/public/browser/web_contents_observer.h" | 66 #include "content/public/browser/web_contents_observer.h" |
66 #include "content/public/browser/web_contents_view.h" | 67 #include "content/public/browser/web_contents_view.h" |
67 #include "content/public/browser/web_ui_controller_factory.h" | |
68 #include "content/public/common/bindings_policy.h" | 68 #include "content/public/common/bindings_policy.h" |
69 #include "content/public/common/content_constants.h" | 69 #include "content/public/common/content_constants.h" |
70 #include "content/public/common/content_restriction.h" | 70 #include "content/public/common/content_restriction.h" |
71 #include "content/public/common/content_switches.h" | 71 #include "content/public/common/content_switches.h" |
72 #include "content/public/common/url_constants.h" | 72 #include "content/public/common/url_constants.h" |
73 #include "net/base/mime_util.h" | 73 #include "net/base/mime_util.h" |
74 #include "net/base/net_util.h" | 74 #include "net/base/net_util.h" |
75 #include "net/base/network_change_notifier.h" | 75 #include "net/base/network_change_notifier.h" |
76 #include "net/url_request/url_request_context_getter.h" | 76 #include "net/url_request/url_request_context_getter.h" |
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 | 829 |
830 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 830 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
831 return render_manager_.GetRenderWidgetHostView(); | 831 return render_manager_.GetRenderWidgetHostView(); |
832 } | 832 } |
833 | 833 |
834 WebContentsView* WebContentsImpl::GetView() const { | 834 WebContentsView* WebContentsImpl::GetView() const { |
835 return view_.get(); | 835 return view_.get(); |
836 } | 836 } |
837 | 837 |
838 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 838 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
839 WebUIControllerFactory* factory = | |
840 GetContentClient()->browser()->GetWebUIControllerFactory(); | |
841 if (!factory) | |
842 return NULL; | |
843 WebUIImpl* web_ui = new WebUIImpl(this); | 839 WebUIImpl* web_ui = new WebUIImpl(this); |
844 WebUIController* controller = | 840 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> |
845 factory->CreateWebUIControllerForURL(web_ui, url); | 841 CreateWebUIControllerForURL(web_ui, url); |
846 if (controller) { | 842 if (controller) { |
847 web_ui->SetController(controller); | 843 web_ui->SetController(controller); |
848 return web_ui; | 844 return web_ui; |
849 } | 845 } |
850 | 846 |
851 delete web_ui; | 847 delete web_ui; |
852 return NULL; | 848 return NULL; |
853 } | 849 } |
854 | 850 |
855 WebUI* WebContentsImpl::GetWebUI() const { | 851 WebUI* WebContentsImpl::GetWebUI() const { |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 return false; | 1578 return false; |
1583 | 1579 |
1584 RenderViewHostImpl* dest_render_view_host = | 1580 RenderViewHostImpl* dest_render_view_host = |
1585 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1581 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
1586 if (!dest_render_view_host) | 1582 if (!dest_render_view_host) |
1587 return false; // Unable to create the desired render view host. | 1583 return false; // Unable to create the desired render view host. |
1588 | 1584 |
1589 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1585 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
1590 // Double check that here. | 1586 // Double check that here. |
1591 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1587 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
1592 WebUIControllerFactory* factory = | |
1593 GetContentClient()->browser()->GetWebUIControllerFactory(); | |
1594 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1588 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
1595 bool is_allowed_in_web_ui_renderer = | 1589 bool is_allowed_in_web_ui_renderer = |
1596 factory && | 1590 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
1597 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), | 1591 GetBrowserContext(), entry.GetURL(), data_urls_allowed); |
1598 data_urls_allowed); | |
1599 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 1592 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
1600 !is_allowed_in_web_ui_renderer) { | 1593 !is_allowed_in_web_ui_renderer) { |
1601 // Log the URL to help us diagnose any future failures of this CHECK. | 1594 // Log the URL to help us diagnose any future failures of this CHECK. |
1602 GetContentClient()->SetActiveURL(entry.GetURL()); | 1595 GetContentClient()->SetActiveURL(entry.GetURL()); |
1603 CHECK(0); | 1596 CHECK(0); |
1604 } | 1597 } |
1605 | 1598 |
1606 // Notify observers that we will navigate in this RV. | 1599 // Notify observers that we will navigate in this RV. |
1607 FOR_EACH_OBSERVER(WebContentsObserver, | 1600 FOR_EACH_OBSERVER(WebContentsObserver, |
1608 observers_, | 1601 observers_, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 | 1858 |
1866 gfx::Size WebContentsImpl::GetPreferredSize() const { | 1859 gfx::Size WebContentsImpl::GetPreferredSize() const { |
1867 return preferred_size_; | 1860 return preferred_size_; |
1868 } | 1861 } |
1869 | 1862 |
1870 int WebContentsImpl::GetContentRestrictions() const { | 1863 int WebContentsImpl::GetContentRestrictions() const { |
1871 return content_restrictions_; | 1864 return content_restrictions_; |
1872 } | 1865 } |
1873 | 1866 |
1874 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { | 1867 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { |
1875 WebUIControllerFactory* factory = | 1868 return WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
1876 GetContentClient()->browser()->GetWebUIControllerFactory(); | 1869 GetBrowserContext(), GetURL()); |
1877 if (!factory) | |
1878 return WebUI::kNoWebUI; | |
1879 return factory->GetWebUIType(GetBrowserContext(), GetURL()); | |
1880 } | 1870 } |
1881 | 1871 |
1882 WebUI* WebContentsImpl::GetWebUIForCurrentState() { | 1872 WebUI* WebContentsImpl::GetWebUIForCurrentState() { |
1883 // When there is a pending navigation entry, we want to use the pending WebUI | 1873 // When there is a pending navigation entry, we want to use the pending WebUI |
1884 // that goes along with it to control the basic flags. For example, we want to | 1874 // that goes along with it to control the basic flags. For example, we want to |
1885 // show the pending URL in the URL bar, so we want the display_url flag to | 1875 // show the pending URL in the URL bar, so we want the display_url flag to |
1886 // be from the pending entry. | 1876 // be from the pending entry. |
1887 // | 1877 // |
1888 // The confusion comes because there are multiple possibilities for the | 1878 // The confusion comes because there are multiple possibilities for the |
1889 // initial load in a tab as a side effect of the way the RenderViewHostManager | 1879 // initial load in a tab as a side effect of the way the RenderViewHostManager |
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 | 3388 |
3399 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3389 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3400 return browser_plugin_guest_.get(); | 3390 return browser_plugin_guest_.get(); |
3401 } | 3391 } |
3402 | 3392 |
3403 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3393 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3404 return browser_plugin_embedder_.get(); | 3394 return browser_plugin_embedder_.get(); |
3405 } | 3395 } |
3406 | 3396 |
3407 } // namespace content | 3397 } // namespace content |
OLD | NEW |