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

Side by Side Diff: chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc

Issue 9705053: Remove tab_contents_view_gtk.h include from chrome. I tried to find a way to not have to expose the… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h" 5 #include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h"
6 6
7 #include <map>
8
9 #include "base/lazy_instance.h"
7 #include "chrome/browser/browser_shutdown.h" 10 #include "chrome/browser/browser_shutdown.h"
8 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" 11 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h" 12 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h"
10 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" 13 #include "chrome/browser/ui/gtk/constrained_window_gtk.h"
11 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/render_widget_host_view.h" 16 #include "content/public/browser/render_widget_host_view.h"
14 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_view.h" 18 #include "content/public/browser/web_contents_view.h"
19 #include "ui/base/gtk/focus_store_gtk.h"
16 #include "ui/base/gtk/gtk_floating_container.h" 20 #include "ui/base/gtk/gtk_floating_container.h"
17 21
22 static base::LazyInstance<std::map<
23 content::WebContents*, ChromeWebContentsViewDelegateGtk*> >
24 g_instances = LAZY_INSTANCE_INITIALIZER;
25
26 ChromeWebContentsViewDelegateGtk* ChromeWebContentsViewDelegateGtk::GetFor(
27 content::WebContents* web_contents) {
28 if (!g_instances.Get().count(web_contents))
29 return 0;
30 return g_instances.Get()[web_contents];
31 }
32
18 ChromeWebContentsViewDelegateGtk::ChromeWebContentsViewDelegateGtk( 33 ChromeWebContentsViewDelegateGtk::ChromeWebContentsViewDelegateGtk(
19 content::WebContents* web_contents) 34 content::WebContents* web_contents)
20 : floating_(gtk_floating_container_new()), 35 : floating_(gtk_floating_container_new()),
21 constrained_window_(NULL), 36 constrained_window_(NULL),
22 web_contents_(web_contents) { 37 web_contents_(web_contents),
38 expanded_container_(NULL),
39 focus_store_(NULL) {
23 gtk_widget_set_name(floating_.get(), "chrome-tab-contents-wrapper-view"); 40 gtk_widget_set_name(floating_.get(), "chrome-tab-contents-wrapper-view");
24 g_signal_connect(floating_.get(), "set-floating-position", 41 g_signal_connect(floating_.get(), "set-floating-position",
25 G_CALLBACK(OnSetFloatingPositionThunk), this); 42 G_CALLBACK(OnSetFloatingPositionThunk), this);
43 DCHECK_EQ(g_instances.Get().count(web_contents), 0u);
44 g_instances.Get()[web_contents] = this;
26 } 45 }
27 46
28 ChromeWebContentsViewDelegateGtk::~ChromeWebContentsViewDelegateGtk() { 47 ChromeWebContentsViewDelegateGtk::~ChromeWebContentsViewDelegateGtk() {
29 floating_.Destroy(); 48 floating_.Destroy();
49 DCHECK_EQ(g_instances.Get().count(web_contents_), 1u);
50 g_instances.Get().erase(web_contents_);
30 } 51 }
31 52
32 void ChromeWebContentsViewDelegateGtk::AttachConstrainedWindow( 53 void ChromeWebContentsViewDelegateGtk::AttachConstrainedWindow(
33 ConstrainedWindowGtk* constrained_window) { 54 ConstrainedWindowGtk* constrained_window) {
34 DCHECK(constrained_window_ == NULL); 55 DCHECK(constrained_window_ == NULL);
35 56
36 constrained_window_ = constrained_window; 57 constrained_window_ = constrained_window;
37 gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()), 58 gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()),
38 constrained_window->widget()); 59 constrained_window->widget());
39 } 60 }
40 61
41 void ChromeWebContentsViewDelegateGtk::RemoveConstrainedWindow( 62 void ChromeWebContentsViewDelegateGtk::RemoveConstrainedWindow(
42 ConstrainedWindowGtk* constrained_window) { 63 ConstrainedWindowGtk* constrained_window) {
43 DCHECK(constrained_window == constrained_window_); 64 DCHECK(constrained_window == constrained_window_);
44 65
45 constrained_window_ = NULL; 66 constrained_window_ = NULL;
46 gtk_container_remove(GTK_CONTAINER(floating_.get()), 67 gtk_container_remove(GTK_CONTAINER(floating_.get()),
47 constrained_window->widget()); 68 constrained_window->widget());
48 } 69 }
49 70
50 void ChromeWebContentsViewDelegateGtk::Initialize( 71 void ChromeWebContentsViewDelegateGtk::Initialize(
51 GtkWidget* expanded_container) { 72 GtkWidget* expanded_container, ui::FocusStoreGtk* focus_store) {
73 expanded_container_ = expanded_container;
74 focus_store_ = focus_store;
52 // We install a chrome specific handler to intercept bookmark drags for the 75 // We install a chrome specific handler to intercept bookmark drags for the
53 // bookmark manager/extension API. 76 // bookmark manager/extension API.
54 bookmark_handler_gtk_.reset(new WebDragBookmarkHandlerGtk); 77 bookmark_handler_gtk_.reset(new WebDragBookmarkHandlerGtk);
55 78
56 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_container); 79 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_container);
57 gtk_widget_show(floating_.get()); 80 gtk_widget_show(floating_.get());
58 } 81 }
59 82
60 gfx::NativeView ChromeWebContentsViewDelegateGtk::GetNativeView() const { 83 gfx::NativeView ChromeWebContentsViewDelegateGtk::GetNativeView() const {
61 return floating_.get(); 84 return floating_.get();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 g_value_set_int(&value, child_x); 171 g_value_set_int(&value, child_x);
149 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 172 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
150 widget, "x", &value); 173 widget, "x", &value);
151 174
152 int child_y = std::max((allocation->height - requisition.height) / 2, 0); 175 int child_y = std::max((allocation->height - requisition.height) / 2, 0);
153 g_value_set_int(&value, child_y); 176 g_value_set_int(&value, child_y);
154 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 177 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
155 widget, "y", &value); 178 widget, "y", &value);
156 g_value_unset(&value); 179 g_value_unset(&value);
157 } 180 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h ('k') | chrome/browser/ui/gtk/constrained_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698