Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1293)

Unified Diff: chrome/browser/extensions/app_notify_channel_setup.h

Issue 8113006: Add js api for hosted/pacakged apps to request notification authorization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added process check, and moved to ExtensionTabHelper Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/app_notify_channel_setup.h
diff --git a/chrome/browser/extensions/app_notify_channel_setup.h b/chrome/browser/extensions/app_notify_channel_setup.h
new file mode 100644
index 0000000000000000000000000000000000000000..c44f8f11d4520b75998072aaf495613593a836e4
--- /dev/null
+++ b/chrome/browser/extensions/app_notify_channel_setup.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
Aaron Boodman 2011/10/06 20:29:28 Add a unit test for this class?
asargent_no_longer_on_chrome 2011/10/06 22:37:38 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
+#define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "googleurl/src/gurl.h"
+
+// This class uses the browser login credentials to fetch a channel ID for an
+// app to use when sending server push notifications.
+class AppNotifyChannelSetup
+ : public base::RefCountedThreadSafe<AppNotifyChannelSetup> {
+ public:
+ class Delegate {
+ public:
+ // If successful, |channel_id| will be non-empty. On failure, |channel_id|
+ // will be empty and |error| will contain an error to report to the JS
+ // callback.
+ virtual void AppNotifyChannelSetupComplete(int request_id,
+ const std::string& channel_id,
+ const std::string& error) = 0;
+ };
+
+ AppNotifyChannelSetup(int request_id,
+ const std::string& client_id,
+ const GURL& requestor_url,
+ base::WeakPtr<Delegate> delegate);
+
+ // This begins the process of fetching the channel id using the browser login
+ // credentials. If the user isn't logged in to chrome, this will first cause a
+ // prompt to appear asking the user to log in.
+ void Start();
+
+ private:
+ friend class base::RefCountedThreadSafe<AppNotifyChannelSetup>;
+
+ virtual ~AppNotifyChannelSetup();
+
+ void ReportResult(const std::string& channel_id, const std::string& error);
+
+ int request_id_;
+ std::string client_id_;
+ GURL requestor_url_;
+ base::WeakPtr<Delegate> delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_

Powered by Google App Engine
This is Rietveld 408576698