OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "chrome/browser/ui/app_list/search/search_provider.h" | 12 #include "chrome/browser/ui/app_list/search/search_provider.h" |
13 | 13 |
| 14 class Profile; |
| 15 |
14 namespace app_list { | 16 namespace app_list { |
15 | 17 |
16 // Helper class for webservice based searches. | 18 // Helper class for webservice based searches. |
17 class WebserviceSearchProvider : public SearchProvider { | 19 class WebserviceSearchProvider : public SearchProvider { |
18 public: | 20 public: |
19 WebserviceSearchProvider(); | 21 explicit WebserviceSearchProvider(Profile* profile); |
20 virtual ~WebserviceSearchProvider(); | 22 virtual ~WebserviceSearchProvider(); |
21 | 23 |
| 24 // Validate the query for privacy and size. |
| 25 bool IsValidQuery(const string16& query); |
| 26 |
| 27 // Start a query with throttling enabled. |
22 void StartThrottledQuery(const base::Closure& start_query); | 28 void StartThrottledQuery(const base::Closure& start_query); |
23 bool IsSensitiveInput(const string16& query); | |
24 | 29 |
25 void set_use_throttling(bool use) { use_throttling_ = use; } | 30 void set_use_throttling(bool use) { use_throttling_ = use; } |
26 | 31 |
| 32 protected: |
| 33 Profile* profile_; |
| 34 |
27 private: | 35 private: |
| 36 bool IsSensitiveInput(const string16& query); |
| 37 |
28 // The timestamp when the last key event happened. | 38 // The timestamp when the last key event happened. |
29 base::Time last_keytyped_; | 39 base::Time last_keytyped_; |
30 | 40 |
31 // The timer to throttle QPS to the webstore search . | 41 // The timer to throttle QPS. |
32 base::OneShotTimer<WebserviceSearchProvider> query_throttler_; | 42 base::OneShotTimer<WebserviceSearchProvider> query_throttler_; |
33 | 43 |
34 // The flag for tests. It prevents the throttling If set to false. | 44 // The flag for tests. It prevents the throttling If set to false. |
35 bool use_throttling_; | 45 bool use_throttling_; |
36 | 46 |
37 DISALLOW_COPY_AND_ASSIGN(WebserviceSearchProvider); | 47 DISALLOW_COPY_AND_ASSIGN(WebserviceSearchProvider); |
38 }; | 48 }; |
39 | 49 |
40 } // namespace app_list | 50 } // namespace app_list |
41 | 51 |
42 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H
_ | 52 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H
_ |
OLD | NEW |