| 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 #include "chrome/browser/extensions/api/test/test_api.h" | 5 #include "chrome/browser/extensions/api/test/test_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
| 14 #include "chrome/browser/extensions/extensions_quota_service.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/extensions/api/test.h" | 17 #include "chrome/common/extensions/api/test.h" |
| 19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "extensions/browser/quota_service.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // If you see this error in your test, you need to set the config state | 23 // If you see this error in your test, you need to set the config state |
| 24 // to be returned by chrome.test.getConfig(). Do this by calling | 24 // to be returned by chrome.test.getConfig(). Do this by calling |
| 25 // TestGetConfigFunction::set_test_config_state(Value* state) | 25 // TestGetConfigFunction::set_test_config_state(Value* state) |
| 26 // in test set up. | 26 // in test set up. |
| 27 const char kNoTestConfigDataError[] = "Test configuration was not set."; | 27 const char kNoTestConfigDataError[] = "Test configuration was not set."; |
| 28 | 28 |
| 29 const char kNotTestProcessError[] = | 29 const char kNotTestProcessError[] = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); | 77 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); |
| 78 EXTENSION_FUNCTION_VALIDATE(params.get()); | 78 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 79 VLOG(1) << params->message; | 79 VLOG(1) << params->message; |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 TestResetQuotaFunction::~TestResetQuotaFunction() {} | 83 TestResetQuotaFunction::~TestResetQuotaFunction() {} |
| 84 | 84 |
| 85 bool TestResetQuotaFunction::RunImpl() { | 85 bool TestResetQuotaFunction::RunImpl() { |
| 86 ExtensionService* service = GetProfile()->GetExtensionService(); | 86 ExtensionService* service = GetProfile()->GetExtensionService(); |
| 87 ExtensionsQuotaService* quota = service->quota_service(); | 87 QuotaService* quota = service->quota_service(); |
| 88 quota->Purge(); | 88 quota->Purge(); |
| 89 quota->violation_errors_.clear(); | 89 quota->violation_errors_.clear(); |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 | 92 |
| 93 TestCreateIncognitoTabFunction:: | 93 TestCreateIncognitoTabFunction:: |
| 94 ~TestCreateIncognitoTabFunction() {} | 94 ~TestCreateIncognitoTabFunction() {} |
| 95 | 95 |
| 96 bool TestCreateIncognitoTabFunction::RunImpl() { | 96 bool TestCreateIncognitoTabFunction::RunImpl() { |
| 97 scoped_ptr<CreateIncognitoTab::Params> params( | 97 scoped_ptr<CreateIncognitoTab::Params> params( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 if (!test_config_state->config_state()) { | 146 if (!test_config_state->config_state()) { |
| 147 error_ = kNoTestConfigDataError; | 147 error_ = kNoTestConfigDataError; |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 SetResult(test_config_state->config_state()->DeepCopy()); | 151 SetResult(test_config_state->config_state()->DeepCopy()); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace extensions | 155 } // namespace extensions |
| OLD | NEW |