Chromium Code Reviews| 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 #include "chrome/browser/extensions/app_notify_channel_setup.h" | |
| 6 | |
| 7 #include "content/browser/browser_thread.h" | |
| 8 | |
| 9 AppNotifyChannelSetup::AppNotifyChannelSetup( | |
| 10 int request_id, | |
| 11 const std::string& client_id, | |
| 12 const GURL& requestor_url, | |
| 13 base::WeakPtr<AppNotifyChannelSetup::Delegate> delegate) | |
| 14 : request_id_(request_id), | |
| 15 client_id_(client_id), | |
| 16 requestor_url_(requestor_url), | |
| 17 delegate_(delegate) {} | |
| 18 | |
| 19 AppNotifyChannelSetup::~AppNotifyChannelSetup() {} | |
| 20 | |
| 21 void AppNotifyChannelSetup::Start() { | |
| 22 AddRef(); // Balanced in ReportResult. | |
| 23 | |
| 24 | |
| 25 // TODO(asargent) - We will eventually check here whether the user is logged | |
| 26 // in to the browser or not. If they are, we'll make a request to a server | |
| 27 // with the browser login credentials to get a channel id for the app to use | |
| 28 // in server pushed notifications. If they are not logged in, we'll prompt | |
| 29 // for login and if they sign in, then continue as in the first case. | |
| 30 // Otherwise we'll return an error message. | |
| 31 | |
| 32 // For now, just reply with an error of 'not_implemented'. | |
| 33 BrowserThread::PostTask( | |
| 34 BrowserThread::UI, | |
| 35 FROM_HERE, | |
| 36 NewRunnableMethod(this, | |
| 37 &AppNotifyChannelSetup::ReportResult, | |
| 38 std::string(), | |
| 39 std::string("not_implemented"))); | |
| 40 } | |
| 41 | |
| 42 void AppNotifyChannelSetup::ReportResult( | |
| 43 const std::string& channel_id, | |
| 44 const std::string& error) { | |
| 45 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 46 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
| |
| 47 delegate_->AppNotifyChannelSetupComplete(request_id_, channel_id, error); | |
| 48 Release(); // Matches AddRef in Start. | |
| 49 } | |
| OLD | NEW |