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/autocomplete/extension_app_provider.h" | 5 #include "chrome/browser/autocomplete/extension_app_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 content::Source<Profile>(profile_->GetOriginalProfile())); | 35 content::Source<Profile>(profile_->GetOriginalProfile())); |
36 RefreshAppList(); | 36 RefreshAppList(); |
37 } | 37 } |
38 | 38 |
39 // static. | 39 // static. |
40 void ExtensionAppProvider::LaunchAppFromOmnibox( | 40 void ExtensionAppProvider::LaunchAppFromOmnibox( |
41 const AutocompleteMatch& match, | 41 const AutocompleteMatch& match, |
42 Profile* profile, | 42 Profile* profile, |
43 WindowOpenDisposition disposition) { | 43 WindowOpenDisposition disposition) { |
44 ExtensionService* service = | 44 ExtensionService* service = |
45 ExtensionSystemFactory::GetForProfile(profile)->extension_service(); | 45 extensions::ExtensionSystemFactory::GetForProfile(profile)-> |
| 46 extension_service(); |
46 const extensions::Extension* extension = | 47 const extensions::Extension* extension = |
47 service->GetInstalledApp(match.destination_url); | 48 service->GetInstalledApp(match.destination_url); |
48 // While the Omnibox popup is open, the extension can be updated, changing | 49 // While the Omnibox popup is open, the extension can be updated, changing |
49 // its URL and leaving us with no extension being found. In this case, we | 50 // its URL and leaving us with no extension being found. In this case, we |
50 // ignore the request. | 51 // ignore the request. |
51 if (!extension) | 52 if (!extension) |
52 return; | 53 return; |
53 | 54 |
54 AppLauncherHandler::RecordAppLaunchType( | 55 AppLauncherHandler::RecordAppLaunchType( |
55 extension_misc::APP_LAUNCH_OMNIBOX_APP); | 56 extension_misc::APP_LAUNCH_OMNIBOX_APP); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 input, *app, name_match_index, url_match_index)); | 143 input, *app, name_match_index, url_match_index)); |
143 } | 144 } |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
147 ExtensionAppProvider::~ExtensionAppProvider() { | 148 ExtensionAppProvider::~ExtensionAppProvider() { |
148 } | 149 } |
149 | 150 |
150 void ExtensionAppProvider::RefreshAppList() { | 151 void ExtensionAppProvider::RefreshAppList() { |
151 ExtensionService* extension_service = | 152 ExtensionService* extension_service = |
152 ExtensionSystemFactory::GetForProfile(profile_)->extension_service(); | 153 extensions::ExtensionSystemFactory::GetForProfile(profile_)-> |
| 154 extension_service(); |
153 if (!extension_service) | 155 if (!extension_service) |
154 return; // During testing, there is no extension service. | 156 return; // During testing, there is no extension service. |
155 const ExtensionSet* extensions = extension_service->extensions(); | 157 const ExtensionSet* extensions = extension_service->extensions(); |
156 extension_apps_.clear(); | 158 extension_apps_.clear(); |
157 for (ExtensionSet::const_iterator iter = extensions->begin(); | 159 for (ExtensionSet::const_iterator iter = extensions->begin(); |
158 iter != extensions->end(); ++iter) { | 160 iter != extensions->end(); ++iter) { |
159 const extensions::Extension* app = *iter; | 161 const extensions::Extension* app = *iter; |
160 if (!app->is_app()) | 162 if (!app->is_app()) |
161 continue; | 163 continue; |
162 | 164 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 history::URLRow info; | 217 history::URLRow info; |
216 url_db->GetRowForURL(url, &info); | 218 url_db->GetRowForURL(url, &info); |
217 type_count_boost = | 219 type_count_boost = |
218 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); | 220 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); |
219 } | 221 } |
220 int relevance = 575 + static_cast<int>(type_count_boost) + | 222 int relevance = 575 + static_cast<int>(type_count_boost) + |
221 static_cast<int>(fraction_boost); | 223 static_cast<int>(fraction_boost); |
222 DCHECK_LE(relevance, kMaxRelevance); | 224 DCHECK_LE(relevance, kMaxRelevance); |
223 return relevance; | 225 return relevance; |
224 } | 226 } |
OLD | NEW |