| 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 827 |
| 828 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 828 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
| 829 return render_manager_.GetRenderWidgetHostView(); | 829 return render_manager_.GetRenderWidgetHostView(); |
| 830 } | 830 } |
| 831 | 831 |
| 832 WebContentsView* WebContentsImpl::GetView() const { | 832 WebContentsView* WebContentsImpl::GetView() const { |
| 833 return view_.get(); | 833 return view_.get(); |
| 834 } | 834 } |
| 835 | 835 |
| 836 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 836 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
| 837 WebUIControllerFactory* factory = |
| 838 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 839 if (!factory) |
| 840 return NULL; |
| 837 WebUIImpl* web_ui = new WebUIImpl(this); | 841 WebUIImpl* web_ui = new WebUIImpl(this); |
| 838 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> | 842 WebUIController* controller = |
| 839 CreateWebUIControllerForURL(web_ui, url); | 843 factory->CreateWebUIControllerForURL(web_ui, url); |
| 840 if (controller) { | 844 if (controller) { |
| 841 web_ui->SetController(controller); | 845 web_ui->SetController(controller); |
| 842 return web_ui; | 846 return web_ui; |
| 843 } | 847 } |
| 844 | 848 |
| 845 delete web_ui; | 849 delete web_ui; |
| 846 return NULL; | 850 return NULL; |
| 847 } | 851 } |
| 848 | 852 |
| 849 WebUI* WebContentsImpl::GetWebUI() const { | 853 WebUI* WebContentsImpl::GetWebUI() const { |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 return false; | 1580 return false; |
| 1577 | 1581 |
| 1578 RenderViewHostImpl* dest_render_view_host = | 1582 RenderViewHostImpl* dest_render_view_host = |
| 1579 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1583 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
| 1580 if (!dest_render_view_host) | 1584 if (!dest_render_view_host) |
| 1581 return false; // Unable to create the desired render view host. | 1585 return false; // Unable to create the desired render view host. |
| 1582 | 1586 |
| 1583 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1587 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 1584 // Double check that here. | 1588 // Double check that here. |
| 1585 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1589 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
| 1590 WebUIControllerFactory* factory = |
| 1591 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1586 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1592 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
| 1587 bool is_allowed_in_web_ui_renderer = | 1593 bool is_allowed_in_web_ui_renderer = |
| 1588 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1594 factory && |
| 1589 GetBrowserContext(), entry.GetURL(), data_urls_allowed); | 1595 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), |
| 1596 data_urls_allowed); |
| 1590 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 1597 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
| 1591 !is_allowed_in_web_ui_renderer) { | 1598 !is_allowed_in_web_ui_renderer) { |
| 1592 // Log the URL to help us diagnose any future failures of this CHECK. | 1599 // Log the URL to help us diagnose any future failures of this CHECK. |
| 1593 GetContentClient()->SetActiveURL(entry.GetURL()); | 1600 GetContentClient()->SetActiveURL(entry.GetURL()); |
| 1594 CHECK(0); | 1601 CHECK(0); |
| 1595 } | 1602 } |
| 1596 | 1603 |
| 1597 // Notify observers that we will navigate in this RV. | 1604 // Notify observers that we will navigate in this RV. |
| 1598 FOR_EACH_OBSERVER(WebContentsObserver, | 1605 FOR_EACH_OBSERVER(WebContentsObserver, |
| 1599 observers_, | 1606 observers_, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 | 1863 |
| 1857 gfx::Size WebContentsImpl::GetPreferredSize() const { | 1864 gfx::Size WebContentsImpl::GetPreferredSize() const { |
| 1858 return preferred_size_; | 1865 return preferred_size_; |
| 1859 } | 1866 } |
| 1860 | 1867 |
| 1861 int WebContentsImpl::GetContentRestrictions() const { | 1868 int WebContentsImpl::GetContentRestrictions() const { |
| 1862 return content_restrictions_; | 1869 return content_restrictions_; |
| 1863 } | 1870 } |
| 1864 | 1871 |
| 1865 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { | 1872 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { |
| 1866 return WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 1873 WebUIControllerFactory* factory = |
| 1867 GetBrowserContext(), GetURL()); | 1874 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1875 if (!factory) |
| 1876 return WebUI::kNoWebUI; |
| 1877 return factory->GetWebUIType(GetBrowserContext(), GetURL()); |
| 1868 } | 1878 } |
| 1869 | 1879 |
| 1870 WebUI* WebContentsImpl::GetWebUIForCurrentState() { | 1880 WebUI* WebContentsImpl::GetWebUIForCurrentState() { |
| 1871 // When there is a pending navigation entry, we want to use the pending WebUI | 1881 // When there is a pending navigation entry, we want to use the pending WebUI |
| 1872 // that goes along with it to control the basic flags. For example, we want to | 1882 // that goes along with it to control the basic flags. For example, we want to |
| 1873 // show the pending URL in the URL bar, so we want the display_url flag to | 1883 // show the pending URL in the URL bar, so we want the display_url flag to |
| 1874 // be from the pending entry. | 1884 // be from the pending entry. |
| 1875 // | 1885 // |
| 1876 // The confusion comes because there are multiple possibilities for the | 1886 // The confusion comes because there are multiple possibilities for the |
| 1877 // initial load in a tab as a side effect of the way the RenderViewHostManager | 1887 // 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... |
| 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 |