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_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 class AutotestPrivateLogoutFunction : public ChromeSyncExtensionFunction { | 16 class AutotestPrivateLogoutFunction : public ChromeSyncExtensionFunction { |
17 public: | 17 public: |
18 DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT) | 18 DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT) |
19 | 19 |
20 private: | 20 private: |
21 virtual ~AutotestPrivateLogoutFunction() {} | 21 virtual ~AutotestPrivateLogoutFunction() {} |
22 virtual bool RunImpl() OVERRIDE; | 22 virtual bool RunImpl() OVERRIDE; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 private: | 81 private: |
82 virtual ~AutotestPrivateSimulateAsanMemoryBugFunction() {} | 82 virtual ~AutotestPrivateSimulateAsanMemoryBugFunction() {} |
83 virtual bool RunImpl() OVERRIDE; | 83 virtual bool RunImpl() OVERRIDE; |
84 }; | 84 }; |
85 | 85 |
86 // Don't kill the browser when we're in a browser test. | 86 // Don't kill the browser when we're in a browser test. |
87 void SetAutotestPrivateTest(); | 87 void SetAutotestPrivateTest(); |
88 | 88 |
89 // The profile-keyed service that manages the autotestPrivate extension API. | 89 // The profile-keyed service that manages the autotestPrivate extension API. |
90 class AutotestPrivateAPI : public BrowserContextKeyedService { | 90 class AutotestPrivateAPI : public ProfileKeyedAPI { |
91 public: | 91 public: |
92 AutotestPrivateAPI(); | 92 static ProfileKeyedAPIFactory<AutotestPrivateAPI>* GetFactoryInstance(); |
93 | 93 |
94 // TODO(achuith): Replace these with a mock object for system calls. | 94 // TODO(achuith): Replace these with a mock object for system calls. |
95 bool test_mode() const { return test_mode_; } | 95 bool test_mode() const { return test_mode_; } |
96 void set_test_mode(bool test_mode) { test_mode_ = test_mode; } | 96 void set_test_mode(bool test_mode) { test_mode_ = test_mode; } |
97 | 97 |
98 private: | 98 private: |
| 99 friend class ProfileKeyedAPIFactory<AutotestPrivateAPI>; |
| 100 |
| 101 AutotestPrivateAPI(); |
99 virtual ~AutotestPrivateAPI(); | 102 virtual ~AutotestPrivateAPI(); |
100 | 103 |
| 104 // ProfileKeyedAPI implementation. |
| 105 static const char* service_name() { return "AutotestPrivateAPI"; } |
| 106 static const bool kServiceIsNULLWhileTesting = true; |
| 107 static const bool kServiceRedirectedInIncognito = true; |
| 108 |
101 bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test. | 109 bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test. |
102 }; | 110 }; |
103 | 111 |
| 112 template <> |
| 113 BrowserContextKeyedService* |
| 114 ProfileKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
| 115 content::BrowserContext* context) const; |
| 116 |
104 } // namespace extensions | 117 } // namespace extensions |
105 | 118 |
106 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H
_ | 119 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H
_ |
OLD | NEW |