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

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

Issue 147923005: Split ExtensionSystem interface from ExtensionSystemImpl implementation, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re^3base Created 6 years, 10 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
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"
(...skipping 28 matching lines...) Expand all
39 content::Source<Profile>(profile_->GetOriginalProfile())); 39 content::Source<Profile>(profile_->GetOriginalProfile()));
40 RefreshAppList(); 40 RefreshAppList();
41 } 41 }
42 42
43 // static. 43 // static.
44 void ExtensionAppProvider::LaunchAppFromOmnibox( 44 void ExtensionAppProvider::LaunchAppFromOmnibox(
45 const AutocompleteMatch& match, 45 const AutocompleteMatch& match,
46 Profile* profile, 46 Profile* profile,
47 WindowOpenDisposition disposition) { 47 WindowOpenDisposition disposition) {
48 ExtensionService* service = 48 ExtensionService* service =
49 extensions::ExtensionSystemFactory::GetForProfile(profile)-> 49 extensions::ExtensionSystem::Get(profile)->extension_service();
50 extension_service();
51 const extensions::Extension* extension = 50 const extensions::Extension* extension =
52 service->GetInstalledApp(match.destination_url); 51 service->GetInstalledApp(match.destination_url);
53 // While the Omnibox popup is open, the extension can be updated, changing 52 // While the Omnibox popup is open, the extension can be updated, changing
54 // its URL and leaving us with no extension being found. In this case, we 53 // its URL and leaving us with no extension being found. In this case, we
55 // ignore the request. 54 // ignore the request.
56 if (!extension) 55 if (!extension)
57 return; 56 return;
58 57
59 CoreAppLauncherHandler::RecordAppLaunchType( 58 CoreAppLauncherHandler::RecordAppLaunchType(
60 extension_misc::APP_LAUNCH_OMNIBOX_APP, 59 extension_misc::APP_LAUNCH_OMNIBOX_APP,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 input, *app, name_match_index, url_match_index)); 142 input, *app, name_match_index, url_match_index));
144 } 143 }
145 } 144 }
146 } 145 }
147 146
148 ExtensionAppProvider::~ExtensionAppProvider() { 147 ExtensionAppProvider::~ExtensionAppProvider() {
149 } 148 }
150 149
151 void ExtensionAppProvider::RefreshAppList() { 150 void ExtensionAppProvider::RefreshAppList() {
152 ExtensionService* extension_service = 151 ExtensionService* extension_service =
153 extensions::ExtensionSystemFactory::GetForProfile(profile_)-> 152 extensions::ExtensionSystem::Get(profile_)->extension_service();
154 extension_service();
155 if (!extension_service) 153 if (!extension_service)
156 return; // During testing, there is no extension service. 154 return; // During testing, there is no extension service.
157 const extensions::ExtensionSet* extensions = extension_service->extensions(); 155 const extensions::ExtensionSet* extensions = extension_service->extensions();
158 extension_apps_.clear(); 156 extension_apps_.clear();
159 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); 157 for (extensions::ExtensionSet::const_iterator iter = extensions->begin();
160 iter != extensions->end(); ++iter) { 158 iter != extensions->end(); ++iter) {
161 const extensions::Extension* app = iter->get(); 159 const extensions::Extension* app = iter->get();
162 if (!app->ShouldDisplayInAppLauncher()) 160 if (!app->ShouldDisplayInAppLauncher())
163 continue; 161 continue;
164 // Note: Apps that appear in the NTP only are not added here since this 162 // Note: Apps that appear in the NTP only are not added here since this
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 history::URLRow info; 217 history::URLRow info;
220 url_db->GetRowForURL(url, &info); 218 url_db->GetRowForURL(url, &info);
221 type_count_boost = 219 type_count_boost =
222 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())));
223 } 221 }
224 int relevance = 575 + static_cast<int>(type_count_boost) + 222 int relevance = 575 + static_cast<int>(type_count_boost) +
225 static_cast<int>(fraction_boost); 223 static_cast<int>(fraction_boost);
226 DCHECK_LE(relevance, kMaxRelevance); 224 DCHECK_LE(relevance, kMaxRelevance);
227 return relevance; 225 return relevance;
228 } 226 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/shortcut_manager.cc ('k') | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698