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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view.cc

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 // This file defines helper functions shared by the various implementations 5 // This file defines helper functions shared by the various implementations
6 // of OmniboxView. 6 // of OmniboxView.
7 7
8 #include "chrome/browser/ui/omnibox/omnibox_view.h" 8 #include "chrome/browser/ui/omnibox/omnibox_view.h"
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 24 matching lines...) Expand all
35 return out; 35 return out;
36 } 36 }
37 37
38 // static 38 // static
39 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { 39 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) {
40 // Check for non-newline whitespace; if found, collapse whitespace runs down 40 // Check for non-newline whitespace; if found, collapse whitespace runs down
41 // to single spaces. 41 // to single spaces.
42 // TODO(shess): It may also make sense to ignore leading or 42 // TODO(shess): It may also make sense to ignore leading or
43 // trailing whitespace when making this determination. 43 // trailing whitespace when making this determination.
44 for (size_t i = 0; i < text.size(); ++i) { 44 for (size_t i = 0; i < text.size(); ++i) {
45 if (IsWhitespace(text[i]) && text[i] != '\n' && text[i] != '\r') { 45 if (base::IsUnicodeWhitespace(text[i]) &&
46 text[i] != '\n' && text[i] != '\r') {
46 const base::string16 collapsed = base::CollapseWhitespace(text, false); 47 const base::string16 collapsed = base::CollapseWhitespace(text, false);
47 // If the user is pasting all-whitespace, paste a single space 48 // If the user is pasting all-whitespace, paste a single space
48 // rather than nothing, since pasting nothing feels broken. 49 // rather than nothing, since pasting nothing feels broken.
49 return collapsed.empty() ? 50 return collapsed.empty() ?
50 base::ASCIIToUTF16(" ") : StripJavascriptSchemas(collapsed); 51 base::ASCIIToUTF16(" ") : StripJavascriptSchemas(collapsed);
51 } 52 }
52 } 53 }
53 54
54 // Otherwise, all whitespace is newlines; remove it entirely. 55 // Otherwise, all whitespace is newlines; remove it entirely.
55 return StripJavascriptSchemas(base::CollapseWhitespace(text, true)); 56 return StripJavascriptSchemas(base::CollapseWhitespace(text, true));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // |profile| can be NULL in tests. 188 // |profile| can be NULL in tests.
188 if (profile) 189 if (profile)
189 model_.reset(new OmniboxEditModel(this, controller, profile)); 190 model_.reset(new OmniboxEditModel(this, controller, profile));
190 } 191 }
191 192
192 void OmniboxView::TextChanged() { 193 void OmniboxView::TextChanged() {
193 EmphasizeURLComponents(); 194 EmphasizeURLComponents();
194 if (model_.get()) 195 if (model_.get())
195 model_->OnChanged(); 196 model_->OnChanged();
196 } 197 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.cc ('k') | chrome/browser/ui/search/search_ipc_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698