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

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

Issue 8526015: Integrate AppNotifyChannelSetup with TokenService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notify_channel_setup.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/app_notify_channel_setup.h
===================================================================
--- chrome/browser/extensions/app_notify_channel_setup.h (revision 108838)
+++ chrome/browser/extensions/app_notify_channel_setup.h (working copy)
@@ -9,6 +9,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/app_notify_channel_ui.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "content/public/common/url_fetcher.h"
#include "content/public/common/url_fetcher_delegate.h"
#include "googleurl/src/gurl.h"
@@ -16,6 +18,10 @@
class AppNotifyChannelSetupTest;
class Profile;
+namespace content {
+class NotificationDetails;
+}
+
// This class uses the browser login credentials to setup app notifications
// for a given app.
//
@@ -27,6 +33,7 @@
// the above steps.
class AppNotifyChannelSetup
: public content::URLFetcherDelegate,
+ public content::NotificationObserver,
public AppNotifyChannelUI::Delegate,
public base::RefCountedThreadSafe<AppNotifyChannelSetup> {
public:
@@ -51,10 +58,16 @@
AppNotifyChannelUI* ui,
base::WeakPtr<Delegate> delegate);
+ AppNotifyChannelUI* ui() { return ui_.get(); }
+
// This begins the process of fetching the channel id using the browser login
// credentials (or using |ui_| to prompt for login if needed).
void Start();
+ // Implementing content::NotificationObserver interface.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
protected:
// content::URLFetcherDelegate.
virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
@@ -67,6 +80,8 @@
INITIAL,
LOGIN_STARTED,
LOGIN_DONE,
+ FETCH_TOKEN_STARTED,
+ FETCH_TOKEN_DONE,
RECORD_GRANT_STARTED,
RECORD_GRANT_DONE,
CHANNEL_ID_SETUP_STARTED,
@@ -84,6 +99,10 @@
// Caller owns the returned instance.
content::URLFetcher* CreateURLFetcher(
const GURL& url, const std::string& body, const std::string& auth_token);
+ void BeginLogin();
+ void EndLogin(bool success);
+ void BeginFetchTokens();
+ void EndFetchTokens(bool success);
void BeginRecordGrant();
void EndRecordGrant(const content::URLFetcher* source);
void BeginGetChannelId();
@@ -100,8 +119,16 @@
std::string GetCWSAuthToken();
static bool ParseCWSChannelServiceResponse(
const std::string& data, std::string* result);
+ static bool IsGaiaServiceRelevant(const std::string& service);
+ // Checks if the user needs to be prompted for login.
+ bool ShouldPromptForLogin() const;
+ // Checks if we need to fetch auth tokens for services we care about.
+ virtual bool ShouldFetchServiceTokens() const;
+ void RegisterForTokenServiceNotifications();
+ void UnregisterForTokenServiceNotifications();
Profile* profile_;
+ content::NotificationRegistrar registrar_;
std::string extension_id_;
std::string client_id_;
GURL requestor_url_;
@@ -111,6 +138,8 @@
scoped_ptr<content::URLFetcher> url_fetcher_;
scoped_ptr<AppNotifyChannelUI> ui_;
State state_;
+ int fetch_token_success_count_;
+ int fetch_token_fail_count_;
DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup);
};
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notify_channel_setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698