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 // TODO(yoz): privatize |
92 AutotestPrivateAPI(); | 93 AutotestPrivateAPI(); |
93 | 94 |
| 95 static ProfileKeyedAPIFactory<AutotestPrivateAPI>* GetFactoryInstance(); |
| 96 |
94 // TODO(achuith): Replace these with a mock object for system calls. | 97 // TODO(achuith): Replace these with a mock object for system calls. |
95 bool test_mode() const { return test_mode_; } | 98 bool test_mode() const { return test_mode_; } |
96 void set_test_mode(bool test_mode) { test_mode_ = test_mode; } | 99 void set_test_mode(bool test_mode) { test_mode_ = test_mode; } |
97 | 100 |
98 private: | 101 private: |
| 102 friend class ProfileKeyedAPIFactory<AutotestPrivateAPI>; |
| 103 |
99 virtual ~AutotestPrivateAPI(); | 104 virtual ~AutotestPrivateAPI(); |
100 | 105 |
| 106 // ProfileKeyedAPI implementation. |
| 107 static const char* service_name() { return "AutotestPrivateAPI"; } |
| 108 static const bool kServiceIsNULLWhileTesting = true; |
| 109 static const bool kServiceRedirectedInIncognito = true; |
| 110 |
101 bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test. | 111 bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test. |
102 }; | 112 }; |
103 | 113 |
| 114 template <> |
| 115 BrowserContextKeyedService* |
| 116 ProfileKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
| 117 content::BrowserContext* context) const; |
| 118 |
104 } // namespace extensions | 119 } // namespace extensions |
105 | 120 |
106 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H
_ | 121 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H
_ |
OLD | NEW |