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

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 8513002: Strip invalid characters (line breaks, tabs), javascript:schemes from the copied text before pasting (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/omnibox/omnibox_view_gtk.h" 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 gtk_widget_set_sensitive(search_engine_menuitem, 1437 gtk_widget_set_sensitive(search_engine_menuitem,
1438 command_updater_->IsCommandEnabled(IDC_EDIT_SEARCH_ENGINES)); 1438 command_updater_->IsCommandEnabled(IDC_EDIT_SEARCH_ENGINES));
1439 gtk_widget_show(search_engine_menuitem); 1439 gtk_widget_show(search_engine_menuitem);
1440 1440
1441 // We need to update the paste and go controller before we know what text 1441 // We need to update the paste and go controller before we know what text
1442 // to show. We could do this all asynchronously, but it would be elaborate 1442 // to show. We could do this all asynchronously, but it would be elaborate
1443 // because we'd have to account for multiple menus showing, getting called 1443 // because we'd have to account for multiple menus showing, getting called
1444 // back after shutdown, and similar issues. 1444 // back after shutdown, and similar issues.
1445 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); 1445 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
1446 gchar* text = gtk_clipboard_wait_for_text(x_clipboard); 1446 gchar* text = gtk_clipboard_wait_for_text(x_clipboard);
1447 string16 text_wstr = UTF8ToUTF16(text ? text : ""); 1447 string16 sanitized_text(text ?
1448 StripJavascriptSchemas(CollapseWhitespace(UTF8ToUTF16(text), true)) :
1449 string16());
1448 g_free(text); 1450 g_free(text);
1449 1451
1450 // Paste and Go menu item. 1452 // Paste and Go menu item.
1451 GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic( 1453 GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic(
1452 gfx::ConvertAcceleratorsFromWindowsStyle( 1454 gfx::ConvertAcceleratorsFromWindowsStyle(
1453 l10n_util::GetStringUTF8(model_->is_paste_and_search() ? 1455 l10n_util::GetStringUTF8(model_->is_paste_and_search() ?
1454 IDS_PASTE_AND_SEARCH : IDS_PASTE_AND_GO)).c_str()); 1456 IDS_PASTE_AND_SEARCH : IDS_PASTE_AND_GO)).c_str());
1455 gtk_menu_shell_append(GTK_MENU_SHELL(menu), paste_go_menuitem); 1457 gtk_menu_shell_append(GTK_MENU_SHELL(menu), paste_go_menuitem);
1456 g_signal_connect(paste_go_menuitem, "activate", 1458 g_signal_connect(paste_go_menuitem, "activate",
1457 G_CALLBACK(HandlePasteAndGoThunk), this); 1459 G_CALLBACK(HandlePasteAndGoThunk), this);
1458 gtk_widget_set_sensitive(paste_go_menuitem, 1460 gtk_widget_set_sensitive(paste_go_menuitem,
1459 model_->CanPasteAndGo(text_wstr)); 1461 model_->CanPasteAndGo(sanitized_text));
Peter Kasting 2011/11/15 07:26:12 This call still needs to be moved up before the ca
SanjoyPal 2011/11/15 12:42:37 Done.
1460 gtk_widget_show(paste_go_menuitem); 1462 gtk_widget_show(paste_go_menuitem);
1461 1463
1462 g_signal_connect(menu, "deactivate", 1464 g_signal_connect(menu, "deactivate",
1463 G_CALLBACK(HandlePopupMenuDeactivateThunk), this); 1465 G_CALLBACK(HandlePopupMenuDeactivateThunk), this);
1464 } 1466 }
1465 1467
1466 void OmniboxViewGtk::HandleEditSearchEngines(GtkWidget* sender) { 1468 void OmniboxViewGtk::HandleEditSearchEngines(GtkWidget* sender) {
1467 command_updater_->ExecuteCommand(IDC_EDIT_SEARCH_ENGINES); 1469 command_updater_->ExecuteCommand(IDC_EDIT_SEARCH_ENGINES);
1468 } 1470 }
1469 1471
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 2396
2395 // Make all the children of the widget visible. NOTE: this won't display 2397 // Make all the children of the widget visible. NOTE: this won't display
2396 // anything, it just toggles the visible flag. 2398 // anything, it just toggles the visible flag.
2397 gtk_widget_show_all(omnibox_view->GetNativeView()); 2399 gtk_widget_show_all(omnibox_view->GetNativeView());
2398 // Hide the widget. NativeViewHostGtk will make it visible again as necessary. 2400 // Hide the widget. NativeViewHostGtk will make it visible again as necessary.
2399 gtk_widget_hide(omnibox_view->GetNativeView()); 2401 gtk_widget_hide(omnibox_view->GetNativeView());
2400 2402
2401 return omnibox_view; 2403 return omnibox_view;
2402 } 2404 }
2403 #endif 2405 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698