Commit 1c05b7c7 authored by jam@chromium.org's avatar jam@chromium.org

Move TabContentsViewGtk's delegate to content\public\browser. Also name it a...

Move TabContentsViewGtk's delegate to content\public\browser. Also name it a delegate instead of a wrapper to match what Mac (and Win soon) call theirs.

BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9586009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124695 0039d316-1c4b-4281-b951-d872f2087c98
parent df3bc522
......@@ -123,7 +123,7 @@
#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#elif defined(TOOLKIT_USES_GTK)
#include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h"
#include "chrome/browser/tab_contents/chrome_web_contents_view_gtk_delegate.h"
#include "content/browser/tab_contents/tab_contents_view_gtk.h"
#elif defined(OS_MACOSX)
#include "chrome/browser/tab_contents/chrome_web_contents_view_mac_delegate.h"
......@@ -346,7 +346,7 @@ content::WebContentsView* ChromeContentBrowserClient::CreateWebContentsView(
return new TabContentsViewViews(web_contents);
#elif defined(TOOLKIT_USES_GTK)
return new content::TabContentsViewGtk(web_contents,
new ChromeTabContentsViewWrapperGtk);
new ChromeWebContentsViewGtkDelegate);
#elif defined(OS_MACOSX)
return web_contents_view_mac::CreateWebContentsView(
web_contents,
......
......@@ -2,7 +2,7 @@
// 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/chrome_tab_contents_view_wrapper_gtk.h"
#include "chrome/browser/tab_contents/chrome_web_contents_view_gtk_delegate.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
......@@ -15,7 +15,7 @@
#include "content/public/browser/web_contents.h"
#include "ui/base/gtk/gtk_floating_container.h"
ChromeTabContentsViewWrapperGtk::ChromeTabContentsViewWrapperGtk()
ChromeWebContentsViewGtkDelegate::ChromeWebContentsViewGtkDelegate()
: floating_(gtk_floating_container_new()),
view_(NULL),
constrained_window_(NULL) {
......@@ -24,11 +24,11 @@ ChromeTabContentsViewWrapperGtk::ChromeTabContentsViewWrapperGtk()
G_CALLBACK(OnSetFloatingPositionThunk), this);
}
ChromeTabContentsViewWrapperGtk::~ChromeTabContentsViewWrapperGtk() {
ChromeWebContentsViewGtkDelegate::~ChromeWebContentsViewGtkDelegate() {
floating_.Destroy();
}
void ChromeTabContentsViewWrapperGtk::AttachConstrainedWindow(
void ChromeWebContentsViewGtkDelegate::AttachConstrainedWindow(
ConstrainedWindowGtk* constrained_window) {
DCHECK(constrained_window_ == NULL);
......@@ -37,7 +37,7 @@ void ChromeTabContentsViewWrapperGtk::AttachConstrainedWindow(
constrained_window->widget());
}
void ChromeTabContentsViewWrapperGtk::RemoveConstrainedWindow(
void ChromeWebContentsViewGtkDelegate::RemoveConstrainedWindow(
ConstrainedWindowGtk* constrained_window) {
DCHECK(constrained_window == constrained_window_);
......@@ -46,7 +46,7 @@ void ChromeTabContentsViewWrapperGtk::RemoveConstrainedWindow(
constrained_window->widget());
}
void ChromeTabContentsViewWrapperGtk::WrapView(
void ChromeWebContentsViewGtkDelegate::WrapView(
content::TabContentsViewGtk* view) {
view_ = view;
......@@ -55,18 +55,18 @@ void ChromeTabContentsViewWrapperGtk::WrapView(
gtk_widget_show(floating_.get());
}
gfx::NativeView ChromeTabContentsViewWrapperGtk::GetNativeView() const {
gfx::NativeView ChromeWebContentsViewGtkDelegate::GetNativeView() const {
return floating_.get();
}
void ChromeTabContentsViewWrapperGtk::OnCreateViewForWidget() {
void ChromeWebContentsViewGtkDelegate::OnCreateViewForWidget() {
// We install a chrome specific handler to intercept bookmark drags for the
// bookmark manager/extension API.
bookmark_handler_gtk_.reset(new WebDragBookmarkHandlerGtk);
view_->SetDragDestDelegate(bookmark_handler_gtk_.get());
}
void ChromeTabContentsViewWrapperGtk::Focus() {
void ChromeWebContentsViewGtkDelegate::Focus() {
if (!constrained_window_) {
GtkWidget* widget = view_->GetContentNativeView();
if (widget)
......@@ -74,7 +74,7 @@ void ChromeTabContentsViewWrapperGtk::Focus() {
}
}
gboolean ChromeTabContentsViewWrapperGtk::OnNativeViewFocusEvent(
gboolean ChromeWebContentsViewGtkDelegate::OnNativeViewFocusEvent(
GtkWidget* widget,
GtkDirectionType type,
gboolean* return_value) {
......@@ -96,7 +96,7 @@ gboolean ChromeTabContentsViewWrapperGtk::OnNativeViewFocusEvent(
return FALSE;
}
void ChromeTabContentsViewWrapperGtk::ShowContextMenu(
void ChromeWebContentsViewGtkDelegate::ShowContextMenu(
const content::ContextMenuParams& params) {
// Find out the RenderWidgetHostView that corresponds to the render widget on
// which this context menu is showed, so that we can retrieve the last mouse
......@@ -128,7 +128,7 @@ void ChromeTabContentsViewWrapperGtk::ShowContextMenu(
context_menu_->Popup(point);
}
void ChromeTabContentsViewWrapperGtk::OnSetFloatingPosition(
void ChromeWebContentsViewGtkDelegate::OnSetFloatingPosition(
GtkWidget* floating_container, GtkAllocation* allocation) {
if (!constrained_window_)
return;
......
......@@ -2,13 +2,13 @@
// 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_CHROME_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#define CHROME_BROWSER_TAB_CONTENTS_CHROME_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#ifndef CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
#define CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
#pragma once
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/tab_contents/tab_contents_view_wrapper_gtk.h"
#include "content/public/browser/web_contents_view_gtk_delegate.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/gtk/owned_widget_gtk.h"
......@@ -19,18 +19,18 @@ class WebDragBookmarkHandlerGtk;
// A chrome/ specific class that extends TabContentsViewGtk with features like
// constrained windows, which live in chrome/.
class ChromeTabContentsViewWrapperGtk
: public content::TabContentsViewWrapperGtk {
class ChromeWebContentsViewGtkDelegate
: public content::WebContentsViewGtkDelegate {
public:
ChromeTabContentsViewWrapperGtk();
virtual ~ChromeTabContentsViewWrapperGtk();
ChromeWebContentsViewGtkDelegate();
virtual ~ChromeWebContentsViewGtkDelegate();
// Unlike Windows, ConstrainedWindows need to collaborate with the
// TabContentsViewGtk to position the dialogs.
void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
// Overridden from TabContentsViewGtkWrapper:
// Overridden from WebContentsViewGtkDelegate:
virtual void WrapView(content::TabContentsViewGtk* view) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void OnCreateViewForWidget() OVERRIDE;
......@@ -43,7 +43,7 @@ class ChromeTabContentsViewWrapperGtk
private:
// Sets the location of the constrained windows.
CHROMEGTK_CALLBACK_1(ChromeTabContentsViewWrapperGtk, void,
CHROMEGTK_CALLBACK_1(ChromeWebContentsViewGtkDelegate, void,
OnSetFloatingPosition,
GtkAllocation*);
......@@ -65,4 +65,4 @@ class ChromeTabContentsViewWrapperGtk
scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_;
};
#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
......@@ -21,7 +21,7 @@
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#else
#include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h"
#include "chrome/browser/tab_contents/chrome_web_contents_view_gtk_delegate.h"
#include "content/browser/tab_contents/tab_contents_view_gtk.h"
#endif
......@@ -141,7 +141,7 @@ ConstrainedWindowGtk::TabContentsViewType*
#else
return static_cast<TabContentsViewType*>(
static_cast<content::TabContentsViewGtk*>(
wrapper_->web_contents()->GetView())->wrapper());
wrapper_->web_contents()->GetView())->delegate());
#endif
}
......
......@@ -20,7 +20,7 @@ typedef struct _GdkColor GdkColor;
#if defined(TOOLKIT_VIEWS)
class NativeTabContentsViewGtk;
#else
class ChromeTabContentsViewWrapperGtk;
class ChromeWebContentsViewGtkDelegate;
#endif
class ConstrainedWindowGtkDelegate {
......@@ -52,7 +52,7 @@ class ConstrainedWindowGtk : public ConstrainedWindow {
#if defined(TOOLKIT_VIEWS)
typedef NativeTabContentsViewGtk TabContentsViewType;
#else
typedef ChromeTabContentsViewWrapperGtk TabContentsViewType;
typedef ChromeWebContentsViewGtkDelegate TabContentsViewType;
#endif
ConstrainedWindowGtk(TabContentsWrapper* wrapper,
......
......@@ -2507,8 +2507,8 @@
'browser/tab_first_render_watcher.h',
'browser/tab_contents/background_contents.cc',
'browser/tab_contents/background_contents.h',
'browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.cc',
'browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h',
'browser/tab_contents/chrome_web_contents_view_gtk_delegate.cc',
'browser/tab_contents/chrome_web_contents_view_gtk_delegate.h',
'browser/tab_contents/chrome_web_contents_view_mac_delegate.h',
'browser/tab_contents/chrome_web_contents_view_mac_delegate.mm',
'browser/tab_contents/confirm_infobar_delegate.cc',
......@@ -4723,7 +4723,14 @@
],
}],
],
}],
}, {
'sources!': [
# The rules only catch files that start or end with gtk, but these
# files would be incorrectly named if we forced the gtk at the end.
'browser/tab_contents/chrome_web_contents_view_gtk_delegate.cc',
'browser/tab_contents/chrome_web_contents_view_gtk_delegate.h',
],
}],
['input_speech==0', {
'sources/': [
['exclude', '^browser/speech/'],
......
......@@ -18,10 +18,10 @@
#include "content/browser/renderer_host/render_widget_host_view_gtk.h"
#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view_wrapper_gtk.h"
#include "content/browser/tab_contents/web_drag_dest_gtk.h"
#include "content/browser/tab_contents/web_drag_source_gtk.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_view_gtk_delegate.h"
#include "ui/base/gtk/gtk_expanded_container.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
......@@ -79,10 +79,10 @@ namespace content {
TabContentsViewGtk::TabContentsViewGtk(
content::WebContents* web_contents,
content::TabContentsViewWrapperGtk* view_wrapper)
content::WebContentsViewGtkDelegate* delegate)
: tab_contents_(static_cast<TabContents*>(web_contents)),
expanded_(gtk_expanded_container_new()),
view_wrapper_(view_wrapper),
delegate_(delegate),
overlaid_view_(NULL) {
gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view");
g_signal_connect(expanded_.get(), "size-allocate",
......@@ -93,8 +93,8 @@ TabContentsViewGtk::TabContentsViewGtk(
gtk_widget_show(expanded_.get());
drag_source_.reset(new content::WebDragSourceGtk(web_contents));
if (view_wrapper_.get())
view_wrapper_->WrapView(this);
if (delegate_.get())
delegate_->WrapView(this);
}
TabContentsViewGtk::~TabContentsViewGtk() {
......@@ -135,15 +135,15 @@ RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget(
// Renderer target DnD.
drag_dest_.reset(new content::WebDragDestGtk(tab_contents_, content_view));
if (view_wrapper_.get())
view_wrapper_->OnCreateViewForWidget();
if (delegate_.get())
delegate_->OnCreateViewForWidget();
return view;
}
gfx::NativeView TabContentsViewGtk::GetNativeView() const {
if (view_wrapper_.get())
return view_wrapper_->GetNativeView();
if (delegate_.get())
return delegate_->GetNativeView();
return expanded_.get();
}
......@@ -209,8 +209,8 @@ void TabContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
void TabContentsViewGtk::Focus() {
if (tab_contents_->ShowingInterstitialPage()) {
tab_contents_->GetInterstitialPage()->Focus();
} else if (wrapper()) {
wrapper()->Focus();
} else if (delegate_.get()) {
delegate_->Focus();
}
}
......@@ -315,9 +315,9 @@ void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) {
gboolean TabContentsViewGtk::OnFocus(GtkWidget* widget,
GtkDirectionType focus) {
// Give our view wrapper first chance at this event.
if (view_wrapper_.get()) {
if (delegate_.get()) {
gboolean return_value = FALSE;
if (view_wrapper_->OnNativeViewFocusEvent(widget, focus, &return_value))
if (delegate_->OnNativeViewFocusEvent(widget, focus, &return_value))
return return_value;
}
......@@ -385,8 +385,8 @@ void TabContentsViewGtk::ShowContextMenu(
return;
}
if (wrapper())
wrapper()->ShowContextMenu(params);
if (delegate_.get())
delegate_->ShowContextMenu(params);
else
DLOG(ERROR) << "Cannot show context menus without a delegate.";
}
......
......@@ -20,7 +20,7 @@
namespace content {
class TabContentsViewWrapperGtk;
class WebContentsViewGtkDelegate;
class WebDragDestDelegate;
class WebDragDestGtk;
class WebDragSourceGtk;
......@@ -33,15 +33,15 @@ class CONTENT_EXPORT TabContentsViewGtk : public WebContentsView {
// |wrapper| which creates an intermediary widget layer for features from the
// Embedding layer that lives with the WebContentsView.
// TODO(jam): make this take a WebContents once it's created from content.
explicit TabContentsViewGtk(content::WebContents* web_contents,
TabContentsViewWrapperGtk* wrapper);
TabContentsViewGtk(content::WebContents* web_contents,
WebContentsViewGtkDelegate* delegate);
virtual ~TabContentsViewGtk();
// Override the stored focus widget. This call only makes sense when the
// tab contents is not focused.
void SetFocusedWidget(GtkWidget* widget);
TabContentsViewWrapperGtk* wrapper() const { return view_wrapper_.get(); }
WebContentsViewGtkDelegate* delegate() const { return delegate_.get(); }
TabContents* tab_contents() { return tab_contents_; }
GtkWidget* expanded_container() { return expanded_.get(); }
WebContents* web_contents();
......@@ -149,7 +149,7 @@ class CONTENT_EXPORT TabContentsViewGtk : public WebContentsView {
// Our optional views wrapper. If non-NULL, we return this widget as our
// GetNativeView() and insert |expanded_| as its child in the GtkWidget
// hierarchy.
scoped_ptr<TabContentsViewWrapperGtk> view_wrapper_;
scoped_ptr<WebContentsViewGtkDelegate> delegate_;
// The size we want the tab contents view to be. We keep this in a separate
// variable because resizing in GTK+ is async.
......
......@@ -124,6 +124,7 @@
'public/browser/web_contents_observer.cc',
'public/browser/web_contents_observer.h',
'public/browser/web_contents_view.h',
'public/browser/web_contents_view_gtk_delegate.h',
'public/browser/web_contents_view_mac_delegate.h',
'public/browser/web_intents_dispatcher.h',
'public/browser/web_ui.h',
......@@ -647,7 +648,6 @@
'browser/tab_contents/tab_contents_view_gtk.h',
'browser/tab_contents/tab_contents_view_helper.cc',
'browser/tab_contents/tab_contents_view_helper.h',
'browser/tab_contents/tab_contents_view_wrapper_gtk.h',
'browser/tab_contents/title_updated_details.h',
'browser/tab_contents/web_contents_view_android.cc',
'browser/tab_contents/web_contents_view_android.h',
......@@ -749,6 +749,12 @@
'../build/linux/system.gyp:x11',
'../dbus/dbus.gyp:dbus',
],
}, {
'sources!': [
# The rules only catch files that start or end with gtk, but this file
# would be incorrectly named if we forced the gtk at the end.
'public/browser/web_contents_view_gtk_delegate.h',
],
}],
['OS=="linux"', {
'dependencies': [
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
#define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
#pragma once
#include <gtk/gtk.h>
......@@ -20,9 +20,9 @@ struct ContextMenuParams;
// An object that supplies the Gtk parent of TabContentsViewGtk. Embedders may
// want to insert widgets that provide features that live with the
// TabContentsViewGtk.
class CONTENT_EXPORT TabContentsViewWrapperGtk {
class CONTENT_EXPORT WebContentsViewGtkDelegate {
public:
// Initializes the TabContentsViewGtkWrapper by taking |view| and adding it
// Initializes the WebContentsViewGtkDelegate by taking |view| and adding it
// this object's GtkContainer.
virtual void WrapView(TabContentsViewGtk* view) = 0;
......@@ -37,7 +37,7 @@ class CONTENT_EXPORT TabContentsViewWrapperGtk {
// Handles a focus event from the renderer process.
virtual void Focus() = 0;
// Gives TabContentsViewGtkWrapper a first chance at focus events from our
// Gives WebContentsViewGtkDelegate a first chance at focus events from our
// render widget host, before the main view invokes its default
// behaviour. Returns TRUE if |return_value| has been set and that value
// should be returned to GTK+.
......@@ -49,9 +49,9 @@ class CONTENT_EXPORT TabContentsViewWrapperGtk {
// specific crud.
virtual void ShowContextMenu(const content::ContextMenuParams& params) = 0;
virtual ~TabContentsViewWrapperGtk() {}
virtual ~WebContentsViewGtkDelegate() {}
};
} // namespace content
#endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WRAPPER_GTK_H_
#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment