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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 6982011: Strip leading "javascript:" schemas from text pasted or dropped into the omnibox. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | Annotate | Revision Log
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/autocomplete/autocomplete_edit.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 autocomplete_controller_->Stop(true); 407 autocomplete_controller_->Stop(true);
408 } 408 }
409 409
410 bool AutocompleteEditModel::CanPasteAndGo(const string16& text) const { 410 bool AutocompleteEditModel::CanPasteAndGo(const string16& text) const {
411 if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL)) 411 if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL))
412 return false; 412 return false;
413 413
414 profile_->GetAutocompleteClassifier()->Classify(text, string16(), false, 414 profile_->GetAutocompleteClassifier()->Classify(text, string16(), false,
415 &paste_and_go_match_, &paste_and_go_alternate_nav_url_); 415 &paste_and_go_match_, &paste_and_go_alternate_nav_url_);
416 return paste_and_go_match_.destination_url.is_valid(); 416 return paste_and_go_match_.destination_url.is_valid() &&
Peter Kasting 2011/05/10 23:27:42 You shouldn't need this; callers should fix this u
Cris Neckar 2011/05/11 21:42:36 We also want to prevent the Paste And Go menu opti
417 !paste_and_go_match_.destination_url.SchemeIs("javascript");
Avi (use Gerrit) 2011/05/10 23:41:06 constant plz
Cris Neckar 2011/05/11 21:42:36 Done.
417 } 418 }
418 419
419 void AutocompleteEditModel::PasteAndGo() { 420 void AutocompleteEditModel::PasteAndGo() {
420 // The final parameter to OpenURL, keyword, is not quite correct here: it's 421 // The final parameter to OpenURL, keyword, is not quite correct here: it's
421 // possible to "paste and go" a string that contains a keyword. This is 422 // possible to "paste and go" a string that contains a keyword. This is
422 // enough of an edge case that we ignore this possibility. 423 // enough of an edge case that we ignore this possibility.
423 view_->RevertAll(); 424 view_->RevertAll();
424 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB, 425 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB,
425 paste_and_go_alternate_nav_url_, AutocompletePopupModel::kNoMatch, 426 paste_and_go_alternate_nav_url_, AutocompletePopupModel::kNoMatch,
426 string16()); 427 string16());
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // static 1007 // static
1007 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1008 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1008 switch (c) { 1009 switch (c) {
1009 case 0x0020: // Space 1010 case 0x0020: // Space
1010 case 0x3000: // Ideographic Space 1011 case 0x3000: // Ideographic Space
1011 return true; 1012 return true;
1012 default: 1013 default:
1013 return false; 1014 return false;
1014 } 1015 }
1015 } 1016 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698