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 (StartsWith(out, kJsPrefix, false)) { | 31 while (base::StartsWith(out, kJsPrefix, false)) { |
32 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, | 32 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, |
33 &out); | 33 &out); |
34 } | 34 } |
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. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // |profile| can be NULL in tests. | 187 // |profile| can be NULL in tests. |
188 if (profile) | 188 if (profile) |
189 model_.reset(new OmniboxEditModel(this, controller, profile)); | 189 model_.reset(new OmniboxEditModel(this, controller, profile)); |
190 } | 190 } |
191 | 191 |
192 void OmniboxView::TextChanged() { | 192 void OmniboxView::TextChanged() { |
193 EmphasizeURLComponents(); | 193 EmphasizeURLComponents(); |
194 if (model_.get()) | 194 if (model_.get()) |
195 model_->OnChanged(); | 195 model_->OnChanged(); |
196 } | 196 } |
OLD | NEW |