| 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_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse
rver.h" | 13 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse
rver.h" |
| 14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche
r.h" |
| 15 #include "chrome/browser/extensions/extension_function.h" |
| 16 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 13 | 17 |
| 14 class Profile; | 18 class Profile; |
| 15 | 19 |
| 16 namespace extensions { | 20 namespace extensions { |
| 17 | 21 |
| 18 // Observes a single InvalidationHandler and generates onMessage events. | 22 // Observes a single InvalidationHandler and generates onMessage events. |
| 19 class PushMessagingEventRouter : public InvalidationHandlerObserver { | 23 class PushMessagingEventRouter : public InvalidationHandlerObserver { |
| 20 public: | 24 public: |
| 21 explicit PushMessagingEventRouter(Profile* profile); | 25 explicit PushMessagingEventRouter(Profile* profile); |
| 22 virtual ~PushMessagingEventRouter(); | 26 virtual ~PushMessagingEventRouter(); |
| 23 | 27 |
| 24 void Init(); | 28 void Init(); |
| 25 | 29 |
| 26 private: | 30 private: |
| 27 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); | 31 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); |
| 28 | 32 |
| 29 // InvalidationHandlerObserver implementation. | 33 // InvalidationHandlerObserver implementation. |
| 30 virtual void OnMessage(const std::string& extension_id, | 34 virtual void OnMessage(const std::string& extension_id, |
| 31 int subchannel, | 35 int subchannel, |
| 32 const std::string& payload) OVERRIDE; | 36 const std::string& payload) OVERRIDE; |
| 33 | 37 |
| 34 Profile* profile_; | 38 Profile* profile_; |
| 35 | 39 |
| 36 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); | 40 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); |
| 37 }; | 41 }; |
| 38 | 42 |
| 43 class PushMessagingGetChannelIdFunction |
| 44 : public AsyncExtensionFunction, public ObfuscatedGaiaIdFetcher::Delegate { |
| 45 public: |
| 46 PushMessagingGetChannelIdFunction(); |
| 47 |
| 48 protected: |
| 49 virtual ~PushMessagingGetChannelIdFunction(); |
| 50 |
| 51 // ExtensionFunction: |
| 52 virtual bool RunImpl() OVERRIDE; |
| 53 DECLARE_EXTENSION_FUNCTION_NAME("experimental.pushMessaging.getChannelId"); |
| 54 |
| 55 private: |
| 56 void ReportResult(const std::string& gaiaId, const long status); |
| 57 // ObfuscatedGiaiaIdFetcher::Delegate implementation. |
| 58 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) |
| 59 OVERRIDE; |
| 60 virtual void OnObfuscatedGaiaIdFetchFailure( |
| 61 const GoogleServiceAuthError& error) OVERRIDE; |
| 62 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); |
| 65 }; |
| 66 |
| 39 } // namespace extension | 67 } // namespace extension |
| 40 | 68 |
| 41 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 69 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| OLD | NEW |