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/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
kaiwang
2012/09/06 22:11:47
remove?
| |
15 #include "ui/base/clipboard/clipboard.h" | 15 #include "ui/base/clipboard/clipboard.h" |
16 | 16 |
17 // static | 17 // static |
18 string16 OmniboxView::StripJavascriptSchemas(const string16& text) { | 18 string16 OmniboxView::StripJavascriptSchemas(const string16& text) { |
19 const string16 kJsPrefix(ASCIIToUTF16(chrome::kJavaScriptScheme) + | 19 const string16 kJsPrefix(ASCIIToUTF16(chrome::kJavaScriptScheme) + |
20 ASCIIToUTF16(":")); | 20 ASCIIToUTF16(":")); |
21 string16 out(text); | 21 string16 out(text); |
22 while (StartsWith(out, kJsPrefix, false)) | 22 while (StartsWith(out, kJsPrefix, false)) |
23 TrimWhitespace(out.substr(kJsPrefix.length()), TRIM_LEADING, &out); | 23 TrimWhitespace(out.substr(kJsPrefix.length()), TRIM_LEADING, &out); |
24 return out; | 24 return out; |
25 } | 25 } |
26 | 26 |
27 // static | 27 // static |
28 string16 OmniboxView::GetClipboardText() { | 28 string16 OmniboxView::GetClipboardText() { |
29 // Try text format. | 29 // Try text format. |
30 ui::Clipboard* clipboard = g_browser_process->clipboard(); | 30 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
31 if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), | 31 if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), |
32 ui::Clipboard::BUFFER_STANDARD)) { | 32 ui::Clipboard::BUFFER_STANDARD)) { |
33 string16 text; | 33 string16 text; |
34 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &text); | 34 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &text); |
35 | 35 |
36 // If the input contains non-newline whitespace, treat it as | 36 // If the input contains non-newline whitespace, treat it as |
37 // search data and convert newlines to spaces. For instance, a | 37 // search data and convert newlines to spaces. For instance, a |
38 // street address. | 38 // street address. |
39 // TODO(shess): It may also make sense to ignore leading or | 39 // TODO(shess): It may also make sense to ignore leading or |
40 // trailing whitespace when making this determination. | 40 // trailing whitespace when making this determination. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 // |profile| can be NULL in tests. | 132 // |profile| can be NULL in tests. |
133 if (profile) | 133 if (profile) |
134 model_.reset(new OmniboxEditModel(this, controller, profile)); | 134 model_.reset(new OmniboxEditModel(this, controller, profile)); |
135 } | 135 } |
136 | 136 |
137 void OmniboxView::TextChanged() { | 137 void OmniboxView::TextChanged() { |
138 EmphasizeURLComponents(); | 138 EmphasizeURLComponents(); |
139 if (model_.get()) | 139 if (model_.get()) |
140 model_->OnChanged(); | 140 model_->OnChanged(); |
141 } | 141 } |
OLD | NEW |