Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Side by Side Diff: chrome/browser/autocomplete/extension_app_provider.cc

Issue 25366003: Moved some functions off ExtensionService into a new file extension_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile failures Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_system_factory.h" 14 #include "chrome/browser/extensions/extension_system_factory.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/extension.h" 22 #include "chrome/common/extensions/extension.h"
22 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
23 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 extension_apps_.clear(); 155 extension_apps_.clear();
155 for (ExtensionSet::const_iterator iter = extensions->begin(); 156 for (ExtensionSet::const_iterator iter = extensions->begin();
156 iter != extensions->end(); ++iter) { 157 iter != extensions->end(); ++iter) {
157 const extensions::Extension* app = iter->get(); 158 const extensions::Extension* app = iter->get();
158 if (!app->ShouldDisplayInAppLauncher()) 159 if (!app->ShouldDisplayInAppLauncher())
159 continue; 160 continue;
160 // Note: Apps that appear in the NTP only are not added here since this 161 // Note: Apps that appear in the NTP only are not added here since this
161 // provider is currently only used in the app launcher. 162 // provider is currently only used in the app launcher.
162 163
163 if (profile_->IsOffTheRecord() && 164 if (profile_->IsOffTheRecord() &&
164 !extension_service->CanLoadInIncognito(app)) 165 !extension_util::CanLoadInIncognito(app, extension_service))
165 continue; 166 continue;
166 167
167 GURL launch_url = app->is_platform_app() ? 168 GURL launch_url = app->is_platform_app() ?
168 app->url() : extensions::AppLaunchInfo::GetFullLaunchURL(app); 169 app->url() : extensions::AppLaunchInfo::GetFullLaunchURL(app);
169 DCHECK(launch_url.is_valid()); 170 DCHECK(launch_url.is_valid());
170 171
171 ExtensionApp extension_app = { 172 ExtensionApp extension_app = {
172 UTF8ToUTF16(app->name()), 173 UTF8ToUTF16(app->name()),
173 UTF8ToUTF16(launch_url.spec()), 174 UTF8ToUTF16(launch_url.spec()),
174 // Only hosted apps have recognizable URLs that users might type in, 175 // Only hosted apps have recognizable URLs that users might type in,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 history::URLRow info; 216 history::URLRow info;
216 url_db->GetRowForURL(url, &info); 217 url_db->GetRowForURL(url, &info);
217 type_count_boost = 218 type_count_boost =
218 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); 219 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count())));
219 } 220 }
220 int relevance = 575 + static_cast<int>(type_count_boost) + 221 int relevance = 575 + static_cast<int>(type_count_boost) +
221 static_cast<int>(fraction_boost); 222 static_cast<int>(fraction_boost);
222 DCHECK_LE(relevance, kMaxRelevance); 223 DCHECK_LE(relevance, kMaxRelevance);
223 return relevance; 224 return relevance;
224 } 225 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698