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

Side by Side Diff: chrome/browser/extensions/app_notify_channel_setup.h

Issue 8727024: Save the oauth client id used in App Notification setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 24 matching lines...) Expand all
35 : public content::URLFetcherDelegate, 35 : public content::URLFetcherDelegate,
36 public content::NotificationObserver, 36 public content::NotificationObserver,
37 public AppNotifyChannelUI::Delegate, 37 public AppNotifyChannelUI::Delegate,
38 public base::RefCountedThreadSafe<AppNotifyChannelSetup> { 38 public base::RefCountedThreadSafe<AppNotifyChannelSetup> {
39 public: 39 public:
40 class Delegate { 40 class Delegate {
41 public: 41 public:
42 // If successful, |channel_id| will be non-empty. On failure, |channel_id| 42 // If successful, |channel_id| will be non-empty. On failure, |channel_id|
43 // will be empty and |error| will contain an error to report to the JS 43 // will be empty and |error| will contain an error to report to the JS
44 // callback. 44 // callback.
45 virtual void AppNotifyChannelSetupComplete(const std::string& channel_id, 45 virtual void AppNotifyChannelSetupComplete(
46 const std::string& error, 46 const std::string& channel_id,
47 int return_route_id, 47 const std::string& error,
48 int callback_id) = 0; 48 const AppNotifyChannelSetup* setup) = 0;
49 }; 49 };
50 50
51 // For tests, we allow intercepting the request to setup the channel and
52 // forcing the return of a certain result to the delegate.
53 class InterceptorForTests {
54 public:
55 virtual void DoIntercept(const AppNotifyChannelSetup* setup,
56 std::string* result_channel_id,
57 std::string* result_error) = 0;
58 };
59 static void SetInterceptorForTests(InterceptorForTests* interceptor);
60
51 // Ownership of |ui| is transferred to this object. 61 // Ownership of |ui| is transferred to this object.
52 AppNotifyChannelSetup(Profile* profile, 62 AppNotifyChannelSetup(Profile* profile,
53 const std::string& extension_id, 63 const std::string& extension_id,
54 const std::string& client_id, 64 const std::string& client_id,
55 const GURL& requestor_url, 65 const GURL& requestor_url,
56 int return_route_id, 66 int return_route_id,
57 int callback_id, 67 int callback_id,
58 AppNotifyChannelUI* ui, 68 AppNotifyChannelUI* ui,
59 base::WeakPtr<Delegate> delegate); 69 base::WeakPtr<Delegate> delegate);
60 70
61 AppNotifyChannelUI* ui() { return ui_.get(); } 71 AppNotifyChannelUI* ui() { return ui_.get(); }
62 72
63 // This begins the process of fetching the channel id using the browser login 73 // This begins the process of fetching the channel id using the browser login
64 // credentials (or using |ui_| to prompt for login if needed). 74 // credentials (or using |ui_| to prompt for login if needed).
65 void Start(); 75 void Start();
66 76
67 // Implementing content::NotificationObserver interface. 77 // Implementing content::NotificationObserver interface.
68 virtual void Observe(int type, 78 virtual void Observe(int type,
69 const content::NotificationSource& source, 79 const content::NotificationSource& source,
70 const content::NotificationDetails& details) OVERRIDE; 80 const content::NotificationDetails& details) OVERRIDE;
81
82 // Getters for various members.
83 const std::string& extension_id() const { return extension_id_; }
84 const std::string& client_id() const { return client_id_; }
85 int return_route_id() const { return return_route_id_; }
86 int callback_id() const { return callback_id_; }
87
71 protected: 88 protected:
72 // content::URLFetcherDelegate. 89 // content::URLFetcherDelegate.
73 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 90 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
74 91
75 // AppNotifyChannelUI::Delegate. 92 // AppNotifyChannelUI::Delegate.
76 virtual void OnSyncSetupResult(bool enabled) OVERRIDE; 93 virtual void OnSyncSetupResult(bool enabled) OVERRIDE;
77 94
78 private: 95 private:
79 enum State { 96 enum State {
80 INITIAL, 97 INITIAL,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 scoped_ptr<content::URLFetcher> url_fetcher_; 155 scoped_ptr<content::URLFetcher> url_fetcher_;
139 scoped_ptr<AppNotifyChannelUI> ui_; 156 scoped_ptr<AppNotifyChannelUI> ui_;
140 State state_; 157 State state_;
141 int fetch_token_success_count_; 158 int fetch_token_success_count_;
142 int fetch_token_fail_count_; 159 int fetch_token_fail_count_;
143 160
144 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); 161 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup);
145 }; 162 };
146 163
147 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ 164 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification_browsertest.cc ('k') | chrome/browser/extensions/app_notify_channel_setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698