OLD | NEW |
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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "content/browser/renderer_host/render_view_host.h" | 75 #include "content/browser/renderer_host/render_view_host.h" |
76 #include "content/browser/renderer_host/render_widget_host_view.h" | 76 #include "content/browser/renderer_host/render_widget_host_view.h" |
77 #include "content/browser/renderer_host/resource_request_details.h" | 77 #include "content/browser/renderer_host/resource_request_details.h" |
78 #include "content/browser/site_instance.h" | 78 #include "content/browser/site_instance.h" |
79 #include "content/browser/tab_contents/interstitial_page.h" | 79 #include "content/browser/tab_contents/interstitial_page.h" |
80 #include "content/browser/tab_contents/navigation_entry.h" | 80 #include "content/browser/tab_contents/navigation_entry.h" |
81 #include "content/browser/tab_contents/provisional_load_details.h" | 81 #include "content/browser/tab_contents/provisional_load_details.h" |
82 #include "content/browser/tab_contents/tab_contents_delegate.h" | 82 #include "content/browser/tab_contents/tab_contents_delegate.h" |
83 #include "content/browser/tab_contents/tab_contents_observer.h" | 83 #include "content/browser/tab_contents/tab_contents_observer.h" |
84 #include "content/browser/tab_contents/tab_contents_view.h" | 84 #include "content/browser/tab_contents/tab_contents_view.h" |
85 #include "content/browser/webui/web_ui.h" | 85 #include "content/browser/webui/content_web_ui_client.h" |
| 86 #include "content/common/content_client.h" |
86 #include "content/common/navigation_types.h" | 87 #include "content/common/navigation_types.h" |
87 #include "content/common/notification_service.h" | 88 #include "content/common/notification_service.h" |
88 #include "content/common/view_messages.h" | 89 #include "content/common/view_messages.h" |
89 #include "net/base/net_util.h" | 90 #include "net/base/net_util.h" |
90 #include "net/base/registry_controlled_domain.h" | 91 #include "net/base/registry_controlled_domain.h" |
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
92 #include "ui/base/resource/resource_bundle.h" | 93 #include "ui/base/resource/resource_bundle.h" |
93 #include "ui/gfx/codec/png_codec.h" | 94 #include "ui/gfx/codec/png_codec.h" |
94 #include "webkit/glue/password_form.h" | 95 #include "webkit/glue/password_form.h" |
95 #include "webkit/glue/webpreferences.h" | 96 #include "webkit/glue/webpreferences.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 displayed_insecure_content_(false), | 247 displayed_insecure_content_(false), |
247 extension_app_(NULL), | 248 extension_app_(NULL), |
248 capturing_contents_(false), | 249 capturing_contents_(false), |
249 is_being_destroyed_(false), | 250 is_being_destroyed_(false), |
250 notify_disconnection_(false), | 251 notify_disconnection_(false), |
251 #if defined(OS_WIN) | 252 #if defined(OS_WIN) |
252 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 253 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
253 #endif | 254 #endif |
254 suppress_javascript_messages_(false), | 255 suppress_javascript_messages_(false), |
255 is_showing_before_unload_dialog_(false), | 256 is_showing_before_unload_dialog_(false), |
256 opener_web_ui_type_(WebUIFactory::kNoWebUI), | 257 opener_web_ui_type_(WebUI::kNoWebUI), |
257 language_state_(&controller_), | 258 language_state_(&controller_), |
258 closed_by_user_gesture_(false), | 259 closed_by_user_gesture_(false), |
259 minimum_zoom_percent_( | 260 minimum_zoom_percent_( |
260 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 261 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), |
261 maximum_zoom_percent_( | 262 maximum_zoom_percent_( |
262 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 263 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), |
263 temporary_zoom_settings_(false), | 264 temporary_zoom_settings_(false), |
264 content_restrictions_(0) { | 265 content_restrictions_(0) { |
265 renderer_preferences_util::UpdateFromSystemSettings( | 266 renderer_preferences_util::UpdateFromSystemSettings( |
266 &renderer_preferences_, profile); | 267 &renderer_preferences_, profile); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 548 |
548 bool TabContents::ShouldDisplayURL() { | 549 bool TabContents::ShouldDisplayURL() { |
549 // Don't hide the url in view source mode and with interstitials. | 550 // Don't hide the url in view source mode and with interstitials. |
550 NavigationEntry* entry = controller_.GetActiveEntry(); | 551 NavigationEntry* entry = controller_.GetActiveEntry(); |
551 if (entry && (entry->IsViewSourceMode() || | 552 if (entry && (entry->IsViewSourceMode() || |
552 entry->page_type() == INTERSTITIAL_PAGE)) { | 553 entry->page_type() == INTERSTITIAL_PAGE)) { |
553 return true; | 554 return true; |
554 } | 555 } |
555 | 556 |
556 // We always display the URL for non-WebUI URLs to prevent spoofing. | 557 // We always display the URL for non-WebUI URLs to prevent spoofing. |
557 if (entry && !WebUIFactory::HasWebUIScheme(entry->url())) | 558 if (entry && !content::GetContentClient()->web_ui()-> |
| 559 HasWebUIScheme(entry->url())) { |
558 return true; | 560 return true; |
| 561 } |
559 | 562 |
560 WebUI* web_ui = GetWebUIForCurrentState(); | 563 WebUI* web_ui = GetWebUIForCurrentState(); |
561 if (web_ui) | 564 if (web_ui) |
562 return !web_ui->should_hide_url(); | 565 return !web_ui->should_hide_url(); |
563 return true; | 566 return true; |
564 } | 567 } |
565 | 568 |
566 SkBitmap TabContents::GetFavicon() const { | 569 SkBitmap TabContents::GetFavicon() const { |
567 // Like GetTitle(), we also want to use the favicon for the last committed | 570 // Like GetTitle(), we also want to use the favicon for the last committed |
568 // entry rather than a pending navigation entry. | 571 // entry rather than a pending navigation entry. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 return false; // Unable to create the desired render view host. | 726 return false; // Unable to create the desired render view host. |
724 | 727 |
725 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { | 728 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { |
726 dest_render_view_host->EnablePreferredSizeChangedMode( | 729 dest_render_view_host->EnablePreferredSizeChangedMode( |
727 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 730 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
728 } | 731 } |
729 | 732 |
730 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 733 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
731 // Double check that here. | 734 // Double check that here. |
732 int enabled_bindings = dest_render_view_host->enabled_bindings(); | 735 int enabled_bindings = dest_render_view_host->enabled_bindings(); |
733 bool is_allowed_in_web_ui_renderer = | 736 bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> |
734 WebUIFactory::IsURLAcceptableForWebUI(profile(), entry.url()); | 737 web_ui()->IsURLAcceptableForWebUI(profile(), entry.url()); |
735 CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) || | 738 CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) || |
736 is_allowed_in_web_ui_renderer); | 739 is_allowed_in_web_ui_renderer); |
737 | 740 |
738 // Tell DevTools agent that it is attached prior to the navigation. | 741 // Tell DevTools agent that it is attached prior to the navigation. |
739 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 742 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
740 if (devtools_manager) { // NULL in unit tests. | 743 if (devtools_manager) { // NULL in unit tests. |
741 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 744 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
742 dest_render_view_host, | 745 dest_render_view_host, |
743 entry.url()); | 746 entry.url()); |
744 } | 747 } |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 // | 1603 // |
1601 // - Normal state with no load: committed nav entry + no pending nav entry: | 1604 // - Normal state with no load: committed nav entry + no pending nav entry: |
1602 // -> Use committed Web UI. | 1605 // -> Use committed Web UI. |
1603 if (controller_.pending_entry() && | 1606 if (controller_.pending_entry() && |
1604 (controller_.GetLastCommittedEntry() || | 1607 (controller_.GetLastCommittedEntry() || |
1605 render_manager_.pending_web_ui())) | 1608 render_manager_.pending_web_ui())) |
1606 return render_manager_.pending_web_ui(); | 1609 return render_manager_.pending_web_ui(); |
1607 return render_manager_.web_ui(); | 1610 return render_manager_.web_ui(); |
1608 } | 1611 } |
1609 | 1612 |
| 1613 WebUI::WebUITypeID TabContents::GetWebUITypeForCurrentState() { |
| 1614 return content::GetContentClient()->web_ui()->GetWebUIType(profile(), |
| 1615 GetURL()); |
| 1616 } |
| 1617 |
1610 void TabContents::DidNavigateMainFramePostCommit( | 1618 void TabContents::DidNavigateMainFramePostCommit( |
1611 const NavigationController::LoadCommittedDetails& details, | 1619 const NavigationController::LoadCommittedDetails& details, |
1612 const ViewHostMsg_FrameNavigate_Params& params) { | 1620 const ViewHostMsg_FrameNavigate_Params& params) { |
1613 if (opener_web_ui_type_ != WebUIFactory::kNoWebUI) { | 1621 if (opener_web_ui_type_ != WebUI::kNoWebUI) { |
1614 // If this is a window.open navigation, use the same WebUI as the renderer | 1622 // If this is a window.open navigation, use the same WebUI as the renderer |
1615 // that opened the window, as long as both renderers have the same | 1623 // that opened the window, as long as both renderers have the same |
1616 // privileges. | 1624 // privileges. |
1617 if (opener_web_ui_type_ == | 1625 if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) { |
1618 WebUIFactory::GetWebUIType(profile(), GetURL())) { | 1626 WebUI* web_ui = content::GetContentClient()->web_ui()-> |
1619 WebUI* web_ui = WebUIFactory::CreateWebUIForURL(this, GetURL()); | 1627 CreateWebUIForURL(this, GetURL()); |
1620 // web_ui might be NULL if the URL refers to a non-existent extension. | 1628 // web_ui might be NULL if the URL refers to a non-existent extension. |
1621 if (web_ui) { | 1629 if (web_ui) { |
1622 render_manager_.SetWebUIPostCommit(web_ui); | 1630 render_manager_.SetWebUIPostCommit(web_ui); |
1623 web_ui->RenderViewCreated(render_view_host()); | 1631 web_ui->RenderViewCreated(render_view_host()); |
1624 } | 1632 } |
1625 } | 1633 } |
1626 opener_web_ui_type_ = WebUIFactory::kNoWebUI; | 1634 opener_web_ui_type_ = WebUI::kNoWebUI; |
1627 } | 1635 } |
1628 | 1636 |
1629 if (details.is_user_initiated_main_frame_load()) { | 1637 if (details.is_user_initiated_main_frame_load()) { |
1630 // Clear the status bubble. This is a workaround for a bug where WebKit | 1638 // Clear the status bubble. This is a workaround for a bug where WebKit |
1631 // doesn't let us know that the cursor left an element during a | 1639 // doesn't let us know that the cursor left an element during a |
1632 // transition (this is also why the mouse cursor remains as a hand after | 1640 // transition (this is also why the mouse cursor remains as a hand after |
1633 // clicking on a link); see bugs 1184641 and 980803. We don't want to | 1641 // clicking on a link); see bugs 1184641 and 980803. We don't want to |
1634 // clear the bubble when a user navigates to a named anchor in the same | 1642 // clear the bubble when a user navigates to a named anchor in the same |
1635 // page. | 1643 // page. |
1636 UpdateTargetURL(details.entry->page_id(), GURL()); | 1644 UpdateTargetURL(details.entry->page_id(), GURL()); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 NotificationService::current()->Notify( | 2004 NotificationService::current()->Notify( |
1997 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, | 2005 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, |
1998 Source<TabContents>(this), | 2006 Source<TabContents>(this), |
1999 Details<RenderViewHost>(render_view_host)); | 2007 Details<RenderViewHost>(render_view_host)); |
2000 NavigationEntry* entry = controller_.GetActiveEntry(); | 2008 NavigationEntry* entry = controller_.GetActiveEntry(); |
2001 if (!entry) | 2009 if (!entry) |
2002 return; | 2010 return; |
2003 | 2011 |
2004 // When we're creating views, we're still doing initial setup, so we always | 2012 // When we're creating views, we're still doing initial setup, so we always |
2005 // use the pending Web UI rather than any possibly existing committed one. | 2013 // use the pending Web UI rather than any possibly existing committed one. |
2006 if (render_manager_.pending_web_ui()) { | 2014 if (render_manager_.pending_web_ui()) |
2007 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 2015 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); |
2008 } | |
2009 | 2016 |
2010 if (entry->IsViewSourceMode()) { | 2017 if (entry->IsViewSourceMode()) { |
2011 // Put the renderer in view source mode. | 2018 // Put the renderer in view source mode. |
2012 render_view_host->Send( | 2019 render_view_host->Send( |
2013 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); | 2020 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); |
2014 } | 2021 } |
2015 | 2022 |
2016 view()->RenderViewCreated(render_view_host); | 2023 view()->RenderViewCreated(render_view_host); |
2017 } | 2024 } |
2018 | 2025 |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 | 2597 |
2591 void TabContents::NotifySwappedFromRenderManager() { | 2598 void TabContents::NotifySwappedFromRenderManager() { |
2592 NotifySwapped(); | 2599 NotifySwapped(); |
2593 } | 2600 } |
2594 | 2601 |
2595 NavigationController& TabContents::GetControllerForRenderManager() { | 2602 NavigationController& TabContents::GetControllerForRenderManager() { |
2596 return controller(); | 2603 return controller(); |
2597 } | 2604 } |
2598 | 2605 |
2599 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { | 2606 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { |
2600 return WebUIFactory::CreateWebUIForURL(this, url); | 2607 return content::GetContentClient()->web_ui()->CreateWebUIForURL(this, url); |
2601 } | 2608 } |
2602 | 2609 |
2603 NavigationEntry* | 2610 NavigationEntry* |
2604 TabContents::GetLastCommittedNavigationEntryForRenderManager() { | 2611 TabContents::GetLastCommittedNavigationEntryForRenderManager() { |
2605 return controller_.GetLastCommittedEntry(); | 2612 return controller_.GetLastCommittedEntry(); |
2606 } | 2613 } |
2607 | 2614 |
2608 bool TabContents::CreateRenderViewForRenderManager( | 2615 bool TabContents::CreateRenderViewForRenderManager( |
2609 RenderViewHost* render_view_host) { | 2616 RenderViewHost* render_view_host) { |
2610 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); | 2617 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 | 2784 |
2778 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2785 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2779 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2786 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2780 rwh_view->SetSize(view()->GetContainerSize()); | 2787 rwh_view->SetSize(view()->GetContainerSize()); |
2781 } | 2788 } |
2782 | 2789 |
2783 void TabContents::OnOnlineStateChanged(bool online) { | 2790 void TabContents::OnOnlineStateChanged(bool online) { |
2784 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2791 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
2785 render_view_host()->routing_id(), online)); | 2792 render_view_host()->routing_id(), online)); |
2786 } | 2793 } |
OLD | NEW |