webservice_search_provider.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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 3// found in the LICENSE file. 4 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_ 7 8#include "base/callback_forward.h" 9#include "base/strings/string16.h" 10#include "base/time/time.h" 11#include "base/timer/timer.h" 12#include "chrome/browser/ui/app_list/search/search_provider.h" 13 14namespace app_list { 15 16// Helper class for webservice based searches. 17class WebserviceSearchProvider : public SearchProvider { 18 public: 19 WebserviceSearchProvider(); 20 virtual ~WebserviceSearchProvider(); 21 22 void StartThrottledQuery(const base::Closure& start_query); 23 bool IsSensitiveInput(const string16& query); 24 25 void set_use_throttling(bool use) { use_throttling_ = use; } 26 27 private: 28 // The timestamp when the last key event happened. 29 base::Time last_keytyped_; 30 31 // The timer to throttle QPS to the webstore search . 32 base::OneShotTimer<WebserviceSearchProvider> query_throttler_; 33 34 // The flag for tests. It prevents the throttling If set to false. 35 bool use_throttling_; 36 37 DISALLOW_COPY_AND_ASSIGN(WebserviceSearchProvider); 38}; 39 40} // namespace app_list 41 42#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_ 43