diff options
Diffstat (limited to 'content')
49 files changed, 320 insertions, 536 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 73d885e..bca737d 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -275,8 +275,9 @@ void ContentViewCoreImpl::InitWebContents() { this, NOTIFICATION_WEB_CONTENTS_CONNECTED, Source<WebContents>(web_contents_)); - static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> - SetContentViewCore(this); + static_cast<WebContentsViewAndroid*>( + static_cast<WebContentsImpl*>(web_contents_)->GetView())-> + SetContentViewCore(this); DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); web_contents_->SetUserData(kContentViewUserDataKey, new ContentViewUserData(this)); @@ -422,13 +423,6 @@ void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { } } -void ContentViewCoreImpl::OnTabCrashed() { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); - if (obj.is_null()) - return; -} - // All positions and sizes are in CSS pixels. // Note that viewport_width/height is a best effort based. // ContentViewCore has the actual information about the physical viewport size. @@ -1656,8 +1650,8 @@ void ContentViewCoreImpl::OnSmartClipDataExtracted( } void ContentViewCoreImpl::WebContentsDestroyed(WebContents* web_contents) { - WebContentsViewAndroid* wcva = - static_cast<WebContentsViewAndroid*>(web_contents->GetView()); + WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( + static_cast<WebContentsImpl*>(web_contents)->GetView()); DCHECK(wcva); wcva->SetContentViewCore(NULL); } diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index e1ebb3a..07e2dd1 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -239,8 +239,6 @@ class ContentViewCoreImpl : public ContentViewCore, // Hides a visible popup menu. void HideSelectPopupMenu(); - void OnTabCrashed(); - // All sizes and offsets are in CSS pixels as cached by the renderer. void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, float page_scale_factor, diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc index 16864ab..2d04235 100644 --- a/content/browser/android/download_controller_android_impl.cc +++ b/content/browser/android/download_controller_android_impl.cc @@ -22,7 +22,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/download_url_parameters.h" #include "content/public/browser/global_request_id.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/referrer.h" #include "jni/DownloadController_jni.h" #include "net/cookies/cookie_options.h" diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 5e398bf..9480e9d 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -35,7 +35,6 @@ #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" #include "content/public/common/drop_data.h" #include "content/public/common/media_stream_request.h" diff --git a/content/browser/frame_host/interstitial_page_impl.cc b/content/browser/frame_host/interstitial_page_impl.cc index 15a232d..b103c7f 100644 --- a/content/browser/frame_host/interstitial_page_impl.cc +++ b/content/browser/frame_host/interstitial_page_impl.cc @@ -24,10 +24,10 @@ #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/site_instance_impl.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/frame_messages.h" #include "content/common/view_messages.h" #include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" @@ -283,7 +283,7 @@ void InterstitialPageImpl::Hide() { if (render_view_host_->GetView() && render_view_host_->GetView()->HasFocus() && controller_->delegate()->GetRenderViewHost()->GetView()) { - controller_->delegate()->GetRenderViewHost()->GetView()->Focus(); + controller_->delegate()->GetRenderViewHost()->Focus(); } // Delete this and call Shutdown on the RVH asynchronously, as we may have @@ -576,11 +576,10 @@ RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { WebContentsView* InterstitialPageImpl::CreateWebContentsView() { if (!enabled() || !create_view_) return NULL; - WebContentsView* web_contents_view = web_contents()->GetView(); - WebContentsViewPort* web_contents_view_port = - static_cast<WebContentsViewPort*>(web_contents_view); + WebContentsView* wcv = + static_cast<WebContentsImpl*>(web_contents())->GetView(); RenderWidgetHostViewBase* view = - web_contents_view_port->CreateViewForWidget(render_view_host_); + wcv->CreateViewForWidget(render_view_host_); render_view_host_->SetView(view); render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION); @@ -592,10 +591,10 @@ WebContentsView* InterstitialPageImpl::CreateWebContentsView() { false); controller_->delegate()->RenderFrameForInterstitialPageCreated( frame_tree_.root()->current_frame_host()); - view->SetSize(web_contents_view->GetContainerSize()); + view->SetSize(web_contents()->GetContainerBounds().size()); // Don't show the interstitial until we have navigated to it. view->Hide(); - return web_contents_view; + return wcv; } void InterstitialPageImpl::Proceed() { @@ -703,7 +702,7 @@ void InterstitialPageImpl::Focus() { // Focus the native window. if (!enabled()) return; - render_view_host_->GetView()->Focus(); + render_view_host_->Focus(); } void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) { diff --git a/content/browser/frame_host/interstitial_page_impl.h b/content/browser/frame_host/interstitial_page_impl.h index cc9dc63..8cb1419 100644 --- a/content/browser/frame_host/interstitial_page_impl.h +++ b/content/browser/frame_host/interstitial_page_impl.h @@ -27,7 +27,6 @@ class NavigationControllerImpl; class RenderViewHostImpl; class RenderWidgetHostView; class WebContentsView; -class WebContentsImpl; enum ResourceRequestAction { BLOCK, diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc index bf4312e..e3847f9 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc @@ -1070,7 +1070,7 @@ void RenderFrameHostManager::CommitPending() { delegate_->SetFocusToLocationBar(false); } else if (focus_render_view && render_frame_host_->render_view_host()->GetView()) { - render_frame_host_->render_view_host()->GetView()->Focus(); + render_frame_host_->render_view_host()->Focus(); } // Notify that we've swapped RenderFrameHosts. We do this before shutting down diff --git a/content/browser/media/webrtc_internals.cc b/content/browser/media/webrtc_internals.cc index 7a1254c..ccee569 100644 --- a/content/browser/media/webrtc_internals.cc +++ b/content/browser/media/webrtc_internals.cc @@ -6,12 +6,12 @@ #include "base/command_line.h" #include "content/browser/media/webrtc_internals_ui_observer.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" using base::ProcessId; @@ -232,7 +232,7 @@ void WebRTCInternals::EnableAecDump(content::WebContents* web_contents) { NULL, 0, FILE_PATH_LITERAL(""), - web_contents->GetView()->GetTopLevelNativeWindow(), + web_contents->GetTopLevelNativeWindow(), NULL); #endif #endif diff --git a/content/browser/web_contents/aura/gesture_nav_simple.cc b/content/browser/web_contents/aura/gesture_nav_simple.cc index 7ae0557..44f16bc 100644 --- a/content/browser/web_contents/aura/gesture_nav_simple.cc +++ b/content/browser/web_contents/aura/gesture_nav_simple.cc @@ -8,8 +8,8 @@ #include "content/browser/frame_host/navigation_controller_impl.h" #include "content/browser/renderer_host/overscroll_controller.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/overscroll_configuration.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_client.h" #include "grit/ui_resources.h" #include "ui/aura/window.h" @@ -159,7 +159,7 @@ void GestureNavSimple::ApplyEffectsForDelta(float delta_x) { } gfx::Rect GestureNavSimple::GetVisibleBounds() const { - return web_contents_->GetView()->GetNativeView()->bounds(); + return web_contents_->GetNativeView()->bounds(); } void GestureNavSimple::OnOverscrollUpdate(float delta_x, float delta_y) { @@ -199,7 +199,7 @@ void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode, arrow_->set_delegate(arrow_delegate_.get()); arrow_->SetFillsBoundsOpaquely(false); - aura::Window* window = web_contents_->GetView()->GetNativeView(); + aura::Window* window = web_contents_->GetNativeView(); const gfx::Rect& window_bounds = window->bounds(); completion_threshold_ = window_bounds.width() * GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE); diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc index 1e24364..829b7dc 100644 --- a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc @@ -6,8 +6,8 @@ #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/web_contents/aura/image_window_delegate.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/view_messages.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/test/mock_render_process_host.h" #include "content/test/test_render_view_host.h" #include "content/test/test_web_contents.h" diff --git a/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc b/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc index c1641dc..0479984 100644 --- a/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc +++ b/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc @@ -12,7 +12,6 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_view_aura.h" #include "content/public/browser/render_frame_host.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" @@ -140,8 +139,7 @@ class TouchEditableImplAuraTest : public ContentBrowserTest { ASSERT_TRUE(test_server()->Start()); GURL test_url(test_server()->GetURL(url)); NavigateToURL(shell(), test_url); - aura::Window* content = - shell()->web_contents()->GetView()->GetContentNativeView(); + aura::Window* content = shell()->web_contents()->GetContentNativeView(); content->GetHost()->SetBounds(gfx::Rect(800, 600)); } @@ -176,7 +174,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, view_aura->SetTouchEditableForTest(touch_editable); RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( web_contents->GetRenderWidgetHostView()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); aura::test::EventGenerator generator(content->GetRootWindow(), content); gfx::Rect bounds = content->GetBoundsInRootWindow(); @@ -362,7 +360,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, view_aura->SetTouchEditableForTest(touch_editable); RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( web_contents->GetRenderWidgetHostView()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); aura::test::EventGenerator generator(content->GetRootWindow(), content); gfx::Rect bounds = content->GetBoundsInRootWindow(); EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 5e97aa8..d3a3145 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -74,7 +74,6 @@ #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/bindings_policy.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" @@ -96,6 +95,7 @@ #if defined(OS_ANDROID) #include "content/browser/android/date_time_chooser_android.h" +#include "content/browser/media/android/browser_media_player_manager.h" #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h" #include "content/browser/web_contents/web_contents_android.h" #include "content/common/java_bridge_messages.h" @@ -1025,7 +1025,7 @@ WebContents* WebContentsImpl::Clone() { // We pass our own opener so that the cloned page can access it if it was // before. CreateParams create_params(GetBrowserContext(), GetSiteInstance()); - create_params.initial_size = view_->GetContainerSize(); + create_params.initial_size = GetContainerBounds().size(); WebContentsImpl* tc = CreateWithOpener(create_params, opener_); tc->GetController().CopyStateFrom(controller_); FOR_EACH_OBSERVER(WebContentsObserver, @@ -1068,30 +1068,24 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { params.browser_context, params.site_instance, params.routing_id, params.main_frame_routing_id); - view_.reset(GetContentClient()->browser()-> - OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); - if (view_) { - CHECK(render_view_host_delegate_view_); + WebContentsViewDelegate* delegate = + GetContentClient()->browser()->GetWebContentsViewDelegate(this); + + if (browser_plugin_guest_) { + scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( + this, delegate, &render_view_host_delegate_view_)); + + WebContentsViewGuest* rv = new WebContentsViewGuest( + this, browser_plugin_guest_.get(), platform_view.Pass(), + render_view_host_delegate_view_); + render_view_host_delegate_view_ = rv; + view_.reset(rv); } else { - WebContentsViewDelegate* delegate = - GetContentClient()->browser()->GetWebContentsViewDelegate(this); - - if (browser_plugin_guest_) { - scoped_ptr<WebContentsViewPort> platform_view(CreateWebContentsView( - this, delegate, &render_view_host_delegate_view_)); - - WebContentsViewGuest* rv = new WebContentsViewGuest( - this, browser_plugin_guest_.get(), platform_view.Pass(), - render_view_host_delegate_view_); - render_view_host_delegate_view_ = rv; - view_.reset(rv); - } else { - // Regular WebContentsView. - view_.reset(CreateWebContentsView( - this, delegate, &render_view_host_delegate_view_)); - } - CHECK(render_view_host_delegate_view_); + // Regular WebContentsView. + view_.reset(CreateWebContentsView( + this, delegate, &render_view_host_delegate_view_)); } + CHECK(render_view_host_delegate_view_); CHECK(view_.get()); gfx::Size initial_size = params.initial_size; @@ -1428,7 +1422,7 @@ void WebContentsImpl::CreateNewWindow( create_params.main_frame_routing_id = main_frame_route_id; if (!is_guest) { create_params.context = view_->GetNativeView(); - create_params.initial_size = view_->GetContainerSize(); + create_params.initial_size = GetContainerBounds().size(); } else { // This makes |new_contents| act as a guest. // For more info, see comment above class BrowserPluginGuest. @@ -1448,7 +1442,7 @@ void WebContentsImpl::CreateNewWindow( // will be shown immediately). if (!params.opener_suppressed) { if (!is_guest) { - WebContentsViewPort* new_view = new_contents->view_.get(); + WebContentsView* new_view = new_contents->view_.get(); // TODO(brettw): It seems bogus that we have to call this function on the // newly created object and give it one of its own member variables. @@ -1948,6 +1942,48 @@ void WebContentsImpl::ExecuteCustomContextMenuCommand( focused_frame->GetRoutingID(), context, action)); } +gfx::NativeView WebContentsImpl::GetNativeView() { + return view_->GetNativeView(); +} + +gfx::NativeView WebContentsImpl::GetContentNativeView() { + return view_->GetContentNativeView(); +} + +gfx::NativeWindow WebContentsImpl::GetTopLevelNativeWindow() { + return view_->GetTopLevelNativeWindow(); +} + +gfx::Rect WebContentsImpl::GetViewBounds() { + return view_->GetViewBounds(); +} + +gfx::Rect WebContentsImpl::GetContainerBounds() { + gfx::Rect rv; + view_->GetContainerBounds(&rv); + return rv; +} + +DropData* WebContentsImpl::GetDropData() { + return view_->GetDropData(); +} + +void WebContentsImpl::Focus() { + view_->Focus(); +} + +void WebContentsImpl::SetInitialFocus() { + view_->SetInitialFocus(); +} + +void WebContentsImpl::StoreFocus() { + view_->StoreFocus(); +} + +void WebContentsImpl::RestoreFocus() { + view_->RestoreFocus(); +} + void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { if (ShowingInterstitialPage()) { GetRenderManager()->interstitial_page()->FocusThroughTabTraversal(reverse); @@ -3266,7 +3302,11 @@ void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, SetIsLoading(rvh, false, true, NULL); NotifyDisconnected(); SetIsCrashed(status, error_code); - GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); + +#if defined(OS_ANDROID) + if (GetRenderViewHostImpl()->media_player_manager()) + GetRenderViewHostImpl()->media_player_manager()->DestroyAllMediaPlayers(); +#endif FOR_EACH_OBSERVER(WebContentsObserver, observers_, @@ -3800,6 +3840,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager( } #if defined(OS_ANDROID) + base::android::ScopedJavaLocalRef<jobject> WebContentsImpl::GetJavaWebContents() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -3818,6 +3859,27 @@ bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { MSG_ROUTING_NONE, NULL); } + +#elif defined(OS_MACOSX) + +void WebContentsImpl::SetAllowOverlappingViews(bool overlapping) { + view_->SetAllowOverlappingViews(overlapping); +} + +bool WebContentsImpl::GetAllowOverlappingViews() { + return view_->GetAllowOverlappingViews(); +} + +void WebContentsImpl::SetOverlayView(WebContents* overlay, + const gfx::Point& offset) { + view_->SetOverlayView(static_cast<WebContentsImpl*>(overlay)->GetView(), + offset); +} + +void WebContentsImpl::RemoveOverlayView() { + view_->RemoveOverlayView(); +} + #endif void WebContentsImpl::OnDialogClosed(int render_process_id, @@ -3860,7 +3922,7 @@ void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { RenderWidgetHostViewBase* rwh_view = view_->CreateViewForWidget(rvh); // Can be NULL during tests. if (rwh_view) - rwh_view->SetSize(GetView()->GetContainerSize()); + rwh_view->SetSize(GetContainerBounds().size()); } bool WebContentsImpl::IsHidden() { @@ -3908,12 +3970,12 @@ void WebContentsImpl::ClearAllPowerSaveBlockers() { power_save_blockers_.clear(); } -gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { +gfx::Size WebContentsImpl::GetSizeForNewRenderView() { gfx::Size size; if (delegate_) size = delegate_->GetSizeForNewRenderView(this); if (size.IsEmpty()) - size = view_->GetContainerSize(); + size = GetContainerBounds().size(); return size; } diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 0482083..1aa619a 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -63,7 +63,7 @@ class TestWebContents; class WebContentsDelegate; class WebContentsImpl; class WebContentsObserver; -class WebContentsViewPort; +class WebContentsView; class WebContentsViewDelegate; struct AXEventNotificationDetails; struct ColorSuggestion; @@ -74,7 +74,7 @@ struct ResourceRequestDetails; // Factory function for the implementations that content knows about. Takes // ownership of |delegate|. -WebContentsViewPort* CreateWebContentsView( +WebContentsView* CreateWebContentsView( WebContentsImpl* web_contents, WebContentsViewDelegate* delegate, RenderViewHostDelegateView** render_view_host_delegate_view); @@ -174,6 +174,8 @@ class CONTENT_EXPORT WebContentsImpl RenderViewHost* render_view_host, const ResourceRedirectDetails& details); + WebContentsView* GetView() const; + // WebContents ------------------------------------------------------ virtual WebContentsDelegate* GetDelegate() OVERRIDE; virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE; @@ -196,7 +198,6 @@ class CONTENT_EXPORT WebContentsImpl virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE; virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const OVERRIDE; - virtual WebContentsView* GetView() const OVERRIDE; virtual WebUI* CreateWebUI(const GURL& url) OVERRIDE; virtual WebUI* GetWebUI() const OVERRIDE; virtual WebUI* GetCommittedWebUI() const OVERRIDE; @@ -254,6 +255,16 @@ class CONTENT_EXPORT WebContentsImpl const CustomContextMenuContext& context) OVERRIDE; virtual void ExecuteCustomContextMenuCommand( int action, const CustomContextMenuContext& context) OVERRIDE; + virtual gfx::NativeView GetNativeView() OVERRIDE; + virtual gfx::NativeView GetContentNativeView() OVERRIDE; + virtual gfx::NativeWindow GetTopLevelNativeWindow() OVERRIDE; + virtual gfx::Rect GetContainerBounds() OVERRIDE; + virtual gfx::Rect GetViewBounds() OVERRIDE; + virtual DropData* GetDropData() OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void SetInitialFocus() OVERRIDE; + virtual void StoreFocus() OVERRIDE; + virtual void RestoreFocus() OVERRIDE; virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE; virtual bool ShowingInterstitialPage() const OVERRIDE; virtual InterstitialPage* GetInterstitialPage() const OVERRIDE; @@ -307,6 +318,12 @@ class CONTENT_EXPORT WebContentsImpl #if defined(OS_ANDROID) virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() OVERRIDE; +#elif defined(OS_MACOSX) + virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; + virtual bool GetAllowOverlappingViews() OVERRIDE; + virtual void SetOverlayView(WebContents* overlay, + const gfx::Point& offset) OVERRIDE; + virtual void RemoveOverlayView() OVERRIDE; #endif // Implementation of PageNavigator. @@ -841,7 +858,7 @@ class CONTENT_EXPORT WebContentsImpl void ClearAllPowerSaveBlockers(); // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). - gfx::Size GetSizeForNewRenderView() const; + gfx::Size GetSizeForNewRenderView(); void OnFrameRemoved(RenderViewHostImpl* render_view_host, int frame_routing_id); @@ -865,7 +882,7 @@ class CONTENT_EXPORT WebContentsImpl NavigationControllerImpl controller_; // The corresponding view. - scoped_ptr<WebContentsViewPort> view_; + scoped_ptr<WebContentsView> view_; // The view of the RVHD. Usually this is our WebContentsView implementation, // but if an embedder uses a different WebContentsView, they'll need to diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc index b414ccd..a8ada8f 100644 --- a/content/browser/web_contents/web_contents_impl_browsertest.cc +++ b/content/browser/web_contents/web_contents_impl_browsertest.cc @@ -6,6 +6,7 @@ #include "base/values.h" #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/load_notification_details.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/notification_details.h" @@ -14,7 +15,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_paths.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" @@ -40,7 +40,8 @@ void ResizeWebContentsView(Shell* shell, const gfx::Size& size, if (set_start_page) NavigateToURL(shell, GURL("about://blank")); #else - shell->web_contents()->GetView()->SizeContents(size); + static_cast<WebContentsImpl*>(shell->web_contents())->GetView()-> + SizeContents(size); #endif // defined(OS_MACOSX) } @@ -113,8 +114,8 @@ class RenderViewSizeDelegate : public WebContentsDelegate { // WebContentsDelegate: virtual gfx::Size GetSizeForNewRenderView( - const WebContents* web_contents) const OVERRIDE { - gfx::Size size(web_contents->GetView()->GetContainerSize()); + WebContents* web_contents) const OVERRIDE { + gfx::Size size(web_contents->GetContainerBounds().size()); size.Enlarge(size_insets_.width(), size_insets_.height()); return size; } @@ -284,7 +285,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, // When no size is set, RenderWidgetHostView adopts the size of // WebContentsView. NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")); - EXPECT_EQ(shell()->web_contents()->GetView()->GetContainerSize(), + EXPECT_EQ(shell()->web_contents()->GetContainerBounds().size(), shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). size()); @@ -308,7 +309,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, #endif EXPECT_EQ(exp_wcv_size, - shell()->web_contents()->GetView()->GetContainerSize()); + shell()->web_contents()->GetContainerBounds().size()); // If WebContentsView is resized after RenderWidgetHostView is created but // before pending navigation entry is committed, both RenderWidgetHostView and @@ -334,7 +335,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, GetViewBounds().size(); EXPECT_EQ(new_size, actual_size); - EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); + EXPECT_EQ(new_size, shell()->web_contents()->GetContainerBounds().size()); } IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, OpenURLSubframe) { diff --git a/content/public/browser/web_contents_view.h b/content/browser/web_contents/web_contents_view.h index 8405945..b2eb509 100644 --- a/content/public/browser/web_contents_view.h +++ b/content/browser/web_contents/web_contents_view.h @@ -2,25 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_ -#define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_ +#ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_ +#define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_ #include <string> #include "base/basictypes.h" -#include "base/process/kill.h" +#include "base/strings/string16.h" #include "content/common/content_export.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" namespace content { +class RenderViewHost; +class RenderWidgetHost; +class RenderWidgetHostViewBase; struct DropData; // The WebContentsView is an interface that is implemented by the platform- // dependent web contents views. The WebContents uses this interface to talk to // them. -class CONTENT_EXPORT WebContentsView { +class WebContentsView { public: virtual ~WebContentsView() {} @@ -40,17 +43,6 @@ class CONTENT_EXPORT WebContentsView { // the tab in the screen coordinate system. virtual void GetContainerBounds(gfx::Rect* out) const = 0; - // Helper function for GetContainerBounds. Most callers just want to know the - // size, and this makes it more clear. - gfx::Size GetContainerSize() const { - gfx::Rect rc; - GetContainerBounds(&rc); - return gfx::Size(rc.width(), rc.height()); - } - - // Used to notify the view that a tab has crashed. - virtual void OnTabCrashed(base::TerminationStatus status, int error_code) = 0; - // TODO(brettw) this is a hack. It's used in two places at the time of this // writing: (1) when render view hosts switch, we need to size the replaced // one to be correct, since it wouldn't have known about sizes that happened @@ -81,6 +73,36 @@ class CONTENT_EXPORT WebContentsView { // Get the bounds of the View, relative to the parent. virtual gfx::Rect GetViewBounds() const = 0; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) = 0; + + // Sets up the View that holds the rendered web page, receives messages for + // it and contains page plugins. The host view should be sized to the current + // size of the WebContents. + virtual RenderWidgetHostViewBase* CreateViewForWidget( + RenderWidgetHost* render_widget_host) = 0; + + // Creates a new View that holds a popup and receives messages for it. + virtual RenderWidgetHostViewBase* CreateViewForPopupWidget( + RenderWidgetHost* render_widget_host) = 0; + + // Sets the page title for the native widgets corresponding to the view. This + // is not strictly necessary and isn't expected to be displayed anywhere, but + // can aid certain debugging tools such as Spy++ on Windows where you are + // trying to find a specific window. + virtual void SetPageTitle(const base::string16& title) = 0; + + // Invoked when the WebContents is notified that the RenderView has been + // fully created. + virtual void RenderViewCreated(RenderViewHost* host) = 0; + + // Invoked when the WebContents is notified that the RenderView has been + // swapped in. + virtual void RenderViewSwappedIn(RenderViewHost* host) = 0; + + // Invoked to enable/disable overscroll gesture navigation. + virtual void SetOverscrollControllerEnabled(bool enabled) = 0; + #if defined(OS_MACOSX) // The web contents view assumes that its view will never be overlapped by // another view (either partially or fully). This allows it to perform @@ -99,9 +121,17 @@ class CONTENT_EXPORT WebContentsView { // Removes the previously set overlay view. virtual void RemoveOverlayView() = 0; + + // If we close the tab while a UI control is in an event-tracking + // loop, the control may message freed objects and crash. + // WebContents::Close() calls IsEventTracking(), and if it returns + // true CloseTabAfterEventTracking() is called and the close is not + // completed. + virtual bool IsEventTracking() const = 0; + virtual void CloseTabAfterEventTracking() = 0; #endif }; } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_H_ +#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_ diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index 2e9eb2e..3378595 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "content/browser/android/content_view_core_impl.h" #include "content/browser/frame_host/interstitial_page_impl.h" -#include "content/browser/media/android/browser_media_player_manager.h" #include "content/browser/renderer_host/render_widget_host_view_android.h" #include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_impl.h" @@ -15,7 +14,7 @@ #include "content/public/browser/web_contents_delegate.h" namespace content { -WebContentsViewPort* CreateWebContentsView( +WebContentsView* CreateWebContentsView( WebContentsImpl* web_contents, WebContentsViewDelegate* delegate, RenderViewHostDelegateView** render_view_host_delegate_view) { @@ -76,16 +75,6 @@ void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { content_view_core_->SetTitle(title); } -void WebContentsViewAndroid::OnTabCrashed(base::TerminationStatus status, - int error_code) { - RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( - web_contents_->GetRenderViewHost()); - if (rvh->media_player_manager()) - rvh->media_player_manager()->DestroyAllMediaPlayers(); - if (content_view_core_) - content_view_core_->OnTabCrashed(); -} - void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { // TODO(klobag): Do we need to do anything else? RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index 621da26..697dfa4 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -6,18 +6,18 @@ #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ #include "base/memory/scoped_ptr.h" -#include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" #include "content/public/browser/web_contents_view_delegate.h" #include "content/public/common/context_menu_params.h" #include "ui/gfx/rect_f.h" namespace content { class ContentViewCoreImpl; +class WebContentsImpl; // Android-specific implementation of the WebContentsView. -class WebContentsViewAndroid : public WebContentsViewPort, +class WebContentsViewAndroid : public WebContentsView, public RenderViewHostDelegateView { public: WebContentsViewAndroid(WebContentsImpl* web_contents, @@ -34,8 +34,6 @@ class WebContentsViewAndroid : public WebContentsViewPort, virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; virtual void SizeContents(const gfx::Size& size) OVERRIDE; virtual void Focus() OVERRIDE; virtual void SetInitialFocus() OVERRIDE; @@ -43,8 +41,6 @@ class WebContentsViewAndroid : public WebContentsViewPort, virtual void RestoreFocus() OVERRIDE; virtual DropData* GetDropData() const OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; - - // WebContentsViewPort implementation ---------------------------------------- virtual void CreateView( const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostViewBase* CreateViewForWidget( diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 0de1e76..968f902 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -70,7 +70,7 @@ #include "ui/wm/public/drag_drop_delegate.h" namespace content { -WebContentsViewPort* CreateWebContentsView( +WebContentsView* CreateWebContentsView( WebContentsImpl* web_contents, WebContentsViewDelegate* delegate, RenderViewHostDelegateView** render_view_host_delegate_view) { @@ -159,7 +159,7 @@ class OverscrollWindowDelegate : public ImageWindowDelegate { web_contents_window()->delegate()->OnGestureEvent(event); } - WebContents* web_contents_; + WebContentsImpl* web_contents_; // The window is displayed both during the gesture, and after the gesture // while the navigation is in progress. During the gesture, it is necessary to @@ -979,10 +979,6 @@ void WebContentsViewAura::GetContainerBounds(gfx::Rect *out) const { *out = window_->GetBoundsInScreen(); } -void WebContentsViewAura::OnTabCrashed(base::TerminationStatus status, - int error_code) { -} - void WebContentsViewAura::SizeContents(const gfx::Size& size) { gfx::Rect bounds = window_->bounds(); if (bounds.size() != size) { @@ -1035,7 +1031,7 @@ gfx::Rect WebContentsViewAura::GetViewBounds() const { } //////////////////////////////////////////////////////////////////////////////// -// WebContentsViewAura, WebContentsViewPort implementation: +// WebContentsViewAura, WebContentsView implementation: void WebContentsViewAura::CreateView( const gfx::Size& initial_size, gfx::NativeView context) { diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 934b3b5..a4532e5 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -10,9 +10,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/overscroll_controller_delegate.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/content_export.h" #include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" #include "ui/aura/window_delegate.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/wm/public/drag_drop_delegate.h" @@ -35,10 +35,10 @@ class WebContentsViewDelegate; class WebContentsImpl; class WebDragDestDelegate; -class CONTENT_EXPORT WebContentsViewAura - : public WebContentsViewPort, +class WebContentsViewAura + : public WebContentsView, public RenderViewHostDelegateView, - NON_EXPORTED_BASE(public OverscrollControllerDelegate), + public OverscrollControllerDelegate, public ui::ImplicitAnimationObserver, public aura::WindowDelegate, public aura::client::DragDropDelegate { @@ -46,9 +46,10 @@ class CONTENT_EXPORT WebContentsViewAura WebContentsViewAura(WebContentsImpl* web_contents, WebContentsViewDelegate* delegate); - void SetupOverlayWindowForTesting(); + CONTENT_EXPORT void SetupOverlayWindowForTesting(); - void SetTouchEditableForTest(TouchEditableImplAura* touch_editable); + CONTENT_EXPORT void SetTouchEditableForTest( + TouchEditableImplAura* touch_editable); private: class WindowObserver; @@ -105,8 +106,6 @@ class CONTENT_EXPORT WebContentsViewAura virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; virtual void SizeContents(const gfx::Size& size) OVERRIDE; virtual void Focus() OVERRIDE; virtual void SetInitialFocus() OVERRIDE; @@ -114,8 +113,6 @@ class CONTENT_EXPORT WebContentsViewAura virtual void RestoreFocus() OVERRIDE; virtual DropData* GetDropData() const OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; - - // Overridden from WebContentsViewPort: virtual void CreateView( const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostViewBase* CreateViewForWidget( diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index adfebd1..92f275da 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -16,9 +16,9 @@ #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" @@ -182,7 +182,7 @@ class WebContentsViewAuraTest : public ContentBrowserTest { EXPECT_TRUE(controller.CanGoBack()); EXPECT_FALSE(controller.CanGoForward()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); const int kScrollDurationMs = 20; @@ -319,7 +319,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, web_contents->GetController().GoBack(); EXPECT_EQ(1, GetCurrentIndex()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); gfx::Rect bounds = content->GetBoundsInRootWindow(); @@ -442,7 +442,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, MAYBE_OverscrollScreenshot) { // index 3 to index 2, and index 3 should have a screenshot. base::string16 expected_title = base::ASCIIToUTF16("Title: #2"); content::TitleWatcher title_watcher(web_contents, expected_title); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); generator.GestureScrollSequence( @@ -582,7 +582,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ExecuteSyncJSFunction(web_contents->GetMainFrame(), "navigate_next()"); EXPECT_EQ(1, GetCurrentIndex()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); generator.GestureScrollSequence( @@ -591,7 +591,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, base::TimeDelta::FromMilliseconds(20), 1); - window->AddChild(shell()->web_contents()->GetView()->GetContentNativeView()); + window->AddChild(shell()->web_contents()->GetContentNativeView()); } IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, @@ -604,7 +604,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ExecuteSyncJSFunction(web_contents->GetMainFrame(), "navigate_next()"); EXPECT_EQ(1, GetCurrentIndex()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); generator.GestureScrollSequence( @@ -613,7 +613,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, base::TimeDelta::FromMilliseconds(20), 1); - delete web_contents->GetView()->GetContentNativeView(); + delete web_contents->GetContentNativeView(); } IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, @@ -644,7 +644,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, EXPECT_TRUE(controller.CanGoBack()); EXPECT_TRUE(controller.CanGoForward()); - aura::Window* content = web_contents->GetView()->GetContentNativeView(); + aura::Window* content = web_contents->GetContentNativeView(); gfx::Rect bounds = content->GetBoundsInRootWindow(); aura::test::EventGenerator generator(content->GetRootWindow(), content); diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index e1417e3..9ebb060 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc @@ -34,7 +34,7 @@ namespace content { WebContentsViewGuest::WebContentsViewGuest( WebContentsImpl* web_contents, BrowserPluginGuest* guest, - scoped_ptr<WebContentsViewPort> platform_view, + scoped_ptr<WebContentsView> platform_view, RenderViewHostDelegateView* platform_view_delegate_view) : web_contents_(web_contents), guest_(guest), @@ -57,7 +57,7 @@ gfx::NativeView WebContentsViewGuest::GetContentNativeView() const { } gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const { - return guest_->embedder_web_contents()->GetView()->GetTopLevelNativeWindow(); + return guest_->embedder_web_contents()->GetTopLevelNativeWindow(); } void WebContentsViewGuest::OnGuestInitialized(WebContentsView* parent_view) { @@ -204,10 +204,6 @@ void WebContentsViewGuest::RestoreFocus() { platform_view_->RestoreFocus(); } -void WebContentsViewGuest::OnTabCrashed(base::TerminationStatus status, - int error_code) { -} - void WebContentsViewGuest::Focus() { platform_view_->Focus(); } diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h index f11e491..086b37e 100644 --- a/content/browser/web_contents/web_contents_view_guest.h +++ b/content/browser/web_contents/web_contents_view_guest.h @@ -8,10 +8,10 @@ #include <vector> #include "base/memory/scoped_ptr.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/content_export.h" #include "content/common/drag_event_source_info.h" #include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" namespace content { @@ -19,9 +19,8 @@ class WebContents; class WebContentsImpl; class BrowserPluginGuest; -class CONTENT_EXPORT WebContentsViewGuest - : public WebContentsViewPort, - public RenderViewHostDelegateView { +class WebContentsViewGuest : public WebContentsView, + public RenderViewHostDelegateView { public: // The corresponding WebContentsImpl is passed in the constructor, and manages // our lifetime. This doesn't need to be the case, but is this way currently @@ -30,7 +29,7 @@ class CONTENT_EXPORT WebContentsViewGuest // |platform_view|. WebContentsViewGuest(WebContentsImpl* web_contents, BrowserPluginGuest* guest, - scoped_ptr<WebContentsViewPort> platform_view, + scoped_ptr<WebContentsView> platform_view, RenderViewHostDelegateView* platform_view_delegate_view); virtual ~WebContentsViewGuest(); @@ -44,13 +43,10 @@ class CONTENT_EXPORT WebContentsViewGuest const ContextMenuParams& params) const; // WebContentsView implementation -------------------------------------------- - virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; virtual void SizeContents(const gfx::Size& size) OVERRIDE; virtual void Focus() OVERRIDE; virtual void SetInitialFocus() OVERRIDE; @@ -58,15 +54,6 @@ class CONTENT_EXPORT WebContentsViewGuest virtual void RestoreFocus() OVERRIDE; virtual DropData* GetDropData() const OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; -#if defined(OS_MACOSX) - virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; - virtual bool GetAllowOverlappingViews() const OVERRIDE; - virtual void SetOverlayView(WebContentsView* overlay, - const gfx::Point& offset) OVERRIDE; - virtual void RemoveOverlayView() OVERRIDE; -#endif - - // WebContentsViewPort implementation ---------------------------------------- virtual void CreateView(const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostViewBase* CreateViewForWidget( @@ -78,6 +65,11 @@ class CONTENT_EXPORT WebContentsViewGuest virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; #if defined(OS_MACOSX) + virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; + virtual bool GetAllowOverlappingViews() const OVERRIDE; + virtual void SetOverlayView(WebContentsView* overlay, + const gfx::Point& offset) OVERRIDE; + virtual void RemoveOverlayView() OVERRIDE; virtual bool IsEventTracking() const OVERRIDE; virtual void CloseTabAfterEventTracking() OVERRIDE; #endif @@ -100,7 +92,7 @@ class CONTENT_EXPORT WebContentsViewGuest BrowserPluginGuest* guest_; // The platform dependent view backing this WebContentsView. // Calls to this WebContentsViewGuest are forwarded to |platform_view_|. - scoped_ptr<WebContentsViewPort> platform_view_; + scoped_ptr<WebContentsView> platform_view_; gfx::Size size_; // Delegate view for guest's platform view. diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index c531c6a..08fbc4e 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h @@ -12,10 +12,10 @@ #include "base/mac/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/content_export.h" #include "content/common/drag_event_source_info.h" #include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" #include "ui/base/cocoa/base_view.h" #include "ui/gfx/size.h" @@ -55,7 +55,7 @@ namespace content { // Mac-specific implementation of the WebContentsView. It owns an NSView that // contains all of the contents of the tab and associated child views. -class WebContentsViewMac : public WebContentsViewPort, +class WebContentsViewMac : public WebContentsView, public RenderViewHostDelegateView { public: // The corresponding WebContentsImpl is passed in the constructor, and manages @@ -70,8 +70,6 @@ class WebContentsViewMac : public WebContentsViewPort, virtual gfx::NativeView GetContentNativeView() const OVERRIDE; virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; virtual void SizeContents(const gfx::Size& size) OVERRIDE; virtual void Focus() OVERRIDE; virtual void SetInitialFocus() OVERRIDE; @@ -84,8 +82,6 @@ class WebContentsViewMac : public WebContentsViewPort, virtual void SetOverlayView(WebContentsView* overlay, const gfx::Point& offset) OVERRIDE; virtual void RemoveOverlayView() OVERRIDE; - - // WebContentsViewPort implementation ---------------------------------------- virtual void CreateView( const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostViewBase* CreateViewForWidget( diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index a1a6e1f..39e579b 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -68,7 +68,7 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); @end namespace content { -WebContentsViewPort* CreateWebContentsView( +WebContentsView* CreateWebContentsView( WebContentsImpl* web_contents, WebContentsViewDelegate* delegate, RenderViewHostDelegateView** render_view_host_delegate_view) { @@ -152,10 +152,6 @@ void WebContentsViewMac::StartDragging( offset:offset]; } -void WebContentsViewMac::OnTabCrashed(base::TerminationStatus /* status */, - int /* error_code */) { -} - void WebContentsViewMac::SizeContents(const gfx::Size& size) { // TODO(brettw | japhet) This is a hack and should be removed. // See web_contents_view.h. diff --git a/content/browser/webui/web_ui_impl.cc b/content/browser/webui/web_ui_impl.cc index 8641919..445bbeb 100644 --- a/content/browser/webui/web_ui_impl.cc +++ b/content/browser/webui/web_ui_impl.cc @@ -11,12 +11,12 @@ #include "content/browser/renderer_host/dip_util.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" #include "content/common/view_messages.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_message_handler.h" #include "content/public/common/bindings_policy.h" diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 99fc3f0..c1e052e 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -42,7 +42,6 @@ 'port/browser/location_provider.h', 'port/browser/render_view_host_delegate_view.h', 'port/browser/vibration_provider.h', - 'port/browser/web_contents_view_port.h', 'public/browser/access_token_store.h', 'public/browser/android/compositor.h', 'public/browser/android/compositor_client.h', @@ -207,7 +206,6 @@ 'public/browser/web_contents_observer.cc', 'public/browser/web_contents_observer.h', 'public/browser/web_contents_user_data.h', - 'public/browser/web_contents_view.h', 'public/browser/web_contents_view_delegate.h', 'public/browser/web_drag_dest_delegate.h', 'public/browser/web_ui.h', @@ -1313,6 +1311,7 @@ 'browser/web_contents/web_contents_android.h', 'browser/web_contents/web_contents_impl.cc', 'browser/web_contents/web_contents_impl.h', + 'browser/web_contents/web_contents_view.h', 'browser/web_contents/web_contents_view_android.cc', 'browser/web_contents/web_contents_view_android.h', 'browser/web_contents/web_contents_view_aura.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 5d6fdd3..9aed0d6 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -202,8 +202,6 @@ 'test/test_render_view_host_factory.h', 'test/test_web_contents.cc', 'test/test_web_contents.h', - 'test/test_web_contents_view.cc', - 'test/test_web_contents_view.h', 'test/web_gesture_curve_mock.cc', 'test/web_gesture_curve_mock.h', 'test/weburl_loader_mock.cc', diff --git a/content/port/browser/web_contents_view_port.h b/content/port/browser/web_contents_view_port.h deleted file mode 100644 index 60632ae..0000000 --- a/content/port/browser/web_contents_view_port.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PORT_BROWSER_WEB_CONTENTS_VIEW_PORT_H_ -#define CONTENT_PORT_BROWSER_WEB_CONTENTS_VIEW_PORT_H_ - -#include "content/public/browser/web_contents_view.h" - -namespace content { -class RenderViewHost; -class RenderWidgetHost; -class RenderWidgetHostViewBase; - -// This is the larger WebContentsView interface exposed only within content/ and -// to embedders looking to port to new platforms. -class CONTENT_EXPORT WebContentsViewPort : public WebContentsView { - public: - virtual ~WebContentsViewPort() {} - - virtual void CreateView( - const gfx::Size& initial_size, gfx::NativeView context) = 0; - - // Sets up the View that holds the rendered web page, receives messages for - // it and contains page plugins. The host view should be sized to the current - // size of the WebContents. - virtual RenderWidgetHostViewBase* CreateViewForWidget( - RenderWidgetHost* render_widget_host) = 0; - - // Creates a new View that holds a popup and receives messages for it. - virtual RenderWidgetHostViewBase* CreateViewForPopupWidget( - RenderWidgetHost* render_widget_host) = 0; - - // Sets the page title for the native widgets corresponding to the view. This - // is not strictly necessary and isn't expected to be displayed anywhere, but - // can aid certain debugging tools such as Spy++ on Windows where you are - // trying to find a specific window. - virtual void SetPageTitle(const base::string16& title) = 0; - - // Invoked when the WebContents is notified that the RenderView has been - // fully created. - virtual void RenderViewCreated(RenderViewHost* host) = 0; - - // Invoked when the WebContents is notified that the RenderView has been - // swapped in. - virtual void RenderViewSwappedIn(RenderViewHost* host) = 0; - - // Invoked to enable/disable overscroll gesture navigation. - virtual void SetOverscrollControllerEnabled(bool enabled) = 0; - -#if defined(OS_MACOSX) - // If we close the tab while a UI control is in an event-tracking - // loop, the control may message freed objects and crash. - // WebContents::Close() calls IsEventTracking(), and if it returns - // true CloseTabAfterEventTracking() is called and the close is not - // completed. - virtual bool IsEventTracking() const = 0; - virtual void CloseTabAfterEventTracking() = 0; -#endif -}; - -} // namespace content - -#endif // CONTENT_PORT_BROWSER_WEB_CONTENTS_VIEW_PORT_H_ diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index ba80b8f..fb8279b 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -15,12 +15,6 @@ BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts( return NULL; } -WebContentsViewPort* ContentBrowserClient::OverrideCreateWebContentsView( - WebContents* web_contents, - RenderViewHostDelegateView** render_view_host_delegate_view) { - return NULL; -} - WebContentsViewDelegate* ContentBrowserClient::GetWebContentsViewDelegate( WebContents* web_contents) { return NULL; diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index ac40ae2..5f0473b 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -95,14 +95,12 @@ class QuotaPermissionContext; class RenderFrameHost; class RenderProcessHost; class RenderViewHost; -class RenderViewHostDelegateView; class ResourceContext; class SiteInstance; class SpeechRecognitionManagerDelegate; class VibrationProvider; class WebContents; class WebContentsViewDelegate; -class WebContentsViewPort; struct MainFunctionParams; struct Referrer; struct ShowDesktopNotificationHostMsgParams; @@ -135,14 +133,6 @@ class CONTENT_EXPORT ContentBrowserClient { virtual BrowserMainParts* CreateBrowserMainParts( const MainFunctionParams& parameters); - // Allows an embedder to return their own WebContentsViewPort implementation. - // Return NULL to let the default one for the platform be created. Otherwise - // |render_view_host_delegate_view| also needs to be provided, and it is - // owned by the embedder. - virtual WebContentsViewPort* OverrideCreateWebContentsView( - WebContents* web_contents, - RenderViewHostDelegateView** render_view_host_delegate_view); - // If content creates the WebContentsView implementation, it will ask the // embedder to return an (optional) delegate to customize it. The view will // own the delegate. diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 0e0ed9b..fd31c1a 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -23,7 +23,7 @@ #include "third_party/skia/include/core/SkColor.h" #include "ui/base/window_open_disposition.h" #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/size.h" +#include "ui/gfx/rect.h" #if defined(OS_ANDROID) #include "base/android/scoped_java_ref.h" @@ -37,11 +37,6 @@ namespace blink { struct WebFindOptions; } -namespace gfx { -class Rect; -class Size; -} - namespace net { struct LoadStateWithParam; } @@ -57,8 +52,8 @@ class RenderViewHost; class RenderWidgetHostView; class SiteInstance; class WebContentsDelegate; -class WebContentsView; struct CustomContextMenuContext; +struct DropData; struct RendererPreferences; // WebContents is the core class in content/. A WebContents renders web content @@ -68,7 +63,7 @@ struct RendererPreferences; // scoped_ptr<content::WebContents> web_contents( // content::WebContents::Create( // content::WebContents::CreateParams(browser_context))); -// gfx::NativeView view = web_contents->GetView()->GetNativeView(); +// gfx::NativeView view = web_contents->GetNativeView(); // // |view| is an HWND, NSView*, GtkWidget*, etc.; insert it into the view // // hierarchy wherever it needs to go. // @@ -210,9 +205,6 @@ class WebContents : public PageNavigator, // NULL. virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const = 0; - // The WebContentsView will never change and is guaranteed non-NULL. - virtual WebContentsView* GetView() const = 0; - // Create a WebUI page for the given url. In most cases, this doesn't need to // be called by embedders since content will create its own WebUI objects as // necessary. However if the embedder wants to create its own WebUI object and @@ -372,6 +364,42 @@ class WebContents : public PageNavigator, // Views and focus ----------------------------------------------------------- + // Returns the native widget that contains the contents of the tab. + virtual gfx::NativeView GetNativeView() = 0; + + // Returns the native widget with the main content of the tab (i.e. the main + // render view host, though there may be many popups in the tab as children of + // the container). + virtual gfx::NativeView GetContentNativeView() = 0; + + // Returns the outermost native view. This will be used as the parent for + // dialog boxes. + virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0; + + // Computes the rectangle for the native widget that contains the contents of + // the tab in the screen coordinate system. + virtual gfx::Rect GetContainerBounds() = 0; + + // Get the bounds of the View, relative to the parent. + virtual gfx::Rect GetViewBounds() = 0; + + // Returns the current drop data, if any. + virtual DropData* GetDropData() = 0; + + // Sets focus to the native widget for this tab. + virtual void Focus() = 0; + + // Sets focus to the appropriate element when the WebContents is shown the + // first time. + virtual void SetInitialFocus() = 0; + + // Stores the currently focused view. + virtual void StoreFocus() = 0; + + // Restores focus to the last focus view. If StoreFocus has not yet been + // invoked, SetInitialFocus is invoked. + virtual void RestoreFocus() = 0; + // Focuses the first (last if |reverse| is true) element in the page. // Invoked when this tab is getting the focus through tab traversal (|reverse| // is true when using Shift-Tab). @@ -545,6 +573,24 @@ class WebContents : public PageNavigator, CONTENT_EXPORT static WebContents* FromJavaWebContents( jobject jweb_contents_android); virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0; +#elif defined(OS_MACOSX) + // The web contents view assumes that its view will never be overlapped by + // another view (either partially or fully). This allows it to perform + // optimizations. If the view is in a view hierarchy where it might be + // overlapped by another view, notify the view by calling this with |true|. + virtual void SetAllowOverlappingViews(bool overlapping) = 0; + + // Returns true if overlapping views are allowed, false otherwise. + virtual bool GetAllowOverlappingViews() = 0; + + // To draw two overlapping web contents view, the underlaying one should + // know about the overlaying one. Caller must ensure that |overlay| exists + // until |RemoveOverlayView| is called. + virtual void SetOverlayView(WebContents* overlay, + const gfx::Point& offset) = 0; + + // Removes the previously set overlay view. + virtual void RemoveOverlayView() = 0; #endif // OS_ANDROID private: diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc index 5346c2a..9a26e0f 100644 --- a/content/public/browser/web_contents_delegate.cc +++ b/content/public/browser/web_contents_delegate.cc @@ -196,7 +196,7 @@ void WebContentsDelegate::Detach(WebContents* web_contents) { } gfx::Size WebContentsDelegate::GetSizeForNewRenderView( - const WebContents* web_contents) const { + WebContents* web_contents) const { return gfx::Size(); } diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index d22d7c7..0edb3bd 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -447,8 +447,7 @@ class CONTENT_EXPORT WebContentsDelegate { // This is optional for implementations of WebContentsDelegate; if the // delegate doesn't provide a size, the current WebContentsView's size will be // used. - virtual gfx::Size GetSizeForNewRenderView( - const WebContents* web_contents) const; + virtual gfx::Size GetSizeForNewRenderView(WebContents* web_contents) const; // Notification that validation of a form displayed by the |web_contents| // has failed. There can only be one message per |web_contents| at a time. diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index d81f391..21f48a8 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -14,6 +14,7 @@ #include "base/synchronization/waitable_event.h" #include "base/test/test_timeouts.h" #include "base/values.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/dom_operation_notification_details.h" #include "content/public/browser/notification_service.h" @@ -23,7 +24,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/test/test_utils.h" #include "grit/webui_resources.h" #include "net/base/filename_util.h" @@ -221,8 +221,8 @@ void CrashTab(WebContents* web_contents) { void SimulateMouseClick(WebContents* web_contents, int modifiers, blink::WebMouseEvent::Button button) { - int x = web_contents->GetView()->GetContainerSize().width() / 2; - int y = web_contents->GetView()->GetContainerSize().height() / 2; + int x = web_contents->GetContainerBounds().width() / 2; + int y = web_contents->GetContainerBounds().height() / 2; SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y)); } @@ -237,8 +237,7 @@ void SimulateMouseClickAt(WebContents* web_contents, mouse_event.y = point.y(); mouse_event.modifiers = modifiers; // Mac needs globalX/globalY for events to plugins. - gfx::Rect offset; - web_contents->GetView()->GetContainerBounds(&offset); + gfx::Rect offset = web_contents->GetContainerBounds(); mouse_event.globalX = point.x() + offset.x(); mouse_event.globalY = point.y() + offset.y(); mouse_event.clickCount = 1; diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc index e55fb85..9fbd5cf 100644 --- a/content/shell/browser/shell.cc +++ b/content/shell/browser/shell.cc @@ -18,7 +18,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/renderer_preferences.h" #include "content/shell/browser/notify_done_forwarder.h" #include "content/shell/browser/shell_browser_main_parts.h" @@ -176,7 +175,7 @@ void Shell::LoadURLForFrame(const GURL& url, const std::string& frame_name) { PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); params.frame_name = frame_name; web_contents_->GetController().LoadURLWithParams(params); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); } void Shell::LoadDataWithBaseURL(const GURL& url, const std::string& data, @@ -188,7 +187,7 @@ void Shell::LoadDataWithBaseURL(const GURL& url, const std::string& data, params.virtual_url_for_data_url = url; params.override_user_agent = NavigationController::UA_OVERRIDE_FALSE; web_contents_->GetController().LoadURLWithParams(params); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); } void Shell::AddNewContents(WebContents* source, @@ -204,17 +203,17 @@ void Shell::AddNewContents(WebContents* source, void Shell::GoBackOrForward(int offset) { web_contents_->GetController().GoToOffset(offset); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); } void Shell::Reload() { web_contents_->GetController().Reload(false); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); } void Shell::Stop() { web_contents_->Stop(); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); } void Shell::UpdateNavigationControls(bool to_different_document) { @@ -252,7 +251,7 @@ void Shell::CloseDevTools() { gfx::NativeView Shell::GetContentView() { if (!web_contents_) return NULL; - return web_contents_->GetView()->GetNativeView(); + return web_contents_->GetNativeView(); } WebContents* Shell::OpenURLFromTab(WebContents* source, diff --git a/content/shell/browser/shell_aura.cc b/content/shell/browser/shell_aura.cc index ccfa1f6..33ee197 100644 --- a/content/shell/browser/shell_aura.cc +++ b/content/shell/browser/shell_aura.cc @@ -5,7 +5,6 @@ #include "content/shell/browser/shell.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/shell/browser/shell_platform_data_aura.h" #include "ui/aura/env.h" #include "ui/aura/test/test_screen.h" @@ -50,7 +49,7 @@ void Shell::PlatformCreateWindow(int width, int height) { void Shell::PlatformSetContents() { CHECK(platform_); - aura::Window* content = web_contents_->GetView()->GetNativeView(); + aura::Window* content = web_contents_->GetNativeView(); aura::Window* parent = platform_->host()->window(); if (parent->Contains(content)) return; diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc index a25df91..6d0e1f0 100644 --- a/content/shell/browser/shell_devtools_frontend.cc +++ b/content/shell/browser/shell_devtools_frontend.cc @@ -13,7 +13,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_client.h" #include "content/shell/browser/shell.h" #include "content/shell/browser/shell_browser_context.h" @@ -90,7 +89,7 @@ void ShellDevToolsFrontend::Activate() { } void ShellDevToolsFrontend::Focus() { - web_contents()->GetView()->Focus(); + web_contents()->Focus(); } void ShellDevToolsFrontend::InspectElementAt(int x, int y) { diff --git a/content/shell/browser/shell_download_manager_delegate.cc b/content/shell/browser/shell_download_manager_delegate.cc index 45f86f3..9f37d82 100644 --- a/content/shell/browser/shell_download_manager_delegate.cc +++ b/content/shell/browser/shell_download_manager_delegate.cc @@ -19,7 +19,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/shell/browser/webkit_test_controller.h" #include "content/shell/common/shell_switches.h" #include "net/base/filename_util.h" @@ -171,7 +170,7 @@ void ShellDownloadManagerDelegate::ChooseDownloadPath( OPENFILENAME save_as; ZeroMemory(&save_as, sizeof(save_as)); save_as.lStructSize = sizeof(OPENFILENAME); - save_as.hwndOwner = item->GetWebContents()->GetView()->GetNativeView()-> + save_as.hwndOwner = item->GetWebContents()->GetNativeView()-> GetHost()->GetAcceleratedWidget(); save_as.lpstrFile = file_name; save_as.nMaxFile = arraysize(file_name); diff --git a/content/shell/browser/shell_javascript_dialog_manager.cc b/content/shell/browser/shell_javascript_dialog_manager.cc index ef284e2..ae08633 100644 --- a/content/shell/browser/shell_javascript_dialog_manager.cc +++ b/content/shell/browser/shell_javascript_dialog_manager.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/shell/browser/shell_javascript_dialog.h" #include "content/shell/browser/webkit_test_controller.h" #include "content/shell/common/shell_switches.h" @@ -55,8 +54,7 @@ void ShellJavaScriptDialogManager::RunJavaScriptDialog( base::string16 new_message_text = net::FormatUrl(origin_url, accept_lang) + base::ASCIIToUTF16("\n\n") + message_text; - gfx::NativeWindow parent_window = - web_contents->GetView()->GetTopLevelNativeWindow(); + gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); dialog_.reset(new ShellJavaScriptDialog(this, parent_window, @@ -99,8 +97,7 @@ void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( message_text + base::ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); - gfx::NativeWindow parent_window = - web_contents->GetView()->GetTopLevelNativeWindow(); + gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); dialog_.reset(new ShellJavaScriptDialog(this, parent_window, diff --git a/content/shell/browser/shell_mac.mm b/content/shell/browser/shell_mac.mm index a51c852..f332064 100644 --- a/content/shell/browser/shell_mac.mm +++ b/content/shell/browser/shell_mac.mm @@ -12,7 +12,6 @@ #include "base/strings/sys_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/shell/app/resource.h" #import "ui/base/cocoa/underlay_opengl_hosting_window.h" #include "url/gurl.h" @@ -243,7 +242,7 @@ void Shell::PlatformCreateWindow(int width, int height) { } void Shell::PlatformSetContents() { - NSView* web_view = web_contents_->GetView()->GetNativeView(); + NSView* web_view = web_contents_->GetNativeView(); [web_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; if (headless_) { @@ -267,7 +266,7 @@ void Shell::SizeTo(const gfx::Size& content_size) { [window().contentView setFrame:frame]; return; } - NSView* web_view = web_contents_->GetView()->GetNativeView(); + NSView* web_view = web_contents_->GetNativeView(); NSRect frame = NSMakeRect(0, 0, content_size.width(), content_size.height()); [web_view setFrame:frame]; } diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc index 6bc61b1..fda7fbc 100644 --- a/content/shell/browser/shell_views.cc +++ b/content/shell/browser/shell_views.cc @@ -8,7 +8,6 @@ #include "base/strings/utf_string_conversions.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" #include "content/shell/browser/shell_platform_data_aura.h" #include "ui/aura/client/screen_position_client.h" @@ -138,7 +137,7 @@ class ShellWindowDelegateView : public views::WidgetDelegateView, web_view_ = new views::WebView(web_contents->GetBrowserContext()); web_view_->SetWebContents(web_contents); web_view_->SetPreferredSize(size); - web_contents->GetView()->Focus(); + web_contents->Focus(); contents_view_->AddChildView(web_view_); Layout(); @@ -174,7 +173,7 @@ class ShellWindowDelegateView : public views::WidgetDelegateView, // Convert from content coordinates to window coordinates. // This code copied from chrome_web_contents_view_delegate_views.cc aura::Window* web_contents_window = - shell_->web_contents()->GetView()->GetNativeView(); + shell_->web_contents()->GetNativeView(); aura::Window* root_window = web_contents_window->GetRootWindow(); aura::client::ScreenPositionClient* screen_position_client = aura::client::GetScreenPositionClient(root_window); @@ -514,7 +513,7 @@ void Shell::PlatformCreateWindow(int width, int height) { void Shell::PlatformSetContents() { if (headless_) { CHECK(platform_); - aura::Window* content = web_contents_->GetView()->GetNativeView(); + aura::Window* content = web_contents_->GetNativeView(); aura::Window* parent = platform_->host()->window(); if (!parent->Contains(content)) { parent->AddChild(content); diff --git a/content/shell/browser/shell_web_contents_view_delegate_android.cc b/content/shell/browser/shell_web_contents_view_delegate_android.cc index fb4a3dc..bd2d186 100644 --- a/content/shell/browser/shell_web_contents_view_delegate_android.cc +++ b/content/shell/browser/shell_web_contents_view_delegate_android.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "content/public/browser/android/content_view_core.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" diff --git a/content/shell/browser/shell_web_contents_view_delegate_mac.mm b/content/shell/browser/shell_web_contents_view_delegate_mac.mm index cd825d5..375112f 100644 --- a/content/shell/browser/shell_web_contents_view_delegate_mac.mm +++ b/content/shell/browser/shell_web_contents_view_delegate_mac.mm @@ -12,7 +12,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" #include "content/shell/browser/shell.h" #include "content/shell/browser/shell_browser_context.h" @@ -202,7 +201,7 @@ void ShellWebContentsViewDelegate::ShowContextMenu( YES, delegate); - NSView* parent_view = web_contents_->GetView()->GetContentNativeView(); + NSView* parent_view = web_contents_->GetContentNativeView(); NSEvent* currentEvent = [NSApp currentEvent]; NSWindow* window = [parent_view window]; NSPoint position = [window mouseLocationOutsideOfEventStream]; @@ -248,15 +247,15 @@ void ShellWebContentsViewDelegate::ActionPerformed(int tag) { } case ShellContextMenuItemBackTag: web_contents_->GetController().GoToOffset(-1); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; case ShellContextMenuItemForwardTag: web_contents_->GetController().GoToOffset(1); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; case ShellContextMenuItemReloadTag: { web_contents_->GetController().Reload(false); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; } case ShellContextMenuItemInspectTag: { diff --git a/content/shell/browser/shell_web_contents_view_delegate_win.cc b/content/shell/browser/shell_web_contents_view_delegate_win.cc index 81d9b0d..9eb834d 100644 --- a/content/shell/browser/shell_web_contents_view_delegate_win.cc +++ b/content/shell/browser/shell_web_contents_view_delegate_win.cc @@ -10,7 +10,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/context_menu_params.h" #include "content/shell/browser/shell.h" #include "content/shell/browser/shell_browser_context.h" @@ -175,14 +174,14 @@ void ShellWebContentsViewDelegate::ShowContextMenu( #else gfx::Point screen_point(params.x, params.y); POINT point = screen_point.ToPOINT(); - ClientToScreen(web_contents_->GetView()->GetNativeView(), &point); + ClientToScreen(web_contents_->GetNativeView(), &point); int selection = TrackPopupMenu(sub_menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, point.x, point.y, 0, - web_contents_->GetView()->GetContentNativeView(), + web_contents_->GetContentNativeView(), NULL); MenuItemSelected(selection); @@ -216,15 +215,15 @@ void ShellWebContentsViewDelegate::MenuItemSelected(int selection) { } case ShellContextMenuItemBackId: web_contents_->GetController().GoToOffset(-1); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; case ShellContextMenuItemForwardId: web_contents_->GetController().GoToOffset(1); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; case ShellContextMenuItemReloadId: web_contents_->GetController().Reload(false); - web_contents_->GetView()->Focus(); + web_contents_->Focus(); break; case ShellContextMenuItemInspectId: { ShellDevToolsFrontend::Show(web_contents_); diff --git a/content/shell/browser/webkit_test_controller.cc b/content/shell/browser/webkit_test_controller.cc index d16986b..3256b20 100644 --- a/content/shell/browser/webkit_test_controller.cc +++ b/content/shell/browser/webkit_test_controller.cc @@ -24,7 +24,6 @@ #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/content_switches.h" #include "content/public/common/url_constants.h" #include "content/shell/browser/shell.h" @@ -277,7 +276,7 @@ bool WebKitTestController::PrepareForLayoutTest( PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); params.should_clear_history_list = true; main_window_->web_contents()->GetController().LoadURLWithParams(params); - main_window_->web_contents()->GetView()->Focus(); + main_window_->web_contents()->Focus(); } main_window_->web_contents()->GetRenderViewHost()->SetActive(true); main_window_->web_contents()->GetRenderViewHost()->Focus(); diff --git a/content/test/test_content_browser_client.cc b/content/test/test_content_browser_client.cc index 7b9d368..c917f25 100644 --- a/content/test/test_content_browser_client.cc +++ b/content/test/test_content_browser_client.cc @@ -4,11 +4,8 @@ #include "content/test/test_content_browser_client.h" -#include <string> - #include "base/files/file_path.h" #include "base/logging.h" -#include "content/test/test_web_contents_view.h" namespace content { @@ -18,18 +15,6 @@ TestContentBrowserClient::TestContentBrowserClient() { TestContentBrowserClient::~TestContentBrowserClient() { } -WebContentsViewPort* TestContentBrowserClient::OverrideCreateWebContentsView( - WebContents* web_contents, - RenderViewHostDelegateView** render_view_host_delegate_view) { -#if defined(OS_IOS) - return NULL; -#else - TestWebContentsView* rv = new TestWebContentsView; - *render_view_host_delegate_view = rv; - return rv; -#endif -} - base::FilePath TestContentBrowserClient::GetDefaultDownloadDirectory() { if (!download_dir_.IsValid()) { bool result = download_dir_.CreateUniqueTempDir(); diff --git a/content/test/test_content_browser_client.h b/content/test/test_content_browser_client.h index f0d58bb..b4ff3f9 100644 --- a/content/test/test_content_browser_client.h +++ b/content/test/test_content_browser_client.h @@ -19,10 +19,6 @@ class TestContentBrowserClient : public ContentBrowserClient { public: TestContentBrowserClient(); virtual ~TestContentBrowserClient(); - - virtual WebContentsViewPort* OverrideCreateWebContentsView( - WebContents* web_contents, - RenderViewHostDelegateView** render_view_host_delegate_view) OVERRIDE; virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE; private: diff --git a/content/test/test_web_contents_view.cc b/content/test/test_web_contents_view.cc deleted file mode 100644 index b7d663b..0000000 --- a/content/test/test_web_contents_view.cc +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/test/test_web_contents_view.h" - -namespace content { - -TestWebContentsView::TestWebContentsView() { -} - -TestWebContentsView::~TestWebContentsView() { -} - -void TestWebContentsView::StartDragging( - const DropData& drop_data, - blink::WebDragOperationsMask allowed_ops, - const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset, - const DragEventSourceInfo& event_info) { -} - -void TestWebContentsView::UpdateDragCursor(blink::WebDragOperation operation) { -} - -void TestWebContentsView::GotFocus() { -} - -void TestWebContentsView::TakeFocus(bool reverse) { -} - -gfx::NativeView TestWebContentsView::GetNativeView() const { - return gfx::NativeView(); -} - -gfx::NativeView TestWebContentsView::GetContentNativeView() const { - return gfx::NativeView(); -} - -gfx::NativeWindow TestWebContentsView::GetTopLevelNativeWindow() const { - return gfx::NativeWindow(); -} - -void TestWebContentsView::GetContainerBounds(gfx::Rect *out) const { -} - -void TestWebContentsView::OnTabCrashed(base::TerminationStatus status, - int error_code) { -} - -void TestWebContentsView::SizeContents(const gfx::Size& size) { -} - -void TestWebContentsView::Focus() { -} - -void TestWebContentsView::SetInitialFocus() { -} - -void TestWebContentsView::StoreFocus() { -} - -void TestWebContentsView::RestoreFocus() { -} - -DropData* TestWebContentsView::GetDropData() const { - return NULL; -} - -gfx::Rect TestWebContentsView::GetViewBounds() const { - return gfx::Rect(); -} - -#if defined(OS_MACOSX) -void TestWebContentsView::SetAllowOverlappingViews(bool overlapping) { -} - -bool TestWebContentsView::GetAllowOverlappingViews() const { - return false; -} - -void TestWebContentsView::SetOverlayView( - WebContentsView* overlay, const gfx::Point& offset) { -} - -void TestWebContentsView::RemoveOverlayView() { -} -#endif - -void TestWebContentsView::CreateView(const gfx::Size& initial_size, - gfx::NativeView context) { -} - -RenderWidgetHostViewBase* TestWebContentsView::CreateViewForWidget( - RenderWidgetHost* render_widget_host) { - return NULL; -} - -RenderWidgetHostViewBase* TestWebContentsView::CreateViewForPopupWidget( - RenderWidgetHost* render_widget_host) { - return NULL; -} - -void TestWebContentsView::SetPageTitle(const base::string16& title) { -} - -void TestWebContentsView::RenderViewCreated(RenderViewHost* host) { -} - -void TestWebContentsView::RenderViewSwappedIn(RenderViewHost* host) { -} - -void TestWebContentsView::SetOverscrollControllerEnabled(bool enabled) { -} - -#if defined(OS_MACOSX) -bool TestWebContentsView::IsEventTracking() const { - return false; -} - -void TestWebContentsView::CloseTabAfterEventTracking() { -} -#endif - -} // namespace content diff --git a/content/test/test_web_contents_view.h b/content/test/test_web_contents_view.h deleted file mode 100644 index 36a7117..0000000 --- a/content/test/test_web_contents_view.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_TEST_TEST_WEB_CONTENTS_VIEW_H_ -#define CONTENT_TEST_TEST_WEB_CONTENTS_VIEW_H_ - -#include "base/compiler_specific.h" -#include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" - -namespace content { - -class TestWebContentsView : public WebContentsViewPort, - public RenderViewHostDelegateView { - public: - TestWebContentsView(); - virtual ~TestWebContentsView(); - - // RenderViewHostDelegateView: - virtual void StartDragging(const DropData& drop_data, - blink::WebDragOperationsMask allowed_ops, - const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset, - const DragEventSourceInfo& event_info) OVERRIDE; - virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE; - virtual void GotFocus() OVERRIDE; - virtual void TakeFocus(bool reverse) OVERRIDE; - - // WebContentsView: - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeView GetContentNativeView() const OVERRIDE; - virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; - virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; - virtual void SizeContents(const gfx::Size& size) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void SetInitialFocus() OVERRIDE; - virtual void StoreFocus() OVERRIDE; - virtual void RestoreFocus() OVERRIDE; - virtual DropData* GetDropData() const OVERRIDE; - virtual gfx::Rect GetViewBounds() const OVERRIDE; -#if defined(OS_MACOSX) - virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; - virtual bool GetAllowOverlappingViews() const OVERRIDE; - virtual void SetOverlayView(WebContentsView* overlay, - const gfx::Point& offset) OVERRIDE; - virtual void RemoveOverlayView() OVERRIDE; -#endif - - // WebContentsViewPort: - virtual void CreateView(const gfx::Size& initial_size, - gfx::NativeView context) OVERRIDE; - virtual RenderWidgetHostViewBase* CreateViewForWidget( - RenderWidgetHost* render_widget_host) OVERRIDE; - virtual RenderWidgetHostViewBase* CreateViewForPopupWidget( - RenderWidgetHost* render_widget_host) OVERRIDE; - virtual void SetPageTitle(const base::string16& title) OVERRIDE; - virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; - virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; - virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; -#if defined(OS_MACOSX) - virtual bool IsEventTracking() const OVERRIDE; - virtual void CloseTabAfterEventTracking() OVERRIDE; -#endif - - private: - DISALLOW_COPY_AND_ASSIGN(TestWebContentsView); -}; - -} // namespace content - -#endif // CONTENT_TEST_TEST_WEB_CONTENTS_VIEW_H_ |