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

Unified Diff: chrome/browser/ui/gtk/gtk_util.cc

Issue 10828289: Revert 151353 - Panels refactor: Support browserless panels on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/gtk_window_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/gtk_util.cc
===================================================================
--- chrome/browser/ui/gtk/gtk_util.cc (revision 151356)
+++ chrome/browser/ui/gtk/gtk_util.cc (working copy)
@@ -25,9 +25,12 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/browser_window_gtk.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
#include "grit/theme_resources.h"
#include "ui/base/gtk/gtk_compat.h"
@@ -45,6 +48,9 @@
// These conflict with base/tracked_objects.h, so need to come last.
#include <gdk/gdkx.h> // NOLINT
+using content::RenderWidgetHost;
+using content::WebContents;
+
namespace {
#if defined(GOOGLE_CHROME_BUILD)
@@ -272,6 +278,16 @@
return TRUE;
}
+WebContents* GetBrowserWindowSelectedWebContents(BrowserWindow* window) {
+ BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
+ window);
+ return chrome::GetActiveWebContents(browser_window->browser());
+}
+
+GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) {
+ return gtk_window_get_focus(window->GetNativeWindow());
+}
+
} // namespace
namespace gtk_util {
@@ -992,4 +1008,38 @@
}
}
+// Performs Cut/Copy/Paste operation on the |window|.
+// If the current render view is focused, then just call the specified |method|
+// against the current render view host, otherwise emit the specified |signal|
+// against the focused widget.
+// TODO(suzhe): This approach does not work for plugins.
+void DoCutCopyPaste(BrowserWindow* window,
+ void (RenderWidgetHost::*method)(),
+ const char* signal) {
+ GtkWidget* widget = GetBrowserWindowFocusedWidget(window);
+ if (widget == NULL)
+ return; // Do nothing if no focused widget.
+
+ WebContents* current_tab = GetBrowserWindowSelectedWebContents(window);
+ if (current_tab && widget == current_tab->GetContentNativeView()) {
+ (current_tab->GetRenderViewHost()->*method)();
+ } else {
+ guint id;
+ if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0)
+ g_signal_emit(widget, id, 0);
+ }
+}
+
+void DoCut(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderWidgetHost::Cut, "cut-clipboard");
+}
+
+void DoCopy(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard");
+}
+
+void DoPaste(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard");
+}
+
} // namespace gtk_util
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/gtk_window_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698