| 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 | 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 "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" | 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche
r.h" |
| 18 #include "chrome/browser/extensions/extension_function.h" |
| 19 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 17 | 20 |
| 18 class Profile; | 21 class Profile; |
| 19 | 22 |
| 20 namespace extensions { | 23 namespace extensions { |
| 21 | 24 |
| 22 class PushMessagingInvalidationMapper; | 25 class PushMessagingInvalidationMapper; |
| 26 class ObfuscatedGaiaIdFetcher; |
| 23 | 27 |
| 24 // Observes a single InvalidationHandler and generates onMessage events. | 28 // Observes a single InvalidationHandler and generates onMessage events. |
| 25 class PushMessagingEventRouter | 29 class PushMessagingEventRouter |
| 26 : public PushMessagingInvalidationHandlerDelegate, | 30 : public PushMessagingInvalidationHandlerDelegate, |
| 27 public content::NotificationObserver { | 31 public content::NotificationObserver { |
| 28 public: | 32 public: |
| 29 explicit PushMessagingEventRouter(Profile* profile); | 33 explicit PushMessagingEventRouter(Profile* profile); |
| 30 virtual ~PushMessagingEventRouter(); | 34 virtual ~PushMessagingEventRouter(); |
| 31 | 35 |
| 32 void Init(); | 36 void Init(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 const content::NotificationSource& source, | 55 const content::NotificationSource& source, |
| 52 const content::NotificationDetails& details) OVERRIDE; | 56 const content::NotificationDetails& details) OVERRIDE; |
| 53 | 57 |
| 54 content::NotificationRegistrar registrar_; | 58 content::NotificationRegistrar registrar_; |
| 55 Profile* const profile_; | 59 Profile* const profile_; |
| 56 scoped_ptr<PushMessagingInvalidationMapper> handler_; | 60 scoped_ptr<PushMessagingInvalidationMapper> handler_; |
| 57 | 61 |
| 58 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); | 62 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); |
| 59 }; | 63 }; |
| 60 | 64 |
| 65 class PushMessagingGetChannelIdFunction |
| 66 : public AsyncExtensionFunction, public ObfuscatedGaiaIdFetcher::Delegate { |
| 67 public: |
| 68 PushMessagingGetChannelIdFunction(); |
| 69 |
| 70 protected: |
| 71 virtual ~PushMessagingGetChannelIdFunction(); |
| 72 |
| 73 // ExtensionFunction: |
| 74 virtual bool RunImpl() OVERRIDE; |
| 75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.pushMessaging.getChannelId"); |
| 76 |
| 77 private: |
| 78 void ReportResult(const std::string& gaia_id, |
| 79 const std::string& error_message); |
| 80 |
| 81 // ObfuscatedGiaiaIdFetcher::Delegate implementation. |
| 82 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) |
| 83 OVERRIDE; |
| 84 virtual void OnObfuscatedGaiaIdFetchFailure( |
| 85 const GoogleServiceAuthError& error) OVERRIDE; |
| 86 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); |
| 89 }; |
| 90 |
| 61 } // namespace extension | 91 } // namespace extension |
| 62 | 92 |
| 63 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 93 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| OLD | NEW |