OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <set> |
| 11 #include <string> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/file_path.h" |
| 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/string16.h" |
| 18 #include "base/timer.h" |
| 19 #include "chrome/browser/cancelable_request.h" |
| 20 #include "chrome/browser/history/history_types.h" |
| 21 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 22 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h" |
| 23 #include "content/public/browser/notification_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" |
| 25 #include "content/public/common/url_fetcher_delegate.h" |
| 26 #include "googleurl/src/gurl.h" |
| 27 |
| 28 class OAuth2AccessTokenFetcher; |
| 29 class Profile; |
| 30 |
| 31 namespace base { |
| 32 class DictionaryValue; |
| 33 } |
| 34 |
| 35 namespace history { |
| 36 |
| 37 class WebHistoryService : public ProfileKeyedService, |
| 38 public content::URLFetcherDelegate, |
| 39 public content::NotificationObserver, |
| 40 public OAuth2AccessTokenConsumer { |
| 41 public: |
| 42 // Returns the WebHistoryService for |profile|, creating a new one if needed. |
| 43 static WebHistoryService* GetForProfile(Profile* profile); |
| 44 |
| 45 explicit WebHistoryService(Profile* profile); |
| 46 virtual ~WebHistoryService(); |
| 47 |
| 48 typedef base::Callback<void()> QueryWebHistoryCallback; |
| 49 |
| 50 // content::URLFetcherDelegate method. |
| 51 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 52 |
| 53 // content::NotificationObserver method. |
| 54 virtual void Observe(int type, |
| 55 const content::NotificationSource& source, |
| 56 const content::NotificationDetails& details) OVERRIDE; |
| 57 |
| 58 // OAuth2AccessTokenConsumer methods. |
| 59 virtual void OnGetTokenSuccess(const std::string& access_token) OVERRIDE; |
| 60 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| 61 |
| 62 void QueryHistory(const string16& text_query, |
| 63 const QueryOptions& options, |
| 64 CancelableRequestConsumerBase* consumer, |
| 65 const QueryWebHistoryCallback& callback); |
| 66 |
| 67 private: |
| 68 // Send the OAuth2AccessTokenFetcher request. |
| 69 void RefreshAccessToken(); |
| 70 void GetHistory(); |
| 71 |
| 72 Profile* profile_; |
| 73 |
| 74 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. |
| 75 content::NotificationRegistrar registrar_; |
| 76 |
| 77 std::string access_token_; |
| 78 |
| 79 scoped_ptr<content::URLFetcher> url_fetcher_; |
| 80 |
| 81 QueryWebHistoryCallback query_history_callback_; |
| 82 |
| 83 // The pending OAuth access token request and a timer for retrying on failure. |
| 84 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; |
| 85 base::OneShotTimer<WebHistoryService> auth_retry_timer_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); |
| 88 }; |
| 89 |
| 90 } // namespace history |
| 91 |
| 92 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_ |
OLD | NEW |