diff options
19 files changed, 835 insertions, 147 deletions
diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index 903c6f3..29415a8 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -33,7 +33,7 @@ class BackingStore { #if defined(OS_WIN) HDC hdc() { return hdc_; } -#else +#elif defined(OS_POSIX) skia::PlatformCanvas* canvas() { return &canvas_; } #endif diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index abd3661..e244c83 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -19,6 +19,7 @@ #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/tab_contents/web_contents.h" @@ -34,10 +35,6 @@ #include "chrome/browser/debugger/debugger_wrapper.h" #endif -#if !defined(OS_MACOSX) -#include "chrome/browser/renderer_host/render_widget_host_view.h" -#endif - using base::TimeDelta; namespace { diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h new file mode 100644 index 0000000..d7d1e4d --- /dev/null +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -0,0 +1,116 @@ +// Copyright (c) 2006-2008 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ +#define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ + +#import <Cocoa/Cocoa.h> + +#include "base/time.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" + +class RenderWidgetHostViewMac; + +// This is the NSView that lives in the Cocoa view hierarchy. In Windows-land, +// RenderWidgetHostViewWin is both the view and the delegate. We split the roles +// but that means that the view needs to own the delegate and will dispose of it +// when it's removed from the view system. + +@interface RenderWidgetHostViewCocoa : NSView { + @private + RenderWidgetHostViewMac* renderWidgetHostView_; +} + +@end + +/////////////////////////////////////////////////////////////////////////////// +// RenderWidgetHostViewMac +// +// An object representing the "View" of a rendered web page. This object is +// responsible for displaying the content of the web page, and integrating with +// the Cocoa view system. It is the implementation of the RenderWidgetHostView +// that the cross-platform RenderWidgetHost object uses +// to display the data. +// +// Comment excerpted from render_widget_host.h: +// +// "The lifetime of the RenderWidgetHost* is tied to the render process. +// If the render process dies, the RenderWidgetHost* goes away and all +// references to it must become NULL." +// +class RenderWidgetHostViewMac : public RenderWidgetHostView { + public: + // The view will associate itself with the given widget. The native view must + // be hooked up immediately to the view hierarchy, or else when it is + // deleted it will delete this out from under the caller. + explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); + virtual ~RenderWidgetHostViewMac(); + + RenderWidgetHost* render_widget_host() const { return render_widget_host_; } + + base::TimeTicks& whiteout_start_time() { return whiteout_start_time_; } + + gfx::NativeView GetNativeView() const; + + // Implementation of RenderWidgetHostView: + virtual RenderWidgetHost* GetRenderWidgetHost() const; + virtual void DidBecomeSelected(); + virtual void WasHidden(); + virtual void SetSize(const gfx::Size& size); + virtual gfx::NativeView GetPluginNativeView(); + virtual void MovePluginWindows( + const std::vector<WebPluginGeometry>& plugin_window_moves); + virtual void Focus(); + virtual void Blur(); + virtual bool HasFocus(); + virtual void Show(); + virtual void Hide(); + virtual gfx::Rect GetViewBounds() const; + virtual void UpdateCursor(const WebCursor& cursor); + virtual void UpdateCursorIfOverSelf(); + virtual void SetIsLoading(bool is_loading); + virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); + virtual void DidPaintRect(const gfx::Rect& rect); + virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy); + virtual void RendererGone(); + virtual void Destroy(); + virtual void SetTooltipText(const std::wstring& tooltip_text); + + private: + // Shuts down the render_widget_host_. This is a separate function so we can + // invoke it from the message loop. + void ShutdownHost(); + + // Redraws the window asynchronously. + void Redraw(const gfx::Rect& invalid_rect); + + // The associated view. + RenderWidgetHostViewCocoa* cocoa_view_; // WEAK + + // The associated Model. + RenderWidgetHost* render_widget_host_; + + // The cursor for the page. This is passed up from the renderer. +// WebCursor current_cursor_; // temporarily commented for link issues + + // Indicates if the page is loading. + bool is_loading_; + + // true if the View is not visible. + bool is_hidden_; + + // Tooltips + // The text to be shown in the tooltip, supplied by the renderer. + std::wstring tooltip_text_; + + // The time at which this view started displaying white pixels as a result of + // not having anything to paint (empty backing store from renderer). This + // value returns true for is_null() if we are not recording whiteout times. + base::TimeTicks whiteout_start_time_; + + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); +}; + +#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ + diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm new file mode 100644 index 0000000..9e46373 --- /dev/null +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -0,0 +1,323 @@ +// Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_host_view_mac.h" + +#include "base/histogram.h" +#include "base/sys_string_conversions.h" +#include "chrome/browser/browser_trial.h" +#include "chrome/browser/renderer_host/backing_store.h" +#include "chrome/browser/renderer_host/render_process_host.h" +#include "chrome/browser/renderer_host/render_widget_host.h" +#include "skia/ext/platform_canvas.h" + +@interface RenderWidgetHostViewCocoa (Private) +- (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; +@end + +namespace { + +// Maximum number of characters we allow in a tooltip. +const size_t kMaxTooltipLength = 1024; + +} + +// RenderWidgetHostView -------------------------------------------------------- + +// static +RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( + RenderWidgetHost* widget) { + return new RenderWidgetHostViewMac(widget); +} + +/////////////////////////////////////////////////////////////////////////////// +// RenderWidgetHostViewMac, public: + +RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) + : render_widget_host_(widget), + is_loading_(false), + is_hidden_(false) { + cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] + initWithRenderWidgetHostViewMac:this] autorelease]; + render_widget_host_->set_view(this); +} + +RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { +} + +gfx::NativeView RenderWidgetHostViewMac::GetNativeView() const { + return cocoa_view_; +} + +/////////////////////////////////////////////////////////////////////////////// +// RenderWidgetHostViewMac, RenderWidgetHostView implementation: + +RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { + return render_widget_host_; +} + +void RenderWidgetHostViewMac::DidBecomeSelected() { + if (!is_hidden_) + return; + + is_hidden_ = false; + render_widget_host_->WasRestored(); +} + +void RenderWidgetHostViewMac::WasHidden() { + if (is_hidden_) + return; + + // If we receive any more paint messages while we are hidden, we want to + // ignore them so we don't re-allocate the backing store. We will paint + // everything again when we become selected again. + is_hidden_ = true; + + // If we have a renderer, then inform it that we are being hidden so it can + // reduce its resource utilization. + render_widget_host_->WasHidden(); +} + +void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { + if (is_hidden_) + return; + + NSRect rect = [cocoa_view_ frame]; + rect.size = NSSizeFromCGSize(size.ToCGSize()); + [cocoa_view_ setFrame:rect]; +} + +gfx::NativeView RenderWidgetHostViewMac::GetPluginNativeView() { + NOTIMPLEMENTED(); + return nil; +} + +void RenderWidgetHostViewMac::MovePluginWindows( + const std::vector<WebPluginGeometry>& plugin_window_moves) { + // All plugin stuff is TBD. TODO(avi,awalker): fill in + NOTIMPLEMENTED(); +} + +void RenderWidgetHostViewMac::Focus() { + [[cocoa_view_ window] makeFirstResponder:cocoa_view_]; +} + +void RenderWidgetHostViewMac::Blur() { + [[cocoa_view_ window] makeFirstResponder:nil]; +} + +bool RenderWidgetHostViewMac::HasFocus() { + return [[cocoa_view_ window] firstResponder] == cocoa_view_; +} + +void RenderWidgetHostViewMac::Show() { + [cocoa_view_ setHidden:NO]; + + DidBecomeSelected(); +} + +void RenderWidgetHostViewMac::Hide() { + [cocoa_view_ setHidden:YES]; + + WasHidden(); +} + +gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const { + return gfx::Rect(NSRectToCGRect([cocoa_view_ frame])); +} + +void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { +// current_cursor_ = cursor; // temporarily commented for link issues + UpdateCursorIfOverSelf(); +} + +void RenderWidgetHostViewMac::UpdateCursorIfOverSelf() { + // Do something special (as Windows does) for arrow cursor while loading a + // page? TODO(avi): decide + // TODO(avi): check to see if mouse pointer is within our bounds + // Disabled so we don't have to link in glue... yet +// NSCursor* ns_cursor = current_cursor_.GetCursor(); +// [ns_cursor set]; +} + +void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { + is_loading_ = is_loading; + UpdateCursorIfOverSelf(); +} + +void RenderWidgetHostViewMac::IMEUpdateStatus(int control, + const gfx::Rect& caret_rect) { + NOTIMPLEMENTED(); +} + +void RenderWidgetHostViewMac::Redraw(const gfx::Rect& rect) { + [cocoa_view_ setNeedsDisplayInRect:NSRectFromCGRect(rect.ToCGRect())]; +} + +void RenderWidgetHostViewMac::DidPaintRect(const gfx::Rect& rect) { + if (is_hidden_) + return; + + Redraw(rect); +} + +void RenderWidgetHostViewMac::DidScrollRect( + const gfx::Rect& rect, int dx, int dy) { + if (is_hidden_) + return; + + [cocoa_view_ scrollRect:NSRectFromCGRect(rect.ToCGRect()) + by:NSMakeSize(dx, dy)]; +} + +void RenderWidgetHostViewMac::RendererGone() { + // TODO(darin): keep this around, and draw sad-tab into it. + UpdateCursorIfOverSelf(); + Destroy(); +} + +void RenderWidgetHostViewMac::Destroy() { + // We've been told to destroy. + [cocoa_view_ retain]; + [cocoa_view_ removeFromSuperview]; + [cocoa_view_ autorelease]; +} + +void RenderWidgetHostViewMac::SetTooltipText(const std::wstring& tooltip_text) { + if (tooltip_text != tooltip_text_) { + tooltip_text_ = tooltip_text; + + // Clamp the tooltip length to kMaxTooltipLength. It's a DOS issue on + // Windows; we're just trying to be polite. + if (tooltip_text_.length() > kMaxTooltipLength) + tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength); + + NSString* tooltip_nsstring = base::SysWideToNSString(tooltip_text_); + [cocoa_view_ setToolTip:tooltip_nsstring]; + } +} + +void RenderWidgetHostViewMac::ShutdownHost() { + render_widget_host_->Shutdown(); + // Do not touch any members at this point, |this| has been deleted. +} + +@implementation RenderWidgetHostViewCocoa + +// Tons of stuff goes here, where we grab events going on in Cocoaland and send +// them into the C++ system. TODO(avi): all that jazz + +- (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { + self = [super init]; + if (self != nil) { + renderWidgetHostView_ = r; + } + return self; +} + +- (void)dealloc { + delete renderWidgetHostView_; + + [super dealloc]; +} + +- (void)drawRect:(NSRect)dirtyRect { + DCHECK(renderWidgetHostView_->render_widget_host()->process()->channel()); + + BackingStore* backing_store = + renderWidgetHostView_->render_widget_host()->GetBackingStore(); + skia::PlatformCanvas* canvas = backing_store->canvas(); + + if (backing_store) { + gfx::Rect damaged_rect(NSRectToCGRect(dirtyRect)); + + gfx::Rect bitmap_rect( + 0, 0, backing_store->size().width(), backing_store->size().height()); + + gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect); + if (!paint_rect.IsEmpty()) { + if ([self lockFocusIfCanDraw]) { + CGContextRef context = static_cast<CGContextRef>( + [[NSGraphicsContext currentContext] graphicsPort]); + + CGRect damaged_rect_cg = damaged_rect.ToCGRect(); + canvas->getTopPlatformDevice().DrawToContext( + context, damaged_rect.x(), damaged_rect.y(), + &damaged_rect_cg); + + [self unlockFocus]; + } + } + + // Fill the remaining portion of the damaged_rect with white + if (damaged_rect.right() > bitmap_rect.right()) { + NSRect r; + r.origin.x = std::max(bitmap_rect.right(), damaged_rect.x()); + r.origin.y = std::min(bitmap_rect.bottom(), damaged_rect.bottom()); + r.size.width = damaged_rect.right() - r.origin.x; + r.size.height = damaged_rect.y() - r.origin.y; + [[NSColor whiteColor] set]; + NSRectFill(r); + } + if (damaged_rect.bottom() > bitmap_rect.bottom()) { + NSRect r; + r.origin.x = damaged_rect.x(); + r.origin.y = damaged_rect.bottom(); + r.size.width = damaged_rect.right() - r.origin.x; + r.size.height = std::max(bitmap_rect.bottom(), damaged_rect.y()) - + r.origin.y; + [[NSColor whiteColor] set]; + NSRectFill(r); + } + if (!renderWidgetHostView_->whiteout_start_time().is_null()) { + base::TimeDelta whiteout_duration = base::TimeTicks::Now() - + renderWidgetHostView_->whiteout_start_time(); + + // If field trial is active, report results in special histogram. + static scoped_refptr<FieldTrial> trial( + FieldTrialList::Find(BrowserTrial::kMemoryModelFieldTrial)); + if (trial.get()) { + if (trial->boolean_value()) + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration_trial_high_memory", + whiteout_duration); + else + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration_trial_med_memory", + whiteout_duration); + } else { + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration", whiteout_duration); + } + + // Reset the start time to 0 so that we start recording again the next + // time the backing store is NULL... + renderWidgetHostView_->whiteout_start_time() = base::TimeTicks(); + } + } else { + [[NSColor whiteColor] set]; + NSRectFill(dirtyRect); + if (renderWidgetHostView_->whiteout_start_time().is_null()) + renderWidgetHostView_->whiteout_start_time() = base::TimeTicks::Now(); + } +} + +- (BOOL)canBecomeKeyView { + return YES; // TODO(avi): be smarter +} + +- (BOOL)acceptsFirstResponder { + return YES; // TODO(avi): be smarter +} + +- (BOOL)becomeFirstResponder { + renderWidgetHostView_->render_widget_host()->Focus(); + + return YES; +} + +- (BOOL)resignFirstResponder { + renderWidgetHostView_->render_widget_host()->Blur(); + + return YES; +} + +@end diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h index da6f1e4..380222a 100644 --- a/chrome/browser/renderer_host/test_render_view_host.h +++ b/chrome/browser/renderer_host/test_render_view_host.h @@ -9,6 +9,7 @@ #include "base/message_loop.h" #include "build/build_config.h" #include "chrome/browser/renderer_host/mock_render_process_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/tab_contents/test_web_contents.h" @@ -21,10 +22,6 @@ #include "chrome/common/temp_scaffolding_stubs.h" #endif -#if !defined(OS_MACOSX) -#include "chrome/browser/renderer_host/render_widget_host_view.h" -#endif - class TestWebContents; // This file provides a testing framework for mocking out the RenderProcessHost diff --git a/chrome/browser/shell_dialogs.h b/chrome/browser/shell_dialogs.h index cef931d..bbc3bc7 100644 --- a/chrome/browser/shell_dialogs.h +++ b/chrome/browser/shell_dialogs.h @@ -94,7 +94,7 @@ class SelectFileDialog const std::wstring& default_path, const std::wstring& filter, const std::wstring& default_extension, - gfx::NativeView owning_window, + gfx::NativeWindow owning_window, void* params) = 0; }; diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index b7655a5..c512b9a 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -4,16 +4,11 @@ #include "chrome/browser/tab_contents/render_view_host_manager.h" -#if defined(OS_MACOSX) -#include "chrome/common/temp_scaffolding_stubs.h" -#else -#include "chrome/browser/renderer_host/render_widget_host_view.h" -#endif - #include "base/command_line.h" #include "base/logging.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/site_instance.h" diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index b152a28..f0f39bf 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -20,8 +20,10 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tab_contents/provisional_load_details.h" +#include "chrome/browser/tab_contents/web_contents_view.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" @@ -490,11 +492,12 @@ void WebContents::PopupNotificationVisibilityChanged(bool visible) { render_view_host()->PopupNotificationVisibilityChanged(visible); } -#if defined(OS_WIN) // Stupid view pass-throughs void WebContents::CreateView() { view_->CreateView(); } + +#if defined(OS_WIN) HWND WebContents::GetContainerHWND() const { return view_->GetNativeView(); } diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h index ccd1e2e..3326cb1 100644 --- a/chrome/browser/tab_contents/web_contents.h +++ b/chrome/browser/tab_contents/web_contents.h @@ -128,11 +128,11 @@ class WebContents : public TabContents, virtual void SetDownloadShelfVisible(bool visible); virtual void PopupNotificationVisibilityChanged(bool visible); -#if defined(OS_WIN) // Retarded pass-throughs to the view. // TODO(brettw) fix this, tab contents shouldn't have these methods, probably // it should be killed altogether. virtual void CreateView(); +#if defined(OS_WIN) virtual HWND GetContainerHWND() const; virtual HWND GetContentHWND(); virtual void GetContainerBounds(gfx::Rect *out) const; @@ -390,7 +390,11 @@ class WebContents : public TabContents, friend class TestWebContents; // Temporary until the view/contents separation is complete. +#if defined(OS_WIN) friend class WebContentsViewWin; +#elif defined(OS_MACOSX) + friend class WebContentsViewMac; +#endif // So InterstitialPage can access SetIsLoading. friend class InterstitialPage; diff --git a/chrome/browser/tab_contents/web_contents_view.h b/chrome/browser/tab_contents/web_contents_view.h index 7c8a4e0..4bf8dca 100644 --- a/chrome/browser/tab_contents/web_contents_view.h +++ b/chrome/browser/tab_contents/web_contents_view.h @@ -61,7 +61,7 @@ class WebContentsView : public RenderViewHostDelegate::View { // Returns the outermost native view. This will be used as the parent for // dialog boxes. - virtual gfx::NativeView GetTopLevelNativeView() const = 0; + virtual gfx::NativeWindow GetTopLevelNativeView() const = 0; // Computes the rectangle for the native widget that contains the contents of // the tab relative to its parent. @@ -130,6 +130,7 @@ class WebContentsView : public RenderViewHostDelegate::View { // when the tab comes back. virtual void HideFindBar(bool end_session) = 0; +#if defined(OS_WIN) // Called when the tab is reparented to a new browser window. On MS Windows, // we have to change the parent of our find bar to go with the new window. // @@ -137,6 +138,7 @@ class WebContentsView : public RenderViewHostDelegate::View { // around the tab like this, the download bar etc. should be managed by the // BrowserView2 object. virtual void ReparentFindWindow(Browser* new_browser) const = 0; +#endif // Computes the location of the find bar and whether it is fully visible in // its parent window. The return value indicates if the window is visible at diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc index c5ff575..cd0d09a 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc @@ -49,7 +49,7 @@ gfx::NativeView WebContentsViewGtk::GetContentNativeView() const { return NULL; } -gfx::NativeView WebContentsViewGtk::GetTopLevelNativeView() const { +gfx::NativeWindow WebContentsViewGtk::GetTopLevelNativeView() const { NOTIMPLEMENTED(); return NULL; } diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.h b/chrome/browser/tab_contents/web_contents_view_gtk.h index b00a520..f10df5c 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.h +++ b/chrome/browser/tab_contents/web_contents_view_gtk.h @@ -24,7 +24,7 @@ class WebContentsViewGtk : public WebContentsView { virtual gfx::NativeView GetNativeView() const; virtual gfx::NativeView GetContentNativeView() const; - virtual gfx::NativeView GetTopLevelNativeView() const; + virtual gfx::NativeWindow GetTopLevelNativeView() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void OnContentsDestroy(); virtual void SetPageTitle(const std::wstring& title); diff --git a/chrome/browser/tab_contents/web_contents_view_mac.h b/chrome/browser/tab_contents/web_contents_view_mac.h new file mode 100644 index 0000000..ec3b613 --- /dev/null +++ b/chrome/browser/tab_contents/web_contents_view_mac.h @@ -0,0 +1,88 @@ +// Copyright (c) 2009 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 CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ +#define CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ + +#import <Cocoa/Cocoa.h> + +#include "base/gfx/size.h" +#include "base/scoped_cftyperef.h" +#include "chrome/browser/tab_contents/web_contents_view.h" + +class FindBarMac; + +@interface WebContentsViewCocoa : NSView { +} + +@end + +// 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 WebContentsView { + public: + // The corresponding WebContents is passed in the constructor, and manages our + // lifetime. This doesn't need to be the case, but is this way currently + // because that's what was easiest when they were split. + explicit WebContentsViewMac(WebContents* web_contents); + virtual ~WebContentsViewMac(); + + // WebContentsView implementation -------------------------------------------- + + virtual WebContents* GetWebContents(); + virtual void CreateView(); + virtual RenderWidgetHostView* CreateViewForWidget( + RenderWidgetHost* render_widget_host); + virtual gfx::NativeView GetNativeView() const; + virtual gfx::NativeView GetContentNativeView() const; + virtual gfx::NativeWindow GetTopLevelNativeView() const; + virtual void GetContainerBounds(gfx::Rect* out) const; + virtual void OnContentsDestroy(); + virtual void SetPageTitle(const std::wstring& title); + virtual void Invalidate(); + virtual void SizeContents(const gfx::Size& size); + virtual void FindInPage(const Browser& browser, + bool find_next, bool forward_direction); + virtual void HideFindBar(bool end_session); + virtual bool GetFindBarWindowInfo(gfx::Point* position, + bool* fully_visible) const; + + // Backend implementation of RenderViewHostDelegate::View. + virtual WebContents* CreateNewWindowInternal( + int route_id, base::WaitableEvent* modal_dialog_event); + virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, + bool activatable); + virtual void ShowCreatedWindowInternal(WebContents* new_web_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); + virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, + const gfx::Rect& initial_pos); + virtual void ShowContextMenu(const ContextMenuParams& params); + virtual void StartDragging(const WebDropData& drop_data); + virtual void UpdateDragCursor(bool is_drop_target); + virtual void TakeFocus(bool reverse); + virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void OnFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); + + private: + // --------------------------------------------------------------------------- + + WebContents* web_contents_; + + // The Cocoa NSView that lives in the view hierarchy. + scoped_cftyperef<WebContentsViewCocoa*> cocoa_view_; + + // For find in page. This may be NULL if there is no find bar, and if it is + // non-NULL, it may or may not be visible. + scoped_ptr<FindBarMac> find_bar_; + + DISALLOW_COPY_AND_ASSIGN(WebContentsViewMac); +}; + +#endif // CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ diff --git a/chrome/browser/tab_contents/web_contents_view_mac.mm b/chrome/browser/tab_contents/web_contents_view_mac.mm new file mode 100644 index 0000000..4218eb2 --- /dev/null +++ b/chrome/browser/tab_contents/web_contents_view_mac.mm @@ -0,0 +1,236 @@ +// Copyright (c) 2006-2008 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 "chrome/browser/tab_contents/web_contents_view_mac.h" + +#include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. +#include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view_mac.h" +#include "chrome/browser/tab_contents/web_contents.h" + +#include "chrome/common/temp_scaffolding_stubs.h" + +// static +WebContentsView* WebContentsView::Create(WebContents* web_contents) { + return new WebContentsViewMac(web_contents); +} + +WebContentsViewMac::WebContentsViewMac(WebContents* web_contents) + : web_contents_(web_contents) { +} + +WebContentsViewMac::~WebContentsViewMac() { +} + +WebContents* WebContentsViewMac::GetWebContents() { + return web_contents_; +} + +void WebContentsViewMac::CreateView() { + WebContentsViewCocoa* view = + [[WebContentsViewCocoa alloc] initWithFrame:NSZeroRect]; + // Under GC, ObjC and CF retains/releases are no longer equivalent. So we + // change our ObjC retain to a CF retain se we can use a scoped_cftyperef. + CFRetain(view); + [view release]; + cocoa_view_.reset(view); +} + +RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget( + RenderWidgetHost* render_widget_host) { + DCHECK(!render_widget_host->view()); + RenderWidgetHostViewMac* view = + new RenderWidgetHostViewMac(render_widget_host); + + NSView* view_view = view->GetNativeView(); + [cocoa_view_.get() addSubview:view_view]; + + return view; +} + +gfx::NativeView WebContentsViewMac::GetNativeView() const { + return cocoa_view_.get(); +} + +gfx::NativeView WebContentsViewMac::GetContentNativeView() const { + if (!web_contents_->render_widget_host_view()) + return NULL; + return web_contents_->render_widget_host_view()->GetPluginNativeView(); +} + +gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeView() const { + return [cocoa_view_.get() window]; +} + +void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { + *out = gfx::Rect(NSRectToCGRect([cocoa_view_.get() frame])); +} + +void WebContentsViewMac::StartDragging(const WebDropData& drop_data) { + NOTIMPLEMENTED(); +} + +void WebContentsViewMac::OnContentsDestroy() { + // TODO(avi):Close the find bar if any. + if (find_bar_.get()) + find_bar_->Close(); +} + +void WebContentsViewMac::SetPageTitle(const std::wstring& title) { + // Meaningless on the Mac; widgets don't have a "title" attribute +} + +void WebContentsViewMac::Invalidate() { + [cocoa_view_.get() setNeedsDisplay:YES]; +} + +void WebContentsViewMac::SizeContents(const gfx::Size& size) { + // TODO(brettw) this is a hack and should be removed. See web_contents_view.h. + NSRect rect = [cocoa_view_.get() frame]; + rect.size = NSSizeFromCGSize(size.ToCGSize()); + [cocoa_view_.get() setBounds:rect]; +} + +void WebContentsViewMac::FindInPage(const Browser& browser, + bool find_next, bool forward_direction) { + if (!find_bar_.get()) { + // We want the Chrome top-level (Frame) window. + NSWindow* window = + static_cast<NSWindow*>(browser.window()->GetNativeHandle()); + find_bar_.reset(new FindBarMac(this, window)); + } else { + find_bar_->Show(); + } + + if (find_next && !find_bar_->find_string().empty()) + find_bar_->StartFinding(forward_direction); +} + +void WebContentsViewMac::HideFindBar(bool end_session) { + if (find_bar_.get()) { + if (end_session) + find_bar_->EndFindSession(); + else + find_bar_->DidBecomeUnselected(); + } +} + +bool WebContentsViewMac::GetFindBarWindowInfo(gfx::Point* position, + bool* fully_visible) const { + if (!find_bar_.get() || + [find_bar_->GetView() isHidden]) { + *position = gfx::Point(0, 0); + *fully_visible = false; + return false; + } + + NSRect frame = [find_bar_->GetView() frame]; + *position = gfx::Point(frame.origin.x, frame.origin.y); + *fully_visible = find_bar_->IsVisible() && !find_bar_->IsAnimating(); + return true; +} + +void WebContentsViewMac::UpdateDragCursor(bool is_drop_target) { + NOTIMPLEMENTED(); +} + +void WebContentsViewMac::TakeFocus(bool reverse) { + [cocoa_view_.get() becomeFirstResponder]; +} + +void WebContentsViewMac::HandleKeyboardEvent(const WebKeyboardEvent& event) { + // The renderer returned a keyboard event it did not process. TODO(avi): + // reconstruct an NSEvent and feed it to the view. + NOTIMPLEMENTED(); +} + +void WebContentsViewMac::OnFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { + if (find_bar_.get()) { + find_bar_->OnFindReply(request_id, number_of_matches, selection_rect, + active_match_ordinal, final_update); + } +} + +void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { + NOTIMPLEMENTED(); +} + +WebContents* WebContentsViewMac::CreateNewWindowInternal( + int route_id, + base::WaitableEvent* modal_dialog_event) { + // Create the new web contents. This will automatically create the new + // WebContentsView. In the future, we may want to create the view separately. + WebContents* new_contents = + new WebContents(web_contents_->profile(), + web_contents_->GetSiteInstance(), + web_contents_->render_view_factory_, + route_id, + modal_dialog_event); + new_contents->SetupController(web_contents_->profile()); + WebContentsView* new_view = new_contents->view(); + + new_view->CreateView(); + + // 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. + new_view->CreateViewForWidget(new_contents->render_view_host()); + return new_contents; +} + +RenderWidgetHostView* WebContentsViewMac::CreateNewWidgetInternal( + int route_id, + bool activatable) { + // Create the widget and its associated view. + // TODO(brettw) can widget creation be cross-platform? + RenderWidgetHost* widget_host = + new RenderWidgetHost(web_contents_->process(), route_id); + RenderWidgetHostViewMac* widget_view = + new RenderWidgetHostViewMac(widget_host); + + // Some weird reparenting stuff happens here. TODO(avi): figure that out + + return widget_view; +} + +void WebContentsViewMac::ShowCreatedWindowInternal( + WebContents* new_web_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { + if (!new_web_contents->render_widget_host_view() || + !new_web_contents->process()->channel()) { + // The view has gone away or the renderer crashed. Nothing to do. + return; + } + + // TODO(brettw) this seems bogus to reach into here and initialize the host. + new_web_contents->render_view_host()->Init(); + web_contents_->AddNewContents(new_web_contents, disposition, initial_pos, + user_gesture); +} + +void WebContentsViewMac::ShowCreatedWidgetInternal( + RenderWidgetHostView* widget_host_view, + const gfx::Rect& initial_pos) { + RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); + if (!widget_host->process()->channel()) { + // The view has gone away or the renderer crashed. Nothing to do. + return; + } + + // Reparenting magic goes here. TODO(avi): fix + + widget_host->Init(); +} + +@implementation WebContentsViewCocoa + +// Tons of stuff goes here, where we grab events going on in Cocoaland and send +// them into the C++ system. TODO(avi): all that jazz + +@end diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index 522f8a1..4e56727 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -91,7 +91,7 @@ gfx::NativeView WebContentsViewWin::GetContentNativeView() const { return web_contents_->render_widget_host_view()->GetPluginNativeView(); } -gfx::NativeView WebContentsViewWin::GetTopLevelNativeView() const { +gfx::NativeWindow WebContentsViewWin::GetTopLevelNativeView() const { return ::GetAncestor(GetNativeView(), GA_ROOT); } diff --git a/chrome/browser/tab_contents/web_contents_view_win.h b/chrome/browser/tab_contents/web_contents_view_win.h index 4edb6f5..a8649d7 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.h +++ b/chrome/browser/tab_contents/web_contents_view_win.h @@ -34,7 +34,7 @@ class WebContentsViewWin : public WebContentsView, RenderWidgetHost* render_widget_host); virtual gfx::NativeView GetNativeView() const; virtual gfx::NativeView GetContentNativeView() const; - virtual gfx::NativeView GetTopLevelNativeView() const; + virtual gfx::NativeWindow GetTopLevelNativeView() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void OnContentsDestroy(); virtual void SetPageTitle(const std::wstring& title); diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index a3aa8ea..f1103e4 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -234,6 +234,9 @@ 826858470F325A10009F6555 /* template_url_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5D16EE60F21455600861FAC /* template_url_unittest.cc */; }; 8268589C0F326CCC009F6555 /* template_url_parser_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5D16EE20F21455600861FAC /* template_url_parser_unittest.cc */; }; 826858FA0F326FA3009F6555 /* testing_profile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 826858F80F326FA3009F6555 /* testing_profile.cc */; }; + 82FA32330F3A4CC400271C5A /* web_contents_view.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6CCB9F20F1EC32700106F0D /* web_contents_view.cc */; }; + 82FA32760F3A537C00271C5A /* web_contents_view_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 82FA32750F3A537C00271C5A /* web_contents_view_mac.mm */; }; + 82FA33460F3A7F6900271C5A /* render_widget_host_view_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 82FA33450F3A7F6900271C5A /* render_widget_host_view_mac.mm */; }; 8570EB3F140C07ABF1957F12 /* url_pattern_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = A9C335E39D39A7DE087850FC /* url_pattern_unittest.cc */; }; 8F51B73AAAF1772ECF9BD180 /* url_fetcher.cc in Sources */ = {isa = PBXBuildFile; fileRef = 778D7927798B7E3FAA498D3D /* url_fetcher.cc */; }; 94542322A5E5A8F4FDDAB7F0 /* render_view_host_manager.cc in Sources */ = {isa = PBXBuildFile; fileRef = A76E42AD0F28EDB5009A7E88 /* render_view_host_manager.cc */; }; @@ -461,13 +464,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 33C594F30F3A68110026A42A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 826850040F2FC82D009F6555 /* webkit.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = E45626A20E268F03005E4685; - remoteInfo = glue; - }; 4D1F59EE0F2A6B740040C1E3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4D7BF2E90E9D46A4009A6919 /* Project object */; @@ -1895,6 +1891,10 @@ 826851480F2FCDEC009F6555 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; 826858F80F326FA3009F6555 /* testing_profile.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testing_profile.cc; sourceTree = "<group>"; }; 826858F90F326FA3009F6555 /* testing_profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testing_profile.h; sourceTree = "<group>"; }; + 82FA32740F3A537C00271C5A /* web_contents_view_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web_contents_view_mac.h; path = tab_contents/web_contents_view_mac.h; sourceTree = "<group>"; }; + 82FA32750F3A537C00271C5A /* web_contents_view_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = web_contents_view_mac.mm; path = tab_contents/web_contents_view_mac.mm; sourceTree = "<group>"; }; + 82FA33440F3A7F6900271C5A /* render_widget_host_view_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = render_widget_host_view_mac.h; path = renderer_host/render_widget_host_view_mac.h; sourceTree = "<group>"; }; + 82FA33450F3A7F6900271C5A /* render_widget_host_view_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = render_widget_host_view_mac.mm; path = renderer_host/render_widget_host_view_mac.mm; sourceTree = "<group>"; }; A54612D90EE9957000A8EE5D /* extensions_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extensions_service.cc; sourceTree = "<group>"; }; A54612DA0EE9957000A8EE5D /* extensions_service.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extensions_service.h; sourceTree = "<group>"; }; A54612DB0EE9958600A8EE5D /* extensions_service_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extensions_service_unittest.cc; sourceTree = "<group>"; }; @@ -1910,8 +1910,6 @@ A76E42A30F28ED73009A7E88 /* render_widget_host.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = render_widget_host.cc; path = renderer_host/render_widget_host.cc; sourceTree = "<group>"; }; A76E42A40F28ED73009A7E88 /* render_widget_host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = render_widget_host.h; path = renderer_host/render_widget_host.h; sourceTree = "<group>"; }; A76E42A50F28ED73009A7E88 /* render_widget_host_view.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = render_widget_host_view.h; path = renderer_host/render_widget_host_view.h; sourceTree = "<group>"; }; - A76E42A60F28ED73009A7E88 /* render_widget_host_view_win.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = render_widget_host_view_win.cc; path = renderer_host/render_widget_host_view_win.cc; sourceTree = "<group>"; }; - A76E42A70F28ED73009A7E88 /* render_widget_host_view_win.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = render_widget_host_view_win.h; path = renderer_host/render_widget_host_view_win.h; sourceTree = "<group>"; }; A76E42A90F28EDB5009A7E88 /* render_view_context_menu.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = render_view_context_menu.cc; path = tab_contents/render_view_context_menu.cc; sourceTree = "<group>"; }; A76E42AA0F28EDB5009A7E88 /* render_view_context_menu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = render_view_context_menu.h; path = tab_contents/render_view_context_menu.h; sourceTree = "<group>"; }; A76E42AB0F28EDB5009A7E88 /* render_view_context_menu_controller.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = render_view_context_menu_controller.cc; path = tab_contents/render_view_context_menu_controller.cc; sourceTree = "<group>"; }; @@ -2031,8 +2029,6 @@ B6CCB9F10F1EC32700106F0D /* web_contents_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_contents_unittest.cc; path = tab_contents/web_contents_unittest.cc; sourceTree = "<group>"; }; B6CCB9F20F1EC32700106F0D /* web_contents_view.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_contents_view.cc; path = tab_contents/web_contents_view.cc; sourceTree = "<group>"; }; B6CCB9F30F1EC32700106F0D /* web_contents_view.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web_contents_view.h; path = tab_contents/web_contents_view.h; sourceTree = "<group>"; }; - B6CCB9F40F1EC32700106F0D /* web_contents_view_win.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_contents_view_win.cc; path = tab_contents/web_contents_view_win.cc; sourceTree = "<group>"; }; - B6CCB9F50F1EC32700106F0D /* web_contents_view_win.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web_contents_view_win.h; path = tab_contents/web_contents_view_win.h; sourceTree = "<group>"; }; B6CCB9F60F1EC32700106F0D /* web_drag_source.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_drag_source.cc; path = tab_contents/web_drag_source.cc; sourceTree = "<group>"; }; B6CCB9F70F1EC32700106F0D /* web_drag_source.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web_drag_source.h; path = tab_contents/web_drag_source.h; sourceTree = "<group>"; }; B6CCB9F80F1EC32700106F0D /* web_drop_target.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_drop_target.cc; path = tab_contents/web_drop_target.cc; sourceTree = "<group>"; }; @@ -3458,8 +3454,8 @@ B6CCB9F10F1EC32700106F0D /* web_contents_unittest.cc */, B6CCB9F20F1EC32700106F0D /* web_contents_view.cc */, B6CCB9F30F1EC32700106F0D /* web_contents_view.h */, - B6CCB9F40F1EC32700106F0D /* web_contents_view_win.cc */, - B6CCB9F50F1EC32700106F0D /* web_contents_view_win.h */, + 82FA32740F3A537C00271C5A /* web_contents_view_mac.h */, + 82FA32750F3A537C00271C5A /* web_contents_view_mac.mm */, B6CCB9F60F1EC32700106F0D /* web_drag_source.cc */, B6CCB9F70F1EC32700106F0D /* web_drag_source.h */, B6CCB9F80F1EC32700106F0D /* web_drop_target.cc */, @@ -3622,8 +3618,8 @@ A76E42A30F28ED73009A7E88 /* render_widget_host.cc */, A76E42A40F28ED73009A7E88 /* render_widget_host.h */, A76E42A50F28ED73009A7E88 /* render_widget_host_view.h */, - A76E42A60F28ED73009A7E88 /* render_widget_host_view_win.cc */, - A76E42A70F28ED73009A7E88 /* render_widget_host_view_win.h */, + 82FA33440F3A7F6900271C5A /* render_widget_host_view_mac.h */, + 82FA33450F3A7F6900271C5A /* render_widget_host_view_mac.mm */, A76E42980F28ECAD009A7E88 /* renderer_security_policy.cc */, A76E42990F28ECAD009A7E88 /* renderer_security_policy.h */, A76E429A0F28ECAD009A7E88 /* renderer_security_policy_unittest.cc */, @@ -3858,7 +3854,6 @@ 4DDC64570EAE393800FB5EBE /* PBXTargetDependency */, 826852150F2FD152009F6555 /* PBXTargetDependency */, 8268521B0F2FD197009F6555 /* PBXTargetDependency */, - 33C594F40F3A68110026A42A /* PBXTargetDependency */, ); name = unit_tests; productName = unit_tests; @@ -4647,10 +4642,11 @@ 94542322A5E5A8F4FDDAB7F0 /* render_view_host_manager.cc in Sources */, E434BBBF0F37D6DB00B665C7 /* render_widget_helper.cc in Sources */, E434BFA40F3A03E200B665C7 /* render_widget_host.cc in Sources */, + 82FA33460F3A7F6900271C5A /* render_widget_host_view_mac.mm in Sources */, E434BBEB0F37DFA500B665C7 /* renderer_security_policy.cc in Sources */, + B0AC9501DED2809AC208AEEA /* resolve_proxy_msg_helper.cc in Sources */, BADB8B710F3A35AC00989B26 /* resource_dispatcher_host.cc in Sources */, A7A214A00F3B91B100F62B4D /* resource_message_filter.cc in Sources */, - B0AC9501DED2809AC208AEEA /* resolve_proxy_msg_helper.cc in Sources */, 4D7BFAF30E9D49EF009A6919 /* safe_browsing_database.cc in Sources */, E48FB9590EC4E9C10052B72B /* safe_browsing_database_bloom.cc in Sources */, E48FB95C0EC4E9DD0052B72B /* safe_browsing_database_impl.cc in Sources */, @@ -4698,6 +4694,8 @@ B5FCDE5C0F269E9B0099BFAF /* visitedlink_master.cc in Sources */, 4D7BFA480E9D4922009A6919 /* visitsegment_database.cc in Sources */, E434B9060F37672900B665C7 /* web_contents.cc in Sources */, + 82FA32330F3A4CC400271C5A /* web_contents_view.cc in Sources */, + 82FA32760F3A537C00271C5A /* web_contents_view_mac.mm in Sources */, E48B6C3C0F27844F002E47EC /* web_data_service.cc in Sources */, E45076200F150E0C003BE099 /* web_database.cc in Sources */, ); @@ -4850,11 +4848,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 33C594F40F3A68110026A42A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = glue; - targetProxy = 33C594F30F3A68110026A42A /* PBXContainerItemProxy */; - }; 4D1F59EF0F2A6B740040C1E3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4D1F59E90F2A6B590040C1E3 /* image_diff */; diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index 661f632..b79214f 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -166,13 +166,22 @@ void Browser::LoadingStateChanged(TabContents* source) { TabContents* TabContents::CreateWithType(TabContentsType type, Profile* profile, SiteInstance* instance) { + TabContents* contents; + switch (type) { case TAB_CONTENTS_WEB: - return new WebContents(profile, instance, NULL, MSG_ROUTING_NONE, NULL); + contents = new WebContents(profile, instance, NULL, MSG_ROUTING_NONE, + NULL); + break; default: - NOTIMPLEMENTED(); - return NULL; + NOTREACHED() << "Don't know how to create tab contents of type " << type; + contents = NULL; } + + if (contents) + contents->CreateView(); + + return contents; } void TabContents::SetupController(Profile* profile) { @@ -213,23 +222,6 @@ void TabContents::Destroy() { //-------------------------------------------------------------------------- -#if defined(OS_MACOSX) -class RenderWidgetHostViewStub : public RenderWidgetHostView { - public: - RenderWidgetHostViewStub(RenderWidgetHost* host) { - host->set_view(this); - } -}; - -RenderWidgetHostView* - WebContentsView::CreateViewForWidget(RenderWidgetHost* host) { - NOTIMPLEMENTED(); - return new RenderWidgetHostViewStub(host); -} -#endif // defined(OS_MACOSX) - -//-------------------------------------------------------------------------- - bool RLZTracker::GetAccessPointRlz(AccessPoint point, std::wstring* rlz) { NOTIMPLEMENTED(); return false; diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index 605421e..82cfb6d 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -77,6 +77,7 @@ class URLRequestContext; class UserScriptMaster; class VisitedLinkMaster; class WebContents; +class WebContentsView; struct WebPluginInfo; struct WebPluginGeometry; class WebPreferences; @@ -620,39 +621,6 @@ class ConfirmInfoBarDelegate : public InfoBarDelegate { }; }; -#if defined(OS_MACOSX) -class RenderWidgetHostView { - public: - virtual RenderWidgetHost* GetRenderWidgetHost() const { - NOTIMPLEMENTED(); - return NULL; - } - virtual void DidBecomeSelected() { NOTIMPLEMENTED(); } - virtual void WasHidden() { NOTIMPLEMENTED(); } - virtual void SetSize(const gfx::Size&) { NOTIMPLEMENTED(); } - virtual gfx::NativeView GetPluginNativeView() - { NOTIMPLEMENTED(); return NULL; }; - virtual void MovePluginWindows(const std::vector<WebPluginGeometry>&) - { NOTIMPLEMENTED(); } - virtual void Focus() { NOTIMPLEMENTED(); } - virtual void Blur() { NOTIMPLEMENTED(); } - virtual bool HasFocus() { NOTIMPLEMENTED(); return false; } - virtual void Show() { NOTIMPLEMENTED(); } - virtual void Hide() { NOTIMPLEMENTED(); } - virtual gfx::Rect GetViewBounds() const - { NOTIMPLEMENTED(); return gfx::Rect(); } - virtual void UpdateCursor(const WebCursor&) { NOTIMPLEMENTED(); } - virtual void UpdateCursorIfOverSelf() { NOTIMPLEMENTED(); } - virtual void SetIsLoading(bool) { NOTIMPLEMENTED(); } - virtual void IMEUpdateStatus(int, const gfx::Rect&) { NOTIMPLEMENTED(); } - virtual void DidPaintRect(const gfx::Rect&) { NOTIMPLEMENTED(); } - virtual void DidScrollRect(const gfx::Rect&, int, int) { NOTIMPLEMENTED(); } - virtual void RendererGone() { NOTIMPLEMENTED(); } - virtual void Destroy() { NOTIMPLEMENTED(); } - virtual void SetTooltipText(const std::wstring&) { NOTIMPLEMENTED(); } -}; -#endif // defined(MAC_OSX) - class LoadNotificationDetails { public: LoadNotificationDetails(const GURL&, PageTransition::Type, @@ -742,6 +710,10 @@ class TabContents : public NotificationObserver { void AddInfoBar(InfoBarDelegate*) { NOTIMPLEMENTED(); } virtual void OpenURL(const GURL&, const GURL&, WindowOpenDisposition, PageTransition::Type) { NOTIMPLEMENTED(); } + void AddNewContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { NOTIMPLEMENTED(); } virtual void Activate() { NOTIMPLEMENTED(); } virtual bool SupportsURL(GURL*) { NOTIMPLEMENTED(); return false; } virtual SiteInstance* GetSiteInstance() const { return NULL; } @@ -756,6 +728,7 @@ class TabContents : public NotificationObserver { static void MigrateShelfView(TabContents* from, TabContents* to) { NOTIMPLEMENTED(); } + virtual void CreateView() {} protected: typedef std::vector<ConstrainedWindow*> ConstrainedWindowList; ConstrainedWindowList child_windows_; @@ -778,7 +751,7 @@ class SelectFileDialog : public base::RefCountedThreadSafe<SelectFileDialog> { }; void ListenerDestroyed() { NOTIMPLEMENTED(); } void SelectFile(Type, const std::wstring&, const std::wstring&, - const std::wstring&, const std::wstring&, gfx::NativeView, + const std::wstring&, const std::wstring&, gfx::NativeWindow, void*) { NOTIMPLEMENTED(); } static SelectFileDialog* Create(WebContents*) { NOTIMPLEMENTED(); @@ -928,54 +901,6 @@ class URLFixerUpper { //--------------------------------------------------------------------------- // These stubs are for WebContents -#if defined(OS_MACOSX) -class WebContentsView : public RenderViewHostDelegate::View { - public: - void OnContentsDestroy() { NOTIMPLEMENTED(); } - void* GetNativeView() { - NOTIMPLEMENTED(); - return NULL; - } - void HideFindBar(bool) { NOTIMPLEMENTED(); } - void Invalidate() { NOTIMPLEMENTED(); } - static WebContentsView* Create(WebContents*) { - NOTIMPLEMENTED(); - return new WebContentsView; - } - gfx::NativeView GetTopLevelNativeView() const { - NOTIMPLEMENTED(); - return NULL; - } - gfx::Size GetContainerSize() const { - NOTIMPLEMENTED(); - return gfx::Size(); - } - void SizeContents(const gfx::Size& size) { NOTIMPLEMENTED(); } - RenderWidgetHostView* CreateViewForWidget(RenderWidgetHost*); - void RenderWidgetHostDestroyed(RenderWidgetHost*) { NOTIMPLEMENTED(); } - void SetPageTitle(const std::wstring&) { NOTIMPLEMENTED(); } - virtual void CreateNewWindow(int, - base::WaitableEvent*) { NOTIMPLEMENTED(); } - virtual void CreateNewWidget(int, bool) { NOTIMPLEMENTED(); } - virtual void ShowCreatedWindow(int, WindowOpenDisposition, - const gfx::Rect&, bool) { NOTIMPLEMENTED(); } - virtual void ShowCreatedWidget(int, const gfx::Rect&) { NOTIMPLEMENTED(); } - virtual void ShowContextMenu(const ContextMenuParams&) { NOTIMPLEMENTED(); } - virtual void StartDragging(const WebDropData&) { NOTIMPLEMENTED(); } - virtual void UpdateDragCursor(bool) { NOTIMPLEMENTED(); } - virtual void TakeFocus(bool) { NOTIMPLEMENTED(); } - virtual void HandleKeyboardEvent(const WebKeyboardEvent&) - { NOTIMPLEMENTED(); } - virtual void OnFindReply(int, int, const gfx::Rect&, int, - bool) { NOTIMPLEMENTED(); } -}; - -class WebContentsViewWin : public WebContentsView { - public: - WebContentsViewWin(WebContents*) { } -}; -#endif // defined(OS_MACOSX) - class WebApp : public base::RefCountedThreadSafe<WebApp> { public: class Observer { @@ -1142,6 +1067,23 @@ class SimpleAlertInfoBarDelegate : public InfoBarDelegate { SimpleAlertInfoBarDelegate(WebContents*, const std::wstring&, void*) {} }; +#if defined(OS_MACOSX) +class FindBarMac { + public: + FindBarMac(WebContentsView*, gfx::NativeWindow) { } + void Show() { } + void Close() { } + void StartFinding(bool&) { } + void EndFindSession() { } + void DidBecomeUnselected() { } + bool IsVisible() { return false; } + bool IsAnimating() { return false; } + gfx::NativeView GetView() { return nil; } + std::string find_string() { return ""; } + void OnFindReply(int, int, const gfx::Rect&, int, bool) { } +}; +#endif + class LoginHandler { public: void SetAuth(const std::wstring& username, |