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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 1833133002: Disallow paste in readonly omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use specialized IsCommandIdEnabled Created 4 years, 8 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
« 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) 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/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 case IDC_EDIT_SEARCH_ENGINES: 363 case IDC_EDIT_SEARCH_ENGINES:
364 location_bar_view_->command_updater()->ExecuteCommand(command_id); 364 location_bar_view_->command_updater()->ExecuteCommand(command_id);
365 return; 365 return;
366 case IDS_MOVE_DOWN: 366 case IDS_MOVE_DOWN:
367 case IDS_MOVE_UP: 367 case IDS_MOVE_UP:
368 model()->OnUpOrDownKeyPressed(command_id == IDS_MOVE_DOWN ? 1 : -1); 368 model()->OnUpOrDownKeyPressed(command_id == IDS_MOVE_DOWN ? 1 : -1);
369 return; 369 return;
370 370
371 // These commands do invoke the popup. 371 // These commands do invoke the popup.
372 case IDS_APP_PASTE: 372 case IDS_APP_PASTE:
373 OnPaste(); 373 if (IsCommandIdEnabled(command_id))
374 OnPaste();
374 return; 375 return;
375 default: 376 default:
376 if (Textfield::IsCommandIdEnabled(command_id)) { 377 if (Textfield::IsCommandIdEnabled(command_id)) {
377 // The Textfield code will invoke OnBefore/AfterPossibleChange() itself 378 // The Textfield code will invoke OnBefore/AfterPossibleChange() itself
378 // as necessary. 379 // as necessary.
379 Textfield::ExecuteCommand(command_id, event_flags); 380 Textfield::ExecuteCommand(command_id, event_flags);
380 return; 381 return;
381 } 382 }
382 OnBeforePossibleChange(); 383 OnBeforePossibleChange();
383 location_bar_view_->command_updater()->ExecuteCommand(command_id); 384 location_bar_view_->command_updater()->ExecuteCommand(command_id);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return true; 759 return true;
759 } 760 }
760 break; 761 break;
761 case ui::VKEY_DOWN: 762 case ui::VKEY_DOWN:
762 if (!read_only()) { 763 if (!read_only()) {
763 model()->OnUpOrDownKeyPressed(1); 764 model()->OnUpOrDownKeyPressed(1);
764 return true; 765 return true;
765 } 766 }
766 break; 767 break;
767 case ui::VKEY_PRIOR: 768 case ui::VKEY_PRIOR:
768 if (control || alt || shift) 769 if (read_only() || control || alt || shift)
769 return false; 770 return false;
770 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); 771 model()->OnUpOrDownKeyPressed(-1 * model()->result().size());
771 return true; 772 return true;
772 case ui::VKEY_NEXT: 773 case ui::VKEY_NEXT:
773 if (control || alt || shift) 774 if (read_only() || control || alt || shift)
774 return false; 775 return false;
775 model()->OnUpOrDownKeyPressed(model()->result().size()); 776 model()->OnUpOrDownKeyPressed(model()->result().size());
776 return true; 777 return true;
777 case ui::VKEY_V: 778 case ui::VKEY_V:
778 if (control && !alt && !read_only()) { 779 if (control && !alt && !read_only()) {
779 ExecuteCommand(IDS_APP_PASTE, 0); 780 ExecuteCommand(IDS_APP_PASTE, 0);
780 return true; 781 return true;
781 } 782 }
782 break; 783 break;
783 case ui::VKEY_INSERT: 784 case ui::VKEY_INSERT:
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 menu_contents->InsertItemWithStringIdAt( 1075 menu_contents->InsertItemWithStringIdAt(
1075 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1076 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1076 } 1077 }
1077 1078
1078 // Minor note: We use IDC_ for command id here while the underlying textfield 1079 // Minor note: We use IDC_ for command id here while the underlying textfield
1079 // is using IDS_ for all its command ids. This is because views cannot depend 1080 // is using IDS_ for all its command ids. This is because views cannot depend
1080 // on IDC_ for now. 1081 // on IDC_ for now.
1081 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1082 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1082 IDS_EDIT_SEARCH_ENGINES); 1083 IDS_EDIT_SEARCH_ENGINES);
1083 } 1084 }
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