| 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" | |
| 41 #include "content/browser/webui/web_ui_impl.h" | 40 #include "content/browser/webui/web_ui_impl.h" |
| 42 #include "content/common/browser_plugin_messages.h" | 41 #include "content/common/browser_plugin_messages.h" |
| 43 #include "content/common/icon_messages.h" | 42 #include "content/common/icon_messages.h" |
| 44 #include "content/common/intents_messages.h" | 43 #include "content/common/intents_messages.h" |
| 45 #include "content/common/ssl_status_serialization.h" | 44 #include "content/common/ssl_status_serialization.h" |
| 46 #include "content/common/view_messages.h" | 45 #include "content/common/view_messages.h" |
| 47 #include "content/port/browser/render_view_host_delegate_view.h" | 46 #include "content/port/browser/render_view_host_delegate_view.h" |
| 48 #include "content/port/browser/render_widget_host_view_port.h" | 47 #include "content/port/browser/render_widget_host_view_port.h" |
| 49 #include "content/public/browser/browser_context.h" | 48 #include "content/public/browser/browser_context.h" |
| 50 #include "content/public/browser/color_chooser.h" | 49 #include "content/public/browser/color_chooser.h" |
| 51 #include "content/public/browser/content_browser_client.h" | 50 #include "content/public/browser/content_browser_client.h" |
| 52 #include "content/public/browser/devtools_agent_host.h" | 51 #include "content/public/browser/devtools_agent_host.h" |
| 53 #include "content/public/browser/download_manager.h" | 52 #include "content/public/browser/download_manager.h" |
| 54 #include "content/public/browser/download_url_parameters.h" | 53 #include "content/public/browser/download_url_parameters.h" |
| 55 #include "content/public/browser/invalidate_type.h" | 54 #include "content/public/browser/invalidate_type.h" |
| 56 #include "content/public/browser/javascript_dialogs.h" | 55 #include "content/public/browser/javascript_dialogs.h" |
| 57 #include "content/public/browser/load_from_memory_cache_details.h" | 56 #include "content/public/browser/load_from_memory_cache_details.h" |
| 58 #include "content/public/browser/load_notification_details.h" | 57 #include "content/public/browser/load_notification_details.h" |
| 59 #include "content/public/browser/navigation_details.h" | 58 #include "content/public/browser/navigation_details.h" |
| 60 #include "content/public/browser/notification_details.h" | 59 #include "content/public/browser/notification_details.h" |
| 61 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
| 62 #include "content/public/browser/resource_request_details.h" | 61 #include "content/public/browser/resource_request_details.h" |
| 63 #include "content/public/browser/storage_partition.h" | 62 #include "content/public/browser/storage_partition.h" |
| 64 #include "content/public/browser/user_metrics.h" | 63 #include "content/public/browser/user_metrics.h" |
| 65 #include "content/public/browser/web_contents_delegate.h" | 64 #include "content/public/browser/web_contents_delegate.h" |
| 66 #include "content/public/browser/web_contents_observer.h" | 65 #include "content/public/browser/web_contents_observer.h" |
| 67 #include "content/public/browser/web_contents_view.h" | 66 #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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 | 816 |
| 817 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 817 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
| 818 return render_manager_.GetRenderWidgetHostView(); | 818 return render_manager_.GetRenderWidgetHostView(); |
| 819 } | 819 } |
| 820 | 820 |
| 821 WebContentsView* WebContentsImpl::GetView() const { | 821 WebContentsView* WebContentsImpl::GetView() const { |
| 822 return view_.get(); | 822 return view_.get(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 825 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
| 826 WebUIControllerFactory* factory = |
| 827 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 828 if (!factory) |
| 829 return NULL; |
| 826 WebUIImpl* web_ui = new WebUIImpl(this); | 830 WebUIImpl* web_ui = new WebUIImpl(this); |
| 827 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> | 831 WebUIController* controller = |
| 828 CreateWebUIControllerForURL(web_ui, url); | 832 factory->CreateWebUIControllerForURL(web_ui, url); |
| 829 if (controller) { | 833 if (controller) { |
| 830 web_ui->SetController(controller); | 834 web_ui->SetController(controller); |
| 831 return web_ui; | 835 return web_ui; |
| 832 } | 836 } |
| 833 | 837 |
| 834 delete web_ui; | 838 delete web_ui; |
| 835 return NULL; | 839 return NULL; |
| 836 } | 840 } |
| 837 | 841 |
| 838 WebUI* WebContentsImpl::GetWebUI() const { | 842 WebUI* WebContentsImpl::GetWebUI() const { |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 return false; | 1569 return false; |
| 1566 | 1570 |
| 1567 RenderViewHostImpl* dest_render_view_host = | 1571 RenderViewHostImpl* dest_render_view_host = |
| 1568 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1572 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
| 1569 if (!dest_render_view_host) | 1573 if (!dest_render_view_host) |
| 1570 return false; // Unable to create the desired render view host. | 1574 return false; // Unable to create the desired render view host. |
| 1571 | 1575 |
| 1572 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1576 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 1573 // Double check that here. | 1577 // Double check that here. |
| 1574 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1578 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
| 1579 WebUIControllerFactory* factory = |
| 1580 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1575 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1581 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
| 1576 bool is_allowed_in_web_ui_renderer = | 1582 bool is_allowed_in_web_ui_renderer = |
| 1577 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1583 factory && |
| 1578 GetBrowserContext(), entry.GetURL(), data_urls_allowed); | 1584 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), |
| 1585 data_urls_allowed); |
| 1579 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 1586 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
| 1580 !is_allowed_in_web_ui_renderer) { | 1587 !is_allowed_in_web_ui_renderer) { |
| 1581 // Log the URL to help us diagnose any future failures of this CHECK. | 1588 // Log the URL to help us diagnose any future failures of this CHECK. |
| 1582 GetContentClient()->SetActiveURL(entry.GetURL()); | 1589 GetContentClient()->SetActiveURL(entry.GetURL()); |
| 1583 CHECK(0); | 1590 CHECK(0); |
| 1584 } | 1591 } |
| 1585 | 1592 |
| 1586 // Notify observers that we will navigate in this RV. | 1593 // Notify observers that we will navigate in this RV. |
| 1587 FOR_EACH_OBSERVER(WebContentsObserver, | 1594 FOR_EACH_OBSERVER(WebContentsObserver, |
| 1588 observers_, | 1595 observers_, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 | 1852 |
| 1846 gfx::Size WebContentsImpl::GetPreferredSize() const { | 1853 gfx::Size WebContentsImpl::GetPreferredSize() const { |
| 1847 return preferred_size_; | 1854 return preferred_size_; |
| 1848 } | 1855 } |
| 1849 | 1856 |
| 1850 int WebContentsImpl::GetContentRestrictions() const { | 1857 int WebContentsImpl::GetContentRestrictions() const { |
| 1851 return content_restrictions_; | 1858 return content_restrictions_; |
| 1852 } | 1859 } |
| 1853 | 1860 |
| 1854 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { | 1861 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { |
| 1855 return WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 1862 WebUIControllerFactory* factory = |
| 1856 GetBrowserContext(), GetURL()); | 1863 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1864 if (!factory) |
| 1865 return WebUI::kNoWebUI; |
| 1866 return factory->GetWebUIType(GetBrowserContext(), GetURL()); |
| 1857 } | 1867 } |
| 1858 | 1868 |
| 1859 WebUI* WebContentsImpl::GetWebUIForCurrentState() { | 1869 WebUI* WebContentsImpl::GetWebUIForCurrentState() { |
| 1860 // When there is a pending navigation entry, we want to use the pending WebUI | 1870 // When there is a pending navigation entry, we want to use the pending WebUI |
| 1861 // that goes along with it to control the basic flags. For example, we want to | 1871 // that goes along with it to control the basic flags. For example, we want to |
| 1862 // show the pending URL in the URL bar, so we want the display_url flag to | 1872 // show the pending URL in the URL bar, so we want the display_url flag to |
| 1863 // be from the pending entry. | 1873 // be from the pending entry. |
| 1864 // | 1874 // |
| 1865 // The confusion comes because there are multiple possibilities for the | 1875 // The confusion comes because there are multiple possibilities for the |
| 1866 // initial load in a tab as a side effect of the way the RenderViewHostManager | 1876 // initial load in a tab as a side effect of the way the RenderViewHostManager |
| (...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3386 | 3396 |
| 3387 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3397 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3388 return browser_plugin_guest_.get(); | 3398 return browser_plugin_guest_.get(); |
| 3389 } | 3399 } |
| 3390 | 3400 |
| 3391 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3401 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3392 return browser_plugin_embedder_.get(); | 3402 return browser_plugin_embedder_.get(); |
| 3393 } | 3403 } |
| 3394 | 3404 |
| 3395 } // namespace content | 3405 } // namespace content |
| OLD | NEW |