OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "googleurl/src/gurl.h" |
| 11 |
| 12 // This class uses the browser login credentials to fetch a channel ID for an |
| 13 // app to use when sending server push notifications. |
| 14 class AppNotifyChannelSetup |
| 15 : public base::RefCountedThreadSafe<AppNotifyChannelSetup> { |
| 16 public: |
| 17 class Delegate { |
| 18 public: |
| 19 // If successful, |channel_id| will be non-empty. On failure, |channel_id| |
| 20 // will be empty and |error| will contain an error to report to the JS |
| 21 // callback. |
| 22 virtual void AppNotifyChannelSetupComplete(int request_id, |
| 23 const std::string& channel_id, |
| 24 const std::string& error) = 0; |
| 25 }; |
| 26 |
| 27 AppNotifyChannelSetup(int request_id, |
| 28 const std::string& client_id, |
| 29 const GURL& requestor_url, |
| 30 base::WeakPtr<Delegate> delegate); |
| 31 |
| 32 // This begins the process of fetching the channel id using the browser login |
| 33 // credentials. If the user isn't logged in to chrome, this will first cause a |
| 34 // prompt to appear asking the user to log in. |
| 35 void Start(); |
| 36 |
| 37 private: |
| 38 friend class base::RefCountedThreadSafe<AppNotifyChannelSetup>; |
| 39 |
| 40 virtual ~AppNotifyChannelSetup(); |
| 41 |
| 42 void ReportResult(const std::string& channel_id, const std::string& error); |
| 43 |
| 44 int request_id_; |
| 45 std::string client_id_; |
| 46 GURL requestor_url_; |
| 47 base::WeakPtr<Delegate> delegate_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); |
| 50 }; |
| 51 |
| 52 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ |
OLD | NEW |