OLD | NEW |
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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 13 #include "chrome/browser/autocomplete/autocomplete_input.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 15 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
16 #include "components/metrics/proto/omnibox_input_type.pb.h" | |
17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
19 #include "ui/base/window_open_disposition.h" | 18 #include "ui/base/window_open_disposition.h" |
20 | 19 |
21 // This provider is responsible for keeping track of which Extension Apps are | 20 // This provider is responsible for keeping track of which Extension Apps are |
22 // installed and their URLs. An instance of it gets created and managed by | 21 // installed and their URLs. An instance of it gets created and managed by |
23 // AutocompleteController. | 22 // AutocompleteController. |
24 class ExtensionAppProvider : public AutocompleteProvider, | 23 class ExtensionAppProvider : public AutocompleteProvider, |
25 public content::NotificationObserver { | 24 public content::NotificationObserver { |
26 public: | 25 public: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Construct a match for the specified parameters. | 64 // Construct a match for the specified parameters. |
66 AutocompleteMatch CreateAutocompleteMatch(const AutocompleteInput& input, | 65 AutocompleteMatch CreateAutocompleteMatch(const AutocompleteInput& input, |
67 const ExtensionApp& app, | 66 const ExtensionApp& app, |
68 size_t name_match_index, | 67 size_t name_match_index, |
69 size_t url_match_index); | 68 size_t url_match_index); |
70 | 69 |
71 // Fetch the current app list and cache it locally. | 70 // Fetch the current app list and cache it locally. |
72 void RefreshAppList(); | 71 void RefreshAppList(); |
73 | 72 |
74 // Calculate the relevance of the match. | 73 // Calculate the relevance of the match. |
75 int CalculateRelevance(metrics::OmniboxInputType::Type type, | 74 int CalculateRelevance(AutocompleteInput::Type type, |
76 int input_length, | 75 int input_length, |
77 int target_length, | 76 int target_length, |
78 const GURL& url); | 77 const GURL& url); |
79 | 78 |
80 // content::NotificationObserver implementation: | 79 // content::NotificationObserver implementation: |
81 virtual void Observe(int type, | 80 virtual void Observe(int type, |
82 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
83 const content::NotificationDetails& details) OVERRIDE; | 82 const content::NotificationDetails& details) OVERRIDE; |
84 | 83 |
85 content::NotificationRegistrar registrar_; | 84 content::NotificationRegistrar registrar_; |
86 | 85 |
87 // Our cache of ExtensionApp objects (name + url) representing the extension | 86 // Our cache of ExtensionApp objects (name + url) representing the extension |
88 // apps we know/care about. | 87 // apps we know/care about. |
89 ExtensionApps extension_apps_; | 88 ExtensionApps extension_apps_; |
90 | 89 |
91 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); | 90 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); |
92 }; | 91 }; |
93 | 92 |
94 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 93 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
OLD | NEW |