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

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

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: rebased, and fixed small nit 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.cc
diff --git a/chrome/browser/extensions/app_notify_channel_setup.cc b/chrome/browser/extensions/app_notify_channel_setup.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8bbe51fb60de53989d7fc3e3695bee341f81af2d
--- /dev/null
+++ b/chrome/browser/extensions/app_notify_channel_setup.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/app_notify_channel_setup.h"
+
+#include "content/browser/browser_thread.h"
+
+AppNotifyChannelSetup::AppNotifyChannelSetup(
+ int request_id,
+ const std::string& client_id,
+ const GURL& requestor_url,
+ base::WeakPtr<AppNotifyChannelSetup::Delegate> delegate)
+ : request_id_(request_id),
+ client_id_(client_id),
+ requestor_url_(requestor_url),
+ delegate_(delegate) {}
+
+AppNotifyChannelSetup::~AppNotifyChannelSetup() {}
+
+void AppNotifyChannelSetup::Start() {
+ AddRef(); // Balanced in ReportResult.
+
+
+ // TODO(asargent) - We will eventually check here whether the user is logged
+ // in to the browser or not. If they are, we'll make a request to a server
+ // with the browser login credentials to get a channel id for the app to use
+ // in server pushed notifications. If they are not logged in, we'll prompt
+ // for login and if they sign in, then continue as in the first case.
+ // Otherwise we'll return an error message.
+
+ // For now, just reply with an error of 'not_implemented'.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ NewRunnableMethod(this,
+ &AppNotifyChannelSetup::ReportResult,
+ std::string(),
+ std::string("not_implemented")));
+}
+
+void AppNotifyChannelSetup::ReportResult(
+ const std::string& channel_id,
+ const std::string& error) {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (delegate_.get())
+ delegate_->AppNotifyChannelSetupComplete(request_id_, channel_id, error);
+ Release(); // Matches AddRef in Start.
+}
« no previous file with comments | « chrome/browser/extensions/app_notify_channel_setup.h ('k') | chrome/browser/extensions/app_notify_channel_setup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698