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

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

Issue 12316077: Move the parsing of app.launch related keys out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.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/string16.h" 10 #include "base/string16.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system_factory.h" 13 #include "chrome/browser/extensions/extension_system_factory.h"
14 #include "chrome/browser/history/history_service.h" 14 #include "chrome/browser/history/history_service.h"
15 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/history/url_database.h" 16 #include "chrome/browser/history/url_database.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/extensions/application_launch.h" 18 #include "chrome/browser/ui/extensions/application_launch.h"
19 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 19 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/extensions/app_launcher_info.h"
21 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
22 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 25
25 ExtensionAppProvider::ExtensionAppProvider( 26 ExtensionAppProvider::ExtensionAppProvider(
26 AutocompleteProviderListener* listener, 27 AutocompleteProviderListener* listener,
27 Profile* profile) 28 Profile* profile)
28 : AutocompleteProvider(listener, profile, 29 : AutocompleteProvider(listener, profile,
29 AutocompleteProvider::TYPE_EXTENSION_APP) { 30 AutocompleteProvider::TYPE_EXTENSION_APP) {
30 // Notifications of extensions loading and unloading always come from the 31 // Notifications of extensions loading and unloading always come from the
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 const extensions::Extension* app = *iter; 156 const extensions::Extension* app = *iter;
156 if (!app->ShouldDisplayInAppLauncher()) 157 if (!app->ShouldDisplayInAppLauncher())
157 continue; 158 continue;
158 // Note: Apps that appear in the NTP only are not added here since this 159 // Note: Apps that appear in the NTP only are not added here since this
159 // provider is currently only used in the app launcher. 160 // provider is currently only used in the app launcher.
160 161
161 if (profile_->IsOffTheRecord() && 162 if (profile_->IsOffTheRecord() &&
162 !extension_service->CanLoadInIncognito(app)) 163 !extension_service->CanLoadInIncognito(app))
163 continue; 164 continue;
164 165
165 GURL launch_url = 166 GURL launch_url = app->is_platform_app() ?
166 app->is_platform_app() ? app->url() : app->GetFullLaunchURL(); 167 app->url() : extensions::AppLauncherInfo::GetFullLaunchURL(app);
167 DCHECK(launch_url.is_valid()); 168 DCHECK(launch_url.is_valid());
168 169
169 ExtensionApp extension_app = { 170 ExtensionApp extension_app = {
170 UTF8ToUTF16(app->name()), 171 UTF8ToUTF16(app->name()),
171 UTF8ToUTF16(launch_url.spec()), 172 UTF8ToUTF16(launch_url.spec()),
172 // Only hosted apps have recognizable URLs that users might type in, 173 // Only hosted apps have recognizable URLs that users might type in,
173 // packaged apps and hosted apps use chrome-extension:// URLs that are 174 // packaged apps and hosted apps use chrome-extension:// URLs that are
174 // normally not shown to users. 175 // normally not shown to users.
175 app->is_hosted_app() 176 app->is_hosted_app()
176 }; 177 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 history::URLRow info; 214 history::URLRow info;
214 url_db->GetRowForURL(url, &info); 215 url_db->GetRowForURL(url, &info);
215 type_count_boost = 216 type_count_boost =
216 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); 217 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count())));
217 } 218 }
218 int relevance = 575 + static_cast<int>(type_count_boost) + 219 int relevance = 575 + static_cast<int>(type_count_boost) +
219 static_cast<int>(fraction_boost); 220 static_cast<int>(fraction_boost);
220 DCHECK_LE(relevance, kMaxRelevance); 221 DCHECK_LE(relevance, kMaxRelevance);
221 return relevance; 222 return relevance;
222 } 223 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698