| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return false; | 157 return false; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void Attach() { | 160 void Attach() { |
| 161 agent_host_ = DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 161 agent_host_ = DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
| 162 agent_host_->AttachClient(this); | 162 agent_host_->AttachClient(this); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void TearDownOnMainThread() override { | 165 void TearDownOnMainThread() override { |
| 166 if (agent_host_) { | 166 if (agent_host_) { |
| 167 agent_host_->DetachClient(); | 167 agent_host_->DetachClient(this); |
| 168 agent_host_ = nullptr; | 168 agent_host_ = nullptr; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 void WaitForNotification(const std::string& notification) { | 172 void WaitForNotification(const std::string& notification) { |
| 173 waiting_for_notification_ = notification; | 173 waiting_for_notification_ = notification; |
| 174 RunMessageLoop(); | 174 RunMessageLoop(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 std::unique_ptr<base::DictionaryValue> result_; | 177 std::unique_ptr<base::DictionaryValue> result_; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 shell()->web_contents()->SetDelegate(&dialog_manager); | 581 shell()->web_contents()->SetDelegate(&dialog_manager); |
| 582 SendCommand("Page.enable", nullptr, true); | 582 SendCommand("Page.enable", nullptr, true); |
| 583 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 583 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 584 params->SetString("expression", "alert('alert')"); | 584 params->SetString("expression", "alert('alert')"); |
| 585 SendCommand("Runtime.evaluate", std::move(params), false); | 585 SendCommand("Runtime.evaluate", std::move(params), false); |
| 586 WaitForNotification("Page.javascriptDialogOpening"); | 586 WaitForNotification("Page.javascriptDialogOpening"); |
| 587 dialog_manager.Handle(); | 587 dialog_manager.Handle(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 } // namespace content | 590 } // namespace content |
| OLD | NEW |