| OLD | NEW |
| 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_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 6 | 6 |
| 7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstdarg> | 10 #include <cstdarg> |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); | 1292 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); |
| 1293 } | 1293 } |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 // Performs Cut/Copy/Paste operation on the |window|. | 1296 // Performs Cut/Copy/Paste operation on the |window|. |
| 1297 // If the current render view is focused, then just call the specified |method| | 1297 // If the current render view is focused, then just call the specified |method| |
| 1298 // against the current render view host, otherwise emit the specified |signal| | 1298 // against the current render view host, otherwise emit the specified |signal| |
| 1299 // against the focused widget. | 1299 // against the focused widget. |
| 1300 // TODO(suzhe): This approach does not work for plugins. | 1300 // TODO(suzhe): This approach does not work for plugins. |
| 1301 void DoCutCopyPaste(BrowserWindow* window, | 1301 void DoCutCopyPaste(BrowserWindow* window, |
| 1302 void (RenderViewHost::*method)(), | 1302 void (RenderWidgetHost::*method)(), |
| 1303 const char* signal) { | 1303 const char* signal) { |
| 1304 GtkWidget* widget = GetBrowserWindowFocusedWidget(window); | 1304 GtkWidget* widget = GetBrowserWindowFocusedWidget(window); |
| 1305 if (widget == NULL) | 1305 if (widget == NULL) |
| 1306 return; // Do nothing if no focused widget. | 1306 return; // Do nothing if no focused widget. |
| 1307 | 1307 |
| 1308 WebContents* current_tab = GetBrowserWindowSelectedWebContents(window); | 1308 WebContents* current_tab = GetBrowserWindowSelectedWebContents(window); |
| 1309 if (current_tab && widget == current_tab->GetContentNativeView()) { | 1309 if (current_tab && widget == current_tab->GetContentNativeView()) { |
| 1310 (current_tab->GetRenderViewHost()->*method)(); | 1310 (current_tab->GetRenderViewHost()->*method)(); |
| 1311 } else { | 1311 } else { |
| 1312 guint id; | 1312 guint id; |
| 1313 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0) | 1313 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0) |
| 1314 g_signal_emit(widget, id, 0); | 1314 g_signal_emit(widget, id, 0); |
| 1315 } | 1315 } |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 void DoCut(BrowserWindow* window) { | 1318 void DoCut(BrowserWindow* window) { |
| 1319 DoCutCopyPaste(window, &RenderViewHost::Cut, "cut-clipboard"); | 1319 DoCutCopyPaste(window, &RenderWidgetHost::Cut, "cut-clipboard"); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 void DoCopy(BrowserWindow* window) { | 1322 void DoCopy(BrowserWindow* window) { |
| 1323 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1323 DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard"); |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 void DoPaste(BrowserWindow* window) { | 1326 void DoPaste(BrowserWindow* window) { |
| 1327 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1327 DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard"); |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 } // namespace gtk_util | 1330 } // namespace gtk_util |
| OLD | NEW |