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

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: 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.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..8614990df1a5ca8d4a9f69e2dd2d214ccc79031f
--- /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_)
Aaron Boodman 2011/10/06 20:29:28 You need to clear this when ExtensionTabHelper goe
asargent_no_longer_on_chrome 2011/10/06 22:37:38 delegate_ is a WeakPtr, so we get this for free. (
Aaron Boodman 2011/10/06 22:40:26 Oh, I missed that, OK. yeah, I do think it would b
+ delegate_->AppNotifyChannelSetupComplete(request_id_, channel_id, error);
+ Release(); // Matches AddRef in Start.
+}

Powered by Google App Engine
This is Rietveld 408576698