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

Side by Side Diff: chrome/browser/ui/gtk/gtk_window_util.cc

Issue 12334073: Remove WebContents methods that duplicate WebContentsView methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/ui/gtk/gtk_window_util.h" 5 #include "chrome/browser/ui/gtk/gtk_window_util.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include "chrome/browser/ui/base_window.h" 8 #include "chrome/browser/ui/base_window.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_contents_view.h"
11 12
12 using content::RenderWidgetHost; 13 using content::RenderWidgetHost;
13 using content::WebContents; 14 using content::WebContents;
14 15
15 namespace gtk_window_util { 16 namespace gtk_window_util {
16 17
17 // Keep track of the last click time and the last click position so we can 18 // Keep track of the last click time and the last click position so we can
18 // filter out extra GDK_BUTTON_PRESS events when a double click happens. 19 // filter out extra GDK_BUTTON_PRESS events when a double click happens.
19 static guint32 last_click_time; 20 static guint32 last_click_time;
20 static int last_click_x; 21 static int last_click_x;
21 static int last_click_y; 22 static int last_click_y;
22 23
23 // Performs Cut/Copy/Paste operation on the |window|. 24 // Performs Cut/Copy/Paste operation on the |window|.
24 // If the current render view is focused, then just call the specified |method| 25 // If the current render view is focused, then just call the specified |method|
25 // against the current render view host, otherwise emit the specified |signal| 26 // against the current render view host, otherwise emit the specified |signal|
26 // against the focused widget. 27 // against the focused widget.
27 // TODO(suzhe): This approach does not work for plugins. 28 // TODO(suzhe): This approach does not work for plugins.
28 void DoCutCopyPaste(GtkWindow* window, 29 void DoCutCopyPaste(GtkWindow* window,
29 WebContents* web_contents, 30 WebContents* web_contents,
30 void (RenderWidgetHost::*method)(), 31 void (RenderWidgetHost::*method)(),
31 const char* signal) { 32 const char* signal) {
32 GtkWidget* widget = gtk_window_get_focus(window); 33 GtkWidget* widget = gtk_window_get_focus(window);
33 if (widget == NULL) 34 if (widget == NULL)
34 return; // Do nothing if no focused widget. 35 return; // Do nothing if no focused widget.
35 36
36 if (web_contents && widget == web_contents->GetContentNativeView()) { 37 if (web_contents &&
38 widget == web_contents->GetView()->GetContentNativeView()) {
37 (web_contents->GetRenderViewHost()->*method)(); 39 (web_contents->GetRenderViewHost()->*method)();
38 } else { 40 } else {
39 guint id; 41 guint id;
40 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0) 42 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0)
41 g_signal_emit(widget, id, 0); 43 g_signal_emit(widget, id, 0);
42 } 44 }
43 } 45 }
44 46
45 void DoCut(GtkWindow* window, WebContents* web_contents) { 47 void DoCut(GtkWindow* window, WebContents* web_contents) {
46 DoCutCopyPaste(window, web_contents, 48 DoCutCopyPaste(window, web_contents,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 gfx::Rect* bounds, 248 gfx::Rect* bounds,
247 gfx::Rect* restored_bounds) { 249 gfx::Rect* restored_bounds) {
248 gint x, y; 250 gint x, y;
249 gtk_window_get_position(window->GetNativeWindow(), &x, &y); 251 gtk_window_get_position(window->GetNativeWindow(), &x, &y);
250 (*bounds).set_origin(gfx::Point(x, y)); 252 (*bounds).set_origin(gfx::Point(x, y));
251 if (!window->IsFullscreen() && !window->IsMaximized()) 253 if (!window->IsFullscreen() && !window->IsMaximized())
252 *restored_bounds = *bounds; 254 *restored_bounds = *bounds;
253 } 255 }
254 256
255 } // namespace gtk_window_util 257 } // namespace gtk_window_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698