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