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 // 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 10 matching lines...) Expand all Loading... |
21 #include "grit/components_scaled_resources.h" | 21 #include "grit/components_scaled_resources.h" |
22 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
23 #include "ui/base/clipboard/clipboard.h" | 23 #include "ui/base/clipboard/clipboard.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 | 25 |
26 // static | 26 // static |
27 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { | 27 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { |
28 const base::string16 kJsPrefix( | 28 const base::string16 kJsPrefix( |
29 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":")); | 29 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":")); |
30 base::string16 out(text); | 30 base::string16 out(text); |
31 while (base::StartsWith(out, kJsPrefix, false)) { | 31 while (base::StartsWith(out, kJsPrefix, |
| 32 base::CompareCase::INSENSITIVE_ASCII)) { |
32 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, | 33 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, |
33 &out); | 34 &out); |
34 } | 35 } |
35 return out; | 36 return out; |
36 } | 37 } |
37 | 38 |
38 // static | 39 // static |
39 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { | 40 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { |
40 // Check for non-newline whitespace; if found, collapse whitespace runs down | 41 // Check for non-newline whitespace; if found, collapse whitespace runs down |
41 // to single spaces. | 42 // to single spaces. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // |profile| can be NULL in tests. | 189 // |profile| can be NULL in tests. |
189 if (profile) | 190 if (profile) |
190 model_.reset(new OmniboxEditModel(this, controller, profile)); | 191 model_.reset(new OmniboxEditModel(this, controller, profile)); |
191 } | 192 } |
192 | 193 |
193 void OmniboxView::TextChanged() { | 194 void OmniboxView::TextChanged() { |
194 EmphasizeURLComponents(); | 195 EmphasizeURLComponents(); |
195 if (model_.get()) | 196 if (model_.get()) |
196 model_->OnChanged(); | 197 model_->OnChanged(); |
197 } | 198 } |
OLD | NEW |