| 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 |
| 54 // If successful, |channel_id| will be non-empty. On failure, |channel_id| | 56 // If successful, |channel_id| will be non-empty. On failure, |channel_id| |
| 55 // will be empty and |error| will contain an error to report to the JS | 57 // will be empty and |error| will contain an error to report to the JS |
| 56 // callback. | 58 // callback. |
| 57 virtual void AppNotifyChannelSetupComplete( | 59 virtual void AppNotifyChannelSetupComplete( |
| 58 const std::string& channel_id, | 60 const std::string& channel_id, |
| 59 const std::string& error, | 61 const std::string& error, |
| 60 const AppNotifyChannelSetup* setup) = 0; | 62 const AppNotifyChannelSetup* setup) = 0; |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 // For tests, we allow intercepting the request to setup the channel and | 65 // For tests, we allow intercepting the request to setup the channel and |
| 64 // forcing the return of a certain result to the delegate. | 66 // forcing the return of a certain result to the delegate. |
| 65 class InterceptorForTests { | 67 class InterceptorForTests { |
| 66 public: | 68 public: |
| 69 virtual ~InterceptorForTests() { } |
| 70 |
| 67 virtual void DoIntercept( | 71 virtual void DoIntercept( |
| 68 const AppNotifyChannelSetup* setup, | 72 const AppNotifyChannelSetup* setup, |
| 69 std::string* result_channel_id, | 73 std::string* result_channel_id, |
| 70 AppNotifyChannelSetup::SetupError* result_error) = 0; | 74 AppNotifyChannelSetup::SetupError* result_error) = 0; |
| 71 }; | 75 }; |
| 72 static void SetInterceptorForTests(InterceptorForTests* interceptor); | 76 static void SetInterceptorForTests(InterceptorForTests* interceptor); |
| 73 | 77 |
| 74 // Ownership of |ui| is transferred to this object. | 78 // Ownership of |ui| is transferred to this object. |
| 75 AppNotifyChannelSetup(Profile* profile, | 79 AppNotifyChannelSetup(Profile* profile, |
| 76 const std::string& extension_id, | 80 const std::string& extension_id, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // infinite loop of trying to generate access token, if that fails, try | 175 // infinite loop of trying to generate access token, if that fails, try |
| 172 // to login the user and generate access token, etc. | 176 // to login the user and generate access token, etc. |
| 173 bool oauth2_access_token_failure_; | 177 bool oauth2_access_token_failure_; |
| 174 | 178 |
| 175 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); | 179 DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup); |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 } // namespace extensions | 182 } // namespace extensions |
| 179 | 183 |
| 180 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ | 184 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_ |
| OLD | NEW |