| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/test/test_api.h" | 5 #include "extensions/browser/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/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 11 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 13 #include "extensions/browser/extension_function_dispatcher.h" | 14 #include "extensions/browser/extension_function_dispatcher.h" |
| 14 #include "extensions/browser/extension_system.h" | 15 #include "extensions/browser/extension_system.h" |
| 15 #include "extensions/browser/notification_types.h" | 16 #include "extensions/browser/notification_types.h" |
| 16 #include "extensions/common/api/test.h" | 17 #include "extensions/common/api/test.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 content::NotificationService::current()->Notify( | 85 content::NotificationService::current()->Notify( |
| 85 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 86 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
| 86 content::Source<TestSendMessageFunction>(this), | 87 content::Source<TestSendMessageFunction>(this), |
| 87 content::Details<std::string>(¶ms->message)); | 88 content::Details<std::string>(¶ms->message)); |
| 88 return true; | 89 return true; |
| 89 } | 90 } |
| 90 | 91 |
| 91 TestSendMessageFunction::~TestSendMessageFunction() {} | 92 TestSendMessageFunction::~TestSendMessageFunction() {} |
| 92 | 93 |
| 93 void TestSendMessageFunction::Reply(const std::string& message) { | 94 void TestSendMessageFunction::Reply(const std::string& message) { |
| 94 SetResult(new base::StringValue(message)); | 95 SetResult(base::MakeUnique<base::StringValue>(message)); |
| 95 SendResponse(true); | 96 SendResponse(true); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void TestSendMessageFunction::ReplyWithError(const std::string& error) { | 99 void TestSendMessageFunction::ReplyWithError(const std::string& error) { |
| 99 error_ = error; | 100 error_ = error; |
| 100 SendResponse(false); | 101 SendResponse(false); |
| 101 } | 102 } |
| 102 | 103 |
| 103 // static | 104 // static |
| 104 void TestGetConfigFunction::set_test_config_state( | 105 void TestGetConfigFunction::set_test_config_state( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 TestGetConfigFunction::~TestGetConfigFunction() {} | 120 TestGetConfigFunction::~TestGetConfigFunction() {} |
| 120 | 121 |
| 121 bool TestGetConfigFunction::RunSafe() { | 122 bool TestGetConfigFunction::RunSafe() { |
| 122 TestConfigState* test_config_state = TestConfigState::GetInstance(); | 123 TestConfigState* test_config_state = TestConfigState::GetInstance(); |
| 123 | 124 |
| 124 if (!test_config_state->config_state()) { | 125 if (!test_config_state->config_state()) { |
| 125 error_ = kNoTestConfigDataError; | 126 error_ = kNoTestConfigDataError; |
| 126 return false; | 127 return false; |
| 127 } | 128 } |
| 128 | 129 |
| 129 SetResult(test_config_state->config_state()->DeepCopy()); | 130 SetResult(test_config_state->config_state()->CreateDeepCopy()); |
| 130 return true; | 131 return true; |
| 131 } | 132 } |
| 132 | 133 |
| 133 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} | 134 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} |
| 134 | 135 |
| 135 bool TestWaitForRoundTripFunction::RunSafe() { | 136 bool TestWaitForRoundTripFunction::RunSafe() { |
| 136 std::unique_ptr<WaitForRoundTrip::Params> params( | 137 std::unique_ptr<WaitForRoundTrip::Params> params( |
| 137 WaitForRoundTrip::Params::Create(*args_)); | 138 WaitForRoundTrip::Params::Create(*args_)); |
| 138 SetResult(new base::StringValue(params->message)); | 139 SetResult(base::MakeUnique<base::StringValue>(params->message)); |
| 139 return true; | 140 return true; |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace extensions | 143 } // namespace extensions |
| OLD | NEW |