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/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_ui_util.h" |
14 #include "chrome/browser/extensions/extension_util.h" | 15 #include "chrome/browser/extensions/extension_util.h" |
15 #include "chrome/browser/history/history_service.h" | 16 #include "chrome/browser/history/history_service.h" |
16 #include "chrome/browser/history/history_service_factory.h" | 17 #include "chrome/browser/history/history_service_factory.h" |
17 #include "chrome/browser/history/url_database.h" | 18 #include "chrome/browser/history/url_database.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/extensions/application_launch.h" | 20 #include "chrome/browser/ui/extensions/application_launch.h" |
20 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 21 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 22 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "extensions/browser/extension_registry.h" | 24 #include "extensions/browser/extension_registry.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void ExtensionAppProvider::RefreshAppList() { | 152 void ExtensionAppProvider::RefreshAppList() { |
152 ExtensionService* extension_service = | 153 ExtensionService* extension_service = |
153 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 154 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
154 if (!extension_service) | 155 if (!extension_service) |
155 return; // During testing, there is no extension service. | 156 return; // During testing, there is no extension service. |
156 const extensions::ExtensionSet* extensions = extension_service->extensions(); | 157 const extensions::ExtensionSet* extensions = extension_service->extensions(); |
157 extension_apps_.clear(); | 158 extension_apps_.clear(); |
158 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); | 159 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); |
159 iter != extensions->end(); ++iter) { | 160 iter != extensions->end(); ++iter) { |
160 const extensions::Extension* app = iter->get(); | 161 const extensions::Extension* app = iter->get(); |
161 if (!app->ShouldDisplayInAppLauncher()) | 162 if (!extensions::ui_util::ShouldDisplayInAppLauncher(app, profile_)) |
162 continue; | 163 continue; |
163 // Note: Apps that appear in the NTP only are not added here since this | 164 // Note: Apps that appear in the NTP only are not added here since this |
164 // provider is currently only used in the app launcher. | 165 // provider is currently only used in the app launcher. |
165 | 166 |
166 if (profile_->IsOffTheRecord() && | 167 if (profile_->IsOffTheRecord() && |
167 !extensions::util::CanLoadInIncognito(app, profile_)) | 168 !extensions::util::CanLoadInIncognito(app, profile_)) |
168 continue; | 169 continue; |
169 | 170 |
170 GURL launch_url = app->is_platform_app() ? | 171 GURL launch_url = app->is_platform_app() ? |
171 app->url() : extensions::AppLaunchInfo::GetFullLaunchURL(app); | 172 app->url() : extensions::AppLaunchInfo::GetFullLaunchURL(app); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 history::URLRow info; | 219 history::URLRow info; |
219 url_db->GetRowForURL(url, &info); | 220 url_db->GetRowForURL(url, &info); |
220 type_count_boost = | 221 type_count_boost = |
221 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); | 222 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); |
222 } | 223 } |
223 int relevance = 575 + static_cast<int>(type_count_boost) + | 224 int relevance = 575 + static_cast<int>(type_count_boost) + |
224 static_cast<int>(fraction_boost); | 225 static_cast<int>(fraction_boost); |
225 DCHECK_LE(relevance, kMaxRelevance); | 226 DCHECK_LE(relevance, kMaxRelevance); |
226 return relevance; | 227 return relevance; |
227 } | 228 } |
OLD | NEW |