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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/history.h" 13 #include "chrome/browser/history/history.h"
14 #include "chrome/browser/history/url_database.h" 14 #include "chrome/browser/history/url_database.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/chrome_notification_types.h"
16 #include "content/common/notification_service.h" 17 #include "content/common/notification_service.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 19
19 ExtensionAppProvider::ExtensionAppProvider(ACProviderListener* listener, 20 ExtensionAppProvider::ExtensionAppProvider(ACProviderListener* listener,
20 Profile* profile) 21 Profile* profile)
21 : AutocompleteProvider(listener, profile, "ExtensionApps") { 22 : AutocompleteProvider(listener, profile, "ExtensionApps") {
22 RegisterForNotifications(); 23 RegisterForNotifications();
23 RefreshAppList(); 24 RefreshAppList();
24 } 25 }
25 26
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 continue; 97 continue;
97 98
98 extension_apps_.push_back( 99 extension_apps_.push_back(
99 std::make_pair(UTF8ToUTF16((*app)->name()), 100 std::make_pair(UTF8ToUTF16((*app)->name()),
100 UTF8ToUTF16((*app)->GetFullLaunchURL().spec()))); 101 UTF8ToUTF16((*app)->GetFullLaunchURL().spec())));
101 } 102 }
102 } 103 }
103 } 104 }
104 105
105 void ExtensionAppProvider::RegisterForNotifications() { 106 void ExtensionAppProvider::RegisterForNotifications() {
106 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 107 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
107 NotificationService::AllSources()); 108 NotificationService::AllSources());
108 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED, 109 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
109 NotificationService::AllSources()); 110 NotificationService::AllSources());
110 } 111 }
111 112
112 void ExtensionAppProvider::Observe(NotificationType type, 113 void ExtensionAppProvider::Observe(int type,
113 const NotificationSource& source, 114 const NotificationSource& source,
114 const NotificationDetails& details) { 115 const NotificationDetails& details) {
115 RefreshAppList(); 116 RefreshAppList();
116 } 117 }
117 118
118 int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type, 119 int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type,
119 int input_length, 120 int input_length,
120 int target_length, 121 int target_length,
121 const GURL& url) { 122 const GURL& url) {
122 // If you update the algorithm here, please remember to update the tables in 123 // If you update the algorithm here, please remember to update the tables in
(...skipping 21 matching lines...) Expand all
144 history::URLRow info; 145 history::URLRow info;
145 url_db->GetRowForURL(url, &info); 146 url_db->GetRowForURL(url, &info);
146 type_count_boost = 147 type_count_boost =
147 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); 148 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count())));
148 } 149 }
149 int relevance = 575 + static_cast<int>(type_count_boost) + 150 int relevance = 575 + static_cast<int>(type_count_boost) +
150 static_cast<int>(fraction_boost); 151 static_cast<int>(fraction_boost);
151 DCHECK_LE(relevance, kMaxRelevance); 152 DCHECK_LE(relevance, kMaxRelevance);
152 return relevance; 153 return relevance;
153 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider.h ('k') | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698