| OLD | NEW |
| 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" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 extension_apps_.push_back( | 103 extension_apps_.push_back( |
| 104 std::make_pair(UTF8ToUTF16((*app)->name()), | 104 std::make_pair(UTF8ToUTF16((*app)->name()), |
| 105 UTF8ToUTF16((*app)->GetFullLaunchURL().spec()))); | 105 UTF8ToUTF16((*app)->GetFullLaunchURL().spec()))); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ExtensionAppProvider::RegisterForNotifications() { | 110 void ExtensionAppProvider::RegisterForNotifications() { |
| 111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 112 NotificationService::AllSources()); | 112 Source<Profile>(profile_)); |
| 113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 114 NotificationService::AllSources()); | 114 Source<Profile>(profile_)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ExtensionAppProvider::Observe(int type, | 117 void ExtensionAppProvider::Observe(int type, |
| 118 const NotificationSource& source, | 118 const NotificationSource& source, |
| 119 const NotificationDetails& details) { | 119 const NotificationDetails& details) { |
| 120 RefreshAppList(); | 120 RefreshAppList(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type, | 123 int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type, |
| 124 int input_length, | 124 int input_length, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 149 history::URLRow info; | 149 history::URLRow info; |
| 150 url_db->GetRowForURL(url, &info); | 150 url_db->GetRowForURL(url, &info); |
| 151 type_count_boost = | 151 type_count_boost = |
| 152 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); | 152 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); |
| 153 } | 153 } |
| 154 int relevance = 575 + static_cast<int>(type_count_boost) + | 154 int relevance = 575 + static_cast<int>(type_count_boost) + |
| 155 static_cast<int>(fraction_boost); | 155 static_cast<int>(fraction_boost); |
| 156 DCHECK_LE(relevance, kMaxRelevance); | 156 DCHECK_LE(relevance, kMaxRelevance); |
| 157 return relevance; | 157 return relevance; |
| 158 } | 158 } |
| OLD | NEW |