| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/setup/me2me_native_messaging_host.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 namespace remoting { | 133 namespace remoting { |
| 134 | 134 |
| 135 class MockDaemonControllerDelegate : public DaemonController::Delegate { | 135 class MockDaemonControllerDelegate : public DaemonController::Delegate { |
| 136 public: | 136 public: |
| 137 MockDaemonControllerDelegate(); | 137 MockDaemonControllerDelegate(); |
| 138 ~MockDaemonControllerDelegate() override; | 138 ~MockDaemonControllerDelegate() override; |
| 139 | 139 |
| 140 // DaemonController::Delegate interface. | 140 // DaemonController::Delegate interface. |
| 141 DaemonController::State GetState() override; | 141 DaemonController::State GetState() override; |
| 142 scoped_ptr<base::DictionaryValue> GetConfig() override; | 142 scoped_ptr<base::DictionaryValue> GetConfig() override; |
| 143 void InstallHost(const DaemonController::CompletionCallback& done) override; | |
| 144 void SetConfigAndStart( | 143 void SetConfigAndStart( |
| 145 scoped_ptr<base::DictionaryValue> config, | 144 scoped_ptr<base::DictionaryValue> config, |
| 146 bool consent, | 145 bool consent, |
| 147 const DaemonController::CompletionCallback& done) override; | 146 const DaemonController::CompletionCallback& done) override; |
| 148 void UpdateConfig(scoped_ptr<base::DictionaryValue> config, | 147 void UpdateConfig(scoped_ptr<base::DictionaryValue> config, |
| 149 const DaemonController::CompletionCallback& done) override; | 148 const DaemonController::CompletionCallback& done) override; |
| 150 void Stop(const DaemonController::CompletionCallback& done) override; | 149 void Stop(const DaemonController::CompletionCallback& done) override; |
| 151 void SetWindow(void* window_handle) override; | 150 void SetWindow(void* window_handle) override; |
| 152 std::string GetVersion() override; | 151 std::string GetVersion() override; |
| 153 DaemonController::UsageStatsConsent GetUsageStatsConsent() override; | 152 DaemonController::UsageStatsConsent GetUsageStatsConsent() override; |
| 154 | 153 |
| 155 private: | 154 private: |
| 156 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); | 155 DISALLOW_COPY_AND_ASSIGN(MockDaemonControllerDelegate); |
| 157 }; | 156 }; |
| 158 | 157 |
| 159 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} | 158 MockDaemonControllerDelegate::MockDaemonControllerDelegate() {} |
| 160 | 159 |
| 161 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} | 160 MockDaemonControllerDelegate::~MockDaemonControllerDelegate() {} |
| 162 | 161 |
| 163 DaemonController::State MockDaemonControllerDelegate::GetState() { | 162 DaemonController::State MockDaemonControllerDelegate::GetState() { |
| 164 return DaemonController::STATE_STARTED; | 163 return DaemonController::STATE_STARTED; |
| 165 } | 164 } |
| 166 | 165 |
| 167 scoped_ptr<base::DictionaryValue> MockDaemonControllerDelegate::GetConfig() { | 166 scoped_ptr<base::DictionaryValue> MockDaemonControllerDelegate::GetConfig() { |
| 168 return make_scoped_ptr(new base::DictionaryValue()); | 167 return make_scoped_ptr(new base::DictionaryValue()); |
| 169 } | 168 } |
| 170 | 169 |
| 171 void MockDaemonControllerDelegate::InstallHost( | |
| 172 const DaemonController::CompletionCallback& done) { | |
| 173 done.Run(DaemonController::RESULT_OK); | |
| 174 } | |
| 175 | |
| 176 void MockDaemonControllerDelegate::SetConfigAndStart( | 170 void MockDaemonControllerDelegate::SetConfigAndStart( |
| 177 scoped_ptr<base::DictionaryValue> config, | 171 scoped_ptr<base::DictionaryValue> config, |
| 178 bool consent, | 172 bool consent, |
| 179 const DaemonController::CompletionCallback& done) { | 173 const DaemonController::CompletionCallback& done) { |
| 180 | 174 |
| 181 // Verify parameters passed in. | 175 // Verify parameters passed in. |
| 182 if (consent && config && config->HasKey("start")) { | 176 if (consent && config && config->HasKey("start")) { |
| 183 done.Run(DaemonController::RESULT_OK); | 177 done.Run(DaemonController::RESULT_OK); |
| 184 } else { | 178 } else { |
| 185 done.Run(DaemonController::RESULT_FAILED); | 179 done.Run(DaemonController::RESULT_FAILED); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 584 |
| 591 // Verify rejection if startDaemon request has no "consent" parameter. | 585 // Verify rejection if startDaemon request has no "consent" parameter. |
| 592 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { | 586 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { |
| 593 base::DictionaryValue message; | 587 base::DictionaryValue message; |
| 594 message.SetString("type", "startDaemon"); | 588 message.SetString("type", "startDaemon"); |
| 595 message.Set("config", base::DictionaryValue().DeepCopy()); | 589 message.Set("config", base::DictionaryValue().DeepCopy()); |
| 596 TestBadRequest(message); | 590 TestBadRequest(message); |
| 597 } | 591 } |
| 598 | 592 |
| 599 } // namespace remoting | 593 } // namespace remoting |
| OLD | NEW |