Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 6713082: Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: synced Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chrome/common/extensions/extension_action.h" 59 #include "chrome/common/extensions/extension_action.h"
60 #include "chrome/common/extensions/extension_icon_set.h" 60 #include "chrome/common/extensions/extension_icon_set.h"
61 #include "chrome/common/extensions/extension_messages.h" 61 #include "chrome/common/extensions/extension_messages.h"
62 #include "chrome/common/extensions/extension_resource.h" 62 #include "chrome/common/extensions/extension_resource.h"
63 #include "chrome/common/extensions/url_pattern.h" 63 #include "chrome/common/extensions/url_pattern.h"
64 #include "chrome/common/net/url_request_context_getter.h" 64 #include "chrome/common/net/url_request_context_getter.h"
65 #include "chrome/common/pref_names.h" 65 #include "chrome/common/pref_names.h"
66 #include "chrome/common/render_messages.h" 66 #include "chrome/common/render_messages.h"
67 #include "chrome/common/url_constants.h" 67 #include "chrome/common/url_constants.h"
68 #include "content/browser/child_process_security_policy.h" 68 #include "content/browser/child_process_security_policy.h"
69 #include "content/browser/content_browser_client.h"
69 #include "content/browser/host_zoom_map.h" 70 #include "content/browser/host_zoom_map.h"
70 #include "content/browser/in_process_webkit/session_storage_namespace.h" 71 #include "content/browser/in_process_webkit/session_storage_namespace.h"
71 #include "content/browser/renderer_host/render_process_host.h" 72 #include "content/browser/renderer_host/render_process_host.h"
72 #include "content/browser/renderer_host/render_view_host.h" 73 #include "content/browser/renderer_host/render_view_host.h"
73 #include "content/browser/renderer_host/render_widget_host_view.h" 74 #include "content/browser/renderer_host/render_widget_host_view.h"
74 #include "content/browser/renderer_host/resource_request_details.h" 75 #include "content/browser/renderer_host/resource_request_details.h"
75 #include "content/browser/site_instance.h" 76 #include "content/browser/site_instance.h"
76 #include "content/browser/tab_contents/interstitial_page.h" 77 #include "content/browser/tab_contents/interstitial_page.h"
77 #include "content/browser/tab_contents/navigation_entry.h" 78 #include "content/browser/tab_contents/navigation_entry.h"
78 #include "content/browser/tab_contents/provisional_load_details.h" 79 #include "content/browser/tab_contents/provisional_load_details.h"
79 #include "content/browser/tab_contents/tab_contents_delegate.h" 80 #include "content/browser/tab_contents/tab_contents_delegate.h"
80 #include "content/browser/tab_contents/tab_contents_observer.h" 81 #include "content/browser/tab_contents/tab_contents_observer.h"
81 #include "content/browser/tab_contents/tab_contents_view.h" 82 #include "content/browser/tab_contents/tab_contents_view.h"
82 #include "content/browser/webui/web_ui.h" 83 #include "content/browser/webui/web_ui_factory.h"
84 #include "content/common/content_client.h"
83 #include "content/common/navigation_types.h" 85 #include "content/common/navigation_types.h"
84 #include "content/common/notification_service.h" 86 #include "content/common/notification_service.h"
85 #include "content/common/view_messages.h" 87 #include "content/common/view_messages.h"
86 #include "net/base/net_util.h" 88 #include "net/base/net_util.h"
87 #include "net/base/registry_controlled_domain.h" 89 #include "net/base/registry_controlled_domain.h"
88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
89 #include "ui/base/resource/resource_bundle.h" 91 #include "ui/base/resource/resource_bundle.h"
90 #include "ui/gfx/codec/png_codec.h" 92 #include "ui/gfx/codec/png_codec.h"
91 #include "webkit/glue/password_form.h" 93 #include "webkit/glue/password_form.h"
92 #include "webkit/glue/webpreferences.h" 94 #include "webkit/glue/webpreferences.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 displayed_insecure_content_(false), 245 displayed_insecure_content_(false),
244 extension_app_(NULL), 246 extension_app_(NULL),
245 capturing_contents_(false), 247 capturing_contents_(false),
246 is_being_destroyed_(false), 248 is_being_destroyed_(false),
247 notify_disconnection_(false), 249 notify_disconnection_(false),
248 #if defined(OS_WIN) 250 #if defined(OS_WIN)
249 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), 251 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)),
250 #endif 252 #endif
251 suppress_javascript_messages_(false), 253 suppress_javascript_messages_(false),
252 is_showing_before_unload_dialog_(false), 254 is_showing_before_unload_dialog_(false),
253 opener_web_ui_type_(WebUIFactory::kNoWebUI), 255 opener_web_ui_type_(WebUI::kNoWebUI),
254 language_state_(&controller_), 256 language_state_(&controller_),
255 closed_by_user_gesture_(false), 257 closed_by_user_gesture_(false),
256 minimum_zoom_percent_( 258 minimum_zoom_percent_(
257 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), 259 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)),
258 maximum_zoom_percent_( 260 maximum_zoom_percent_(
259 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), 261 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)),
260 temporary_zoom_settings_(false), 262 temporary_zoom_settings_(false),
261 content_restrictions_(0) { 263 content_restrictions_(0) {
262 renderer_preferences_util::UpdateFromSystemSettings( 264 renderer_preferences_util::UpdateFromSystemSettings(
263 &renderer_preferences_, profile); 265 &renderer_preferences_, profile);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 545
544 bool TabContents::ShouldDisplayURL() { 546 bool TabContents::ShouldDisplayURL() {
545 // Don't hide the url in view source mode and with interstitials. 547 // Don't hide the url in view source mode and with interstitials.
546 NavigationEntry* entry = controller_.GetActiveEntry(); 548 NavigationEntry* entry = controller_.GetActiveEntry();
547 if (entry && (entry->IsViewSourceMode() || 549 if (entry && (entry->IsViewSourceMode() ||
548 entry->page_type() == INTERSTITIAL_PAGE)) { 550 entry->page_type() == INTERSTITIAL_PAGE)) {
549 return true; 551 return true;
550 } 552 }
551 553
552 // We always display the URL for non-WebUI URLs to prevent spoofing. 554 // We always display the URL for non-WebUI URLs to prevent spoofing.
553 if (entry && !WebUIFactory::HasWebUIScheme(entry->url())) 555 if (entry && !content::WebUIFactory::Get()->HasWebUIScheme(entry->url()))
554 return true; 556 return true;
555 557
556 WebUI* web_ui = GetWebUIForCurrentState(); 558 WebUI* web_ui = GetWebUIForCurrentState();
557 if (web_ui) 559 if (web_ui)
558 return !web_ui->should_hide_url(); 560 return !web_ui->should_hide_url();
559 return true; 561 return true;
560 } 562 }
561 563
562 SkBitmap TabContents::GetFavicon() const { 564 SkBitmap TabContents::GetFavicon() const {
563 // Like GetTitle(), we also want to use the favicon for the last committed 565 // Like GetTitle(), we also want to use the favicon for the last committed
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return false; // Unable to create the desired render view host. 708 return false; // Unable to create the desired render view host.
707 709
708 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { 710 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) {
709 dest_render_view_host->EnablePreferredSizeChangedMode( 711 dest_render_view_host->EnablePreferredSizeChangedMode(
710 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); 712 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
711 } 713 }
712 714
713 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 715 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
714 // Double check that here. 716 // Double check that here.
715 int enabled_bindings = dest_render_view_host->enabled_bindings(); 717 int enabled_bindings = dest_render_view_host->enabled_bindings();
716 bool is_allowed_in_web_ui_renderer = 718 bool is_allowed_in_web_ui_renderer = content::GetContentClient()->
717 WebUIFactory::IsURLAcceptableForWebUI(profile(), entry.url()); 719 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(profile(),
720 entry.url());
718 CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) || 721 CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) ||
719 is_allowed_in_web_ui_renderer); 722 is_allowed_in_web_ui_renderer);
720 723
721 // Tell DevTools agent that it is attached prior to the navigation. 724 // Tell DevTools agent that it is attached prior to the navigation.
722 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 725 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
723 if (devtools_manager) { // NULL in unit tests. 726 if (devtools_manager) { // NULL in unit tests.
724 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), 727 devtools_manager->OnNavigatingToPendingEntry(render_view_host(),
725 dest_render_view_host, 728 dest_render_view_host,
726 entry.url()); 729 entry.url());
727 } 730 }
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 // 1594 //
1592 // - Normal state with no load: committed nav entry + no pending nav entry: 1595 // - Normal state with no load: committed nav entry + no pending nav entry:
1593 // -> Use committed Web UI. 1596 // -> Use committed Web UI.
1594 if (controller_.pending_entry() && 1597 if (controller_.pending_entry() &&
1595 (controller_.GetLastCommittedEntry() || 1598 (controller_.GetLastCommittedEntry() ||
1596 render_manager_.pending_web_ui())) 1599 render_manager_.pending_web_ui()))
1597 return render_manager_.pending_web_ui(); 1600 return render_manager_.pending_web_ui();
1598 return render_manager_.web_ui(); 1601 return render_manager_.web_ui();
1599 } 1602 }
1600 1603
1604 WebUI::TypeID TabContents::GetWebUITypeForCurrentState() {
1605 return content::WebUIFactory::Get()->GetWebUIType(profile(), GetURL());
1606 }
1607
1601 void TabContents::DidNavigateMainFramePostCommit( 1608 void TabContents::DidNavigateMainFramePostCommit(
1602 const NavigationController::LoadCommittedDetails& details, 1609 const NavigationController::LoadCommittedDetails& details,
1603 const ViewHostMsg_FrameNavigate_Params& params) { 1610 const ViewHostMsg_FrameNavigate_Params& params) {
1604 if (opener_web_ui_type_ != WebUIFactory::kNoWebUI) { 1611 if (opener_web_ui_type_ != WebUI::kNoWebUI) {
1605 // If this is a window.open navigation, use the same WebUI as the renderer 1612 // If this is a window.open navigation, use the same WebUI as the renderer
1606 // that opened the window, as long as both renderers have the same 1613 // that opened the window, as long as both renderers have the same
1607 // privileges. 1614 // privileges.
1608 if (opener_web_ui_type_ == 1615 if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) {
1609 WebUIFactory::GetWebUIType(profile(), GetURL())) { 1616 WebUI* web_ui = content::GetContentClient()->browser()->
1610 WebUI* web_ui = WebUIFactory::CreateWebUIForURL(this, GetURL()); 1617 GetWebUIFactory()->CreateWebUIForURL(this, GetURL());
1611 // web_ui might be NULL if the URL refers to a non-existent extension. 1618 // web_ui might be NULL if the URL refers to a non-existent extension.
1612 if (web_ui) { 1619 if (web_ui) {
1613 render_manager_.SetWebUIPostCommit(web_ui); 1620 render_manager_.SetWebUIPostCommit(web_ui);
1614 web_ui->RenderViewCreated(render_view_host()); 1621 web_ui->RenderViewCreated(render_view_host());
1615 } 1622 }
1616 } 1623 }
1617 opener_web_ui_type_ = WebUIFactory::kNoWebUI; 1624 opener_web_ui_type_ = WebUI::kNoWebUI;
1618 } 1625 }
1619 1626
1620 if (details.is_user_initiated_main_frame_load()) { 1627 if (details.is_user_initiated_main_frame_load()) {
1621 // Clear the status bubble. This is a workaround for a bug where WebKit 1628 // Clear the status bubble. This is a workaround for a bug where WebKit
1622 // doesn't let us know that the cursor left an element during a 1629 // doesn't let us know that the cursor left an element during a
1623 // transition (this is also why the mouse cursor remains as a hand after 1630 // transition (this is also why the mouse cursor remains as a hand after
1624 // clicking on a link); see bugs 1184641 and 980803. We don't want to 1631 // clicking on a link); see bugs 1184641 and 980803. We don't want to
1625 // clear the bubble when a user navigates to a named anchor in the same 1632 // clear the bubble when a user navigates to a named anchor in the same
1626 // page. 1633 // page.
1627 UpdateTargetURL(details.entry->page_id(), GURL()); 1634 UpdateTargetURL(details.entry->page_id(), GURL());
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 NotificationService::current()->Notify( 1994 NotificationService::current()->Notify(
1988 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, 1995 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
1989 Source<TabContents>(this), 1996 Source<TabContents>(this),
1990 Details<RenderViewHost>(render_view_host)); 1997 Details<RenderViewHost>(render_view_host));
1991 NavigationEntry* entry = controller_.GetActiveEntry(); 1998 NavigationEntry* entry = controller_.GetActiveEntry();
1992 if (!entry) 1999 if (!entry)
1993 return; 2000 return;
1994 2001
1995 // When we're creating views, we're still doing initial setup, so we always 2002 // When we're creating views, we're still doing initial setup, so we always
1996 // use the pending Web UI rather than any possibly existing committed one. 2003 // use the pending Web UI rather than any possibly existing committed one.
1997 if (render_manager_.pending_web_ui()) { 2004 if (render_manager_.pending_web_ui())
1998 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); 2005 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host);
1999 }
2000 2006
2001 if (entry->IsViewSourceMode()) { 2007 if (entry->IsViewSourceMode()) {
2002 // Put the renderer in view source mode. 2008 // Put the renderer in view source mode.
2003 render_view_host->Send( 2009 render_view_host->Send(
2004 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); 2010 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id()));
2005 } 2011 }
2006 2012
2007 view()->RenderViewCreated(render_view_host); 2013 view()->RenderViewCreated(render_view_host);
2008 } 2014 }
2009 2015
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 2570
2565 void TabContents::NotifySwappedFromRenderManager() { 2571 void TabContents::NotifySwappedFromRenderManager() {
2566 NotifySwapped(); 2572 NotifySwapped();
2567 } 2573 }
2568 2574
2569 NavigationController& TabContents::GetControllerForRenderManager() { 2575 NavigationController& TabContents::GetControllerForRenderManager() {
2570 return controller(); 2576 return controller();
2571 } 2577 }
2572 2578
2573 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { 2579 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
2574 return WebUIFactory::CreateWebUIForURL(this, url); 2580 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url);
2575 } 2581 }
2576 2582
2577 NavigationEntry* 2583 NavigationEntry*
2578 TabContents::GetLastCommittedNavigationEntryForRenderManager() { 2584 TabContents::GetLastCommittedNavigationEntryForRenderManager() {
2579 return controller_.GetLastCommittedEntry(); 2585 return controller_.GetLastCommittedEntry();
2580 } 2586 }
2581 2587
2582 bool TabContents::CreateRenderViewForRenderManager( 2588 bool TabContents::CreateRenderViewForRenderManager(
2583 RenderViewHost* render_view_host) { 2589 RenderViewHost* render_view_host) {
2584 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); 2590 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 2757
2752 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2758 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2753 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2759 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2754 rwh_view->SetSize(view()->GetContainerSize()); 2760 rwh_view->SetSize(view()->GetContainerSize());
2755 } 2761 }
2756 2762
2757 void TabContents::OnOnlineStateChanged(bool online) { 2763 void TabContents::OnOnlineStateChanged(bool online) {
2758 render_view_host()->Send(new ViewMsg_NetworkStateChanged( 2764 render_view_host()->Send(new ViewMsg_NetworkStateChanged(
2759 render_view_host()->routing_id(), online)); 2765 render_view_host()->routing_id(), online));
2760 } 2766 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/browser/tab_contents/tab_contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698