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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
14 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
16 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
19 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 19 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
23 | 23 |
24 // static | 24 // static |
25 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { | 25 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { |
26 const base::string16 kJsPrefix( | 26 const base::string16 kJsPrefix( |
27 base::ASCIIToUTF16(content::kJavaScriptScheme) + base::ASCIIToUTF16(":")); | 27 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":")); |
28 base::string16 out(text); | 28 base::string16 out(text); |
29 while (StartsWith(out, kJsPrefix, false)) { | 29 while (StartsWith(out, kJsPrefix, false)) { |
30 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, | 30 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, |
31 &out); | 31 &out); |
32 } | 32 } |
33 return out; | 33 return out; |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { | 37 base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // |profile| can be NULL in tests. | 218 // |profile| can be NULL in tests. |
219 if (profile) | 219 if (profile) |
220 model_.reset(new OmniboxEditModel(this, controller, profile)); | 220 model_.reset(new OmniboxEditModel(this, controller, profile)); |
221 } | 221 } |
222 | 222 |
223 void OmniboxView::TextChanged() { | 223 void OmniboxView::TextChanged() { |
224 EmphasizeURLComponents(); | 224 EmphasizeURLComponents(); |
225 if (model_.get()) | 225 if (model_.get()) |
226 model_->OnChanged(); | 226 model_->OnChanged(); |
227 } | 227 } |
OLD | NEW |