OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 AUTH_ERROR, | 44 AUTH_ERROR, |
45 INTERNAL_ERROR, | 45 INTERNAL_ERROR, |
46 USER_CANCELLED, | 46 USER_CANCELLED, |
47 | 47 |
48 // This is used for histograms, and should always be the last value. | 48 // This is used for histograms, and should always be the last value. |
49 SETUP_ERROR_BOUNDARY | 49 SETUP_ERROR_BOUNDARY |
50 }; | 50 }; |
51 | 51 |
52 class Delegate { | 52 class Delegate { |
53 public: | 53 public: |
54 virtual ~Delegate() { } | |
55 | |
56 // If successful, |channel_id| will be non-empty. On failure, |channel_id| | 54 // If successful, |channel_id| will be non-empty. On failure, |channel_id| |
57 // will be empty and |error| will contain an error to report to the JS | 55 // will be empty and |error| will contain an error to report to the JS |
58 // callback. | 56 // callback. |
59 virtual void AppNotifyChannelSetupComplete( | 57 virtual void AppNotifyChannelSetupComplete( |
60 const std::string& channel_id, | 58 const std::string& channel_id, |
61 const std::string& error, | 59 const std::string& error, |
62 const AppNotifyChannelSetup* setup) = 0; | 60 const AppNotifyChannelSetup* setup) = 0; |
63 }; | 61 }; |
64 | 62 |
65 // For tests, we allow intercepting the request to setup the channel and | 63 // For tests, we allow intercepting the request to setup the channel and |
66 // forcing the return of a certain result to the delegate. | 64 // forcing the return of a certain result to the delegate. |
67 class InterceptorForTests { | 65 class InterceptorForTests { |
68 public: | 66 public: |
69 virtual ~InterceptorForTests() { } | |
70 | |
71 virtual void DoIntercept( | 67 virtual void DoIntercept( |
72 const AppNotifyChannelSetup* setup, | 68 const AppNotifyChannelSetup* setup, |
73 std::string* result_channel_id, | 69 std::string* result_channel_id, |
74 AppNotifyChannelSetup::SetupError* result_error) = 0; | 70 AppNotifyChannelSetup::SetupError* result_error) = 0; |
75 }; | 71 }; |
76 static void SetInterceptorForTests(InterceptorForTests* interceptor); | 72 static void SetInterceptorForTests(InterceptorForTests* interceptor); |
77 | 73 |
78 // Ownership of |ui| is transferred to this object. | 74 // Ownership of |ui| is transferred to this object. |
79 AppNotifyChannelSetup(Profile* profile, | 75 AppNotifyChannelSetup(Profile* profile, |
80 const std::string& extension_id, | 76 const std::string& extension_id, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // infinite loop of trying to generate access token, if that fails, try | 171 // infinite loop of trying to generate access token, if that fails, try |
176 // to login the user and generate access token, etc. | 172 // to login the user and generate access token, etc. |
177 bool oauth2_access_token_failure_; | 173 bool oauth2_access_token_failure_; |
178 | 174 |
179 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); | 175 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); |
180 }; | 176 }; |
181 | 177 |
182 } // namespace extensions | 178 } // namespace extensions |
183 | 179 |
184 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ | 180 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ |
OLD | NEW |