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 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h" | 5 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "components/metrics/proto/omnibox_event.pb.h" | 26 #include "components/metrics/proto/omnibox_event.pb.h" |
27 #include "components/omnibox/autocomplete_match.h" | 27 #include "components/omnibox/autocomplete_match.h" |
28 #include "components/omnibox/autocomplete_provider.h" | 28 #include "components/omnibox/autocomplete_provider.h" |
29 #include "components/search_engines/template_url.h" | 29 #include "components/search_engines/template_url.h" |
30 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
31 #include "mojo/common/common_type_converters.h" | 31 #include "mojo/common/common_type_converters.h" |
32 | 32 |
33 namespace mojo { | 33 namespace mojo { |
34 | 34 |
35 template <> | 35 template <> |
36 class TypeConverter<mojo::Array<AutocompleteAdditionalInfoPtr>, | 36 struct TypeConverter<mojo::Array<AutocompleteAdditionalInfoPtr>, |
37 AutocompleteMatch::AdditionalInfo> { | 37 AutocompleteMatch::AdditionalInfo> { |
38 public: | 38 static mojo::Array<AutocompleteAdditionalInfoPtr> Convert( |
39 static mojo::Array<AutocompleteAdditionalInfoPtr> ConvertFrom( | |
40 const AutocompleteMatch::AdditionalInfo& input) { | 39 const AutocompleteMatch::AdditionalInfo& input) { |
41 mojo::Array<AutocompleteAdditionalInfoPtr> array(input.size()); | 40 mojo::Array<AutocompleteAdditionalInfoPtr> array(input.size()); |
42 size_t index = 0; | 41 size_t index = 0; |
43 for (AutocompleteMatch::AdditionalInfo::const_iterator i = input.begin(); | 42 for (AutocompleteMatch::AdditionalInfo::const_iterator i = input.begin(); |
44 i != input.end(); ++i, index++) { | 43 i != input.end(); ++i, index++) { |
45 AutocompleteAdditionalInfoPtr item(AutocompleteAdditionalInfo::New()); | 44 AutocompleteAdditionalInfoPtr item(AutocompleteAdditionalInfo::New()); |
46 item->key = i->first; | 45 item->key = i->first; |
47 item->value = i->second; | 46 item->value = i->second; |
48 array[index] = item.Pass(); | 47 array[index] = item.Pass(); |
49 } | 48 } |
50 return array.Pass(); | 49 return array.Pass(); |
51 } | 50 } |
52 }; | 51 }; |
53 | 52 |
54 template <> | 53 template <> |
55 class TypeConverter<AutocompleteMatchMojoPtr, AutocompleteMatch> { | 54 struct TypeConverter<AutocompleteMatchMojoPtr, AutocompleteMatch> { |
56 public: | 55 static AutocompleteMatchMojoPtr Convert(const AutocompleteMatch& input) { |
57 static AutocompleteMatchMojoPtr ConvertFrom(const AutocompleteMatch& input) { | |
58 AutocompleteMatchMojoPtr result(AutocompleteMatchMojo::New()); | 56 AutocompleteMatchMojoPtr result(AutocompleteMatchMojo::New()); |
59 if (input.provider != NULL) { | 57 if (input.provider != NULL) { |
60 result->provider_name = input.provider->GetName(); | 58 result->provider_name = input.provider->GetName(); |
61 result->provider_done = input.provider->done(); | 59 result->provider_done = input.provider->done(); |
62 } | 60 } |
63 result->relevance = input.relevance; | 61 result->relevance = input.relevance; |
64 result->deletable = input.deletable; | 62 result->deletable = input.deletable; |
65 result->fill_into_edit = mojo::String::From(input.fill_into_edit); | 63 result->fill_into_edit = mojo::String::From(input.fill_into_edit); |
66 result->inline_autocompletion = | 64 result->inline_autocompletion = |
67 mojo::String::From(input.inline_autocompletion); | 65 mojo::String::From(input.inline_autocompletion); |
(...skipping 19 matching lines...) Expand all Loading... |
87 result->duplicates = static_cast<int32>(input.duplicate_matches.size()); | 85 result->duplicates = static_cast<int32>(input.duplicate_matches.size()); |
88 result->from_previous = input.from_previous; | 86 result->from_previous = input.from_previous; |
89 | 87 |
90 result->additional_info = | 88 result->additional_info = |
91 mojo::Array<AutocompleteAdditionalInfoPtr>::From(input.additional_info); | 89 mojo::Array<AutocompleteAdditionalInfoPtr>::From(input.additional_info); |
92 return result.Pass(); | 90 return result.Pass(); |
93 } | 91 } |
94 }; | 92 }; |
95 | 93 |
96 template <> | 94 template <> |
97 class TypeConverter<AutocompleteResultsForProviderMojoPtr, | 95 struct TypeConverter<AutocompleteResultsForProviderMojoPtr, |
98 scoped_refptr<AutocompleteProvider> > { | 96 scoped_refptr<AutocompleteProvider> > { |
99 public: | 97 static AutocompleteResultsForProviderMojoPtr Convert( |
100 static AutocompleteResultsForProviderMojoPtr ConvertFrom( | |
101 const scoped_refptr<AutocompleteProvider>& input) { | 98 const scoped_refptr<AutocompleteProvider>& input) { |
102 AutocompleteResultsForProviderMojoPtr result( | 99 AutocompleteResultsForProviderMojoPtr result( |
103 AutocompleteResultsForProviderMojo::New()); | 100 AutocompleteResultsForProviderMojo::New()); |
104 result->provider_name = input->GetName(); | 101 result->provider_name = input->GetName(); |
105 result->results = | 102 result->results = |
106 mojo::Array<AutocompleteMatchMojoPtr>::From(input->matches()); | 103 mojo::Array<AutocompleteMatchMojoPtr>::From(input->matches()); |
107 return result.Pass(); | 104 return result.Pass(); |
108 } | 105 } |
109 }; | 106 }; |
110 | 107 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 ChromeAutocompleteSchemeClassifier(profile_)); | 195 ChromeAutocompleteSchemeClassifier(profile_)); |
199 controller_->Start(input_); | 196 controller_->Start(input_); |
200 } | 197 } |
201 | 198 |
202 void OmniboxUIHandler::ResetController() { | 199 void OmniboxUIHandler::ResetController() { |
203 controller_.reset(new AutocompleteController(profile_, | 200 controller_.reset(new AutocompleteController(profile_, |
204 TemplateURLServiceFactory::GetForProfile(profile_), | 201 TemplateURLServiceFactory::GetForProfile(profile_), |
205 this, | 202 this, |
206 AutocompleteClassifier::kDefaultOmniboxProviders)); | 203 AutocompleteClassifier::kDefaultOmniboxProviders)); |
207 } | 204 } |
OLD | NEW |