Commit cb5956b3 authored by jam@chromium.org's avatar jam@chromium.org

Remove tab_contents_view_gtk.h include from chrome. I tried to find a way to...

Remove tab_contents_view_gtk.h include from chrome. I tried to find a way to not have to expose the FocusStore to the delegate, but I couldn't find any other way.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126926 0039d316-1c4b-4281-b951-d872f2087c98
parent 77a581d3
......@@ -39,7 +39,6 @@ include_rules = [
"+content/browser/renderer_host/render_widget_host_view_mac_delegate.h",
"+content/browser/renderer_host/resource_request_details.h",
"+content/browser/renderer_host/resource_request_info_impl.h",
"+content/browser/tab_contents/tab_contents_view_gtk.h",
"+content/browser/tab_contents/tab_contents_view_helper.h",
"+content/browser/tab_contents/test_tab_contents.h",
"+content/browser/tab_contents/web_contents_drag_win.h",
......
......@@ -4,6 +4,9 @@
#include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h"
#include <map>
#include "base/lazy_instance.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
#include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h"
......@@ -13,20 +16,38 @@
#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 "ui/base/gtk/focus_store_gtk.h"
#include "ui/base/gtk/gtk_floating_container.h"
static base::LazyInstance<std::map<
content::WebContents*, ChromeWebContentsViewDelegateGtk*> >
g_instances = LAZY_INSTANCE_INITIALIZER;
ChromeWebContentsViewDelegateGtk* ChromeWebContentsViewDelegateGtk::GetFor(
content::WebContents* web_contents) {
if (!g_instances.Get().count(web_contents))
return 0;
return g_instances.Get()[web_contents];
}
ChromeWebContentsViewDelegateGtk::ChromeWebContentsViewDelegateGtk(
content::WebContents* web_contents)
: floating_(gtk_floating_container_new()),
constrained_window_(NULL),
web_contents_(web_contents) {
web_contents_(web_contents),
expanded_container_(NULL),
focus_store_(NULL) {
gtk_widget_set_name(floating_.get(), "chrome-tab-contents-wrapper-view");
g_signal_connect(floating_.get(), "set-floating-position",
G_CALLBACK(OnSetFloatingPositionThunk), this);
DCHECK_EQ(g_instances.Get().count(web_contents), 0u);
g_instances.Get()[web_contents] = this;
}
ChromeWebContentsViewDelegateGtk::~ChromeWebContentsViewDelegateGtk() {
floating_.Destroy();
DCHECK_EQ(g_instances.Get().count(web_contents_), 1u);
g_instances.Get().erase(web_contents_);
}
void ChromeWebContentsViewDelegateGtk::AttachConstrainedWindow(
......@@ -48,7 +69,9 @@ void ChromeWebContentsViewDelegateGtk::RemoveConstrainedWindow(
}
void ChromeWebContentsViewDelegateGtk::Initialize(
GtkWidget* expanded_container) {
GtkWidget* expanded_container, ui::FocusStoreGtk* focus_store) {
expanded_container_ = expanded_container;
focus_store_ = focus_store;
// We install a chrome specific handler to intercept bookmark drags for the
// bookmark manager/extension API.
bookmark_handler_gtk_.reset(new WebDragBookmarkHandlerGtk);
......
......@@ -28,6 +28,12 @@ class ChromeWebContentsViewDelegateGtk
explicit ChromeWebContentsViewDelegateGtk(content::WebContents* web_contents);
virtual ~ChromeWebContentsViewDelegateGtk();
static ChromeWebContentsViewDelegateGtk* GetFor(
content::WebContents* web_contents);
GtkWidget* expanded_container() { return expanded_container_; }
ui::FocusStoreGtk* focus_store() { return focus_store_; }
// Unlike Windows, ConstrainedWindows need to collaborate with the
// TabContentsViewGtk to position the dialogs.
void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
......@@ -37,7 +43,8 @@ class ChromeWebContentsViewDelegateGtk
virtual void ShowContextMenu(
const content::ContextMenuParams& params) OVERRIDE;
virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
virtual void Initialize(GtkWidget* expanded_container) OVERRIDE;
virtual void Initialize(GtkWidget* expanded_container,
ui::FocusStoreGtk* focus_store) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void Focus() OVERRIDE;
virtual gboolean OnNativeViewFocusEvent(GtkWidget* widget,
......@@ -65,6 +72,9 @@ class ChromeWebContentsViewDelegateGtk
scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_;
content::WebContents* web_contents_;
GtkWidget* expanded_container_;
ui::FocusStoreGtk* focus_store_;
};
#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK_H_
......@@ -14,6 +14,7 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/gtk/focus_store_gtk.h"
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/gtk/gtk_hig_constants.h"
......@@ -22,7 +23,6 @@
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#else
#include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h"
#include "content/browser/tab_contents/tab_contents_view_gtk.h"
#endif
using content::BrowserThread;
......@@ -126,8 +126,7 @@ void ConstrainedWindowGtk::FocusConstrainedWindow() {
// TODO(estade): this define should not need to be here because this class
// should not be used on linux/views.
#if defined(TOOLKIT_GTK)
static_cast<content::TabContentsViewGtk*>(
wrapper_->web_contents()->GetView())->SetFocusedWidget(focus_widget);
ContainingView()->focus_store()->SetWidget(focus_widget);
#endif
}
}
......@@ -139,9 +138,7 @@ ConstrainedWindowGtk::TabContentsViewType*
static_cast<TabContentsViewViews*>(wrapper_->web_contents()->GetView())->
native_tab_contents_view());
#else
return static_cast<TabContentsViewType*>(
static_cast<content::TabContentsViewGtk*>(
wrapper_->web_contents()->GetView())->delegate());
return ChromeWebContentsViewDelegateGtk::GetFor(wrapper_->web_contents());
#endif
}
......
......@@ -19,7 +19,7 @@
#include <gtk/gtk.h>
#include "content/browser/tab_contents/tab_contents_view_gtk.h"
#include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h"
#include "chrome/browser/ui/gtk/sad_tab_gtk.h"
#endif
......@@ -58,11 +58,11 @@ void SadTabHelper::Observe(int type,
#elif defined(TOOLKIT_VIEWS)
sad_tab_->Close();
#elif defined(TOOLKIT_GTK)
content::TabContentsViewGtk* view =
static_cast<content::TabContentsViewGtk*>(
web_contents()->GetView());
GtkWidget* expanded_container =
ChromeWebContentsViewDelegateGtk::GetFor(web_contents())->
expanded_container();
gtk_container_remove(
GTK_CONTAINER(view->expanded_container()), sad_tab_->widget());
GTK_CONTAINER(expanded_container), sad_tab_->widget());
#else
#error Unknown platform
#endif
......@@ -106,10 +106,10 @@ void SadTabHelper::InstallSadTab(base::TerminationStatus status) {
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED
? SadTabGtk::KILLED
: SadTabGtk::CRASHED));
content::TabContentsViewGtk* view =
static_cast<content::TabContentsViewGtk*>(web_contents()->GetView());
gtk_container_add(
GTK_CONTAINER(view->expanded_container()), sad_tab_->widget());
GtkWidget* expanded_container =
ChromeWebContentsViewDelegateGtk::GetFor(web_contents())->
expanded_container();
gtk_container_add(GTK_CONTAINER(expanded_container), sad_tab_->widget());
gtk_widget_show(sad_tab_->widget());
#else
#error Unknown platform
......
......@@ -94,7 +94,7 @@ TabContentsViewGtk::TabContentsViewGtk(
drag_source_.reset(new content::WebDragSourceGtk(web_contents));
if (delegate_.get())
delegate_->Initialize(expanded_.get());
delegate_->Initialize(expanded_.get(), &focus_store_);
}
TabContentsViewGtk::~TabContentsViewGtk() {
......@@ -257,10 +257,6 @@ void TabContentsViewGtk::GetViewBounds(gfx::Rect* out) const {
out->SetRect(x, y, w, h);
}
void TabContentsViewGtk::SetFocusedWidget(GtkWidget* widget) {
focus_store_.SetWidget(widget);
}
WebContents* TabContentsViewGtk::web_contents() {
return tab_contents_;
}
......
......@@ -37,13 +37,8 @@ class CONTENT_EXPORT TabContentsViewGtk : public WebContentsView {
WebContentsViewDelegate* delegate);
virtual ~TabContentsViewGtk();
// Override the stored focus widget. This call only makes sense when the
// tab contents is not focused.
void SetFocusedWidget(GtkWidget* widget);
WebContentsViewDelegate* delegate() const { return delegate_.get(); }
TabContents* tab_contents() { return tab_contents_; }
GtkWidget* expanded_container() { return expanded_.get(); }
WebContents* web_contents();
// WebContentsView implementation --------------------------------------------
......
......@@ -23,6 +23,10 @@ namespace gfx {
class Size;
}
namespace ui {
class FocusStoreGtk;
}
namespace content {
class RenderWidgetHost;
......@@ -52,7 +56,8 @@ class CONTENT_EXPORT WebContentsViewDelegate {
virtual void SizeChanged(const gfx::Size& size) = 0;
#elif defined(TOOLKIT_USES_GTK)
// Initializes the WebContentsViewDelegate.
virtual void Initialize(GtkWidget* expanded_container) = 0;
virtual void Initialize(GtkWidget* expanded_container,
ui::FocusStoreGtk* focus_store) = 0;
// Returns the top widget that contains |view| passed in from WrapView. This
// is exposed through TabContentsViewGtk::GetNativeView() when a wrapper is
......
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