Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2047833002: DevTools: introduce browser domain for basic target discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool wait) { 115 bool wait) {
116 in_dispatch_ = true; 116 in_dispatch_ = true;
117 base::DictionaryValue command; 117 base::DictionaryValue command;
118 command.SetInteger(kIdParam, ++last_sent_id_); 118 command.SetInteger(kIdParam, ++last_sent_id_);
119 command.SetString(kMethodParam, method); 119 command.SetString(kMethodParam, method);
120 if (params) 120 if (params)
121 command.Set(kParamsParam, params.release()); 121 command.Set(kParamsParam, params.release());
122 122
123 std::string json_command; 123 std::string json_command;
124 base::JSONWriter::Write(command, &json_command); 124 base::JSONWriter::Write(command, &json_command);
125 agent_host_->DispatchProtocolMessage(json_command); 125 agent_host_->DispatchProtocolMessage(this, json_command);
126 // Some messages are dispatched synchronously. 126 // Some messages are dispatched synchronously.
127 // Only run loop if we are not finished yet. 127 // Only run loop if we are not finished yet.
128 if (in_dispatch_ && wait) { 128 if (in_dispatch_ && wait) {
129 waiting_for_command_result_id_ = last_sent_id_; 129 waiting_for_command_result_id_ = last_sent_id_;
130 base::MessageLoop::current()->Run(); 130 base::MessageLoop::current()->Run();
131 } 131 }
132 in_dispatch_ = false; 132 in_dispatch_ = false;
133 } 133 }
134 134
135 bool HasValue(const std::string& path) { 135 bool HasValue(const std::string& path) {
(...skipping 21 matching lines...) Expand all
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
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
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/browser_handler.cc ('k') | content/browser/devtools/protocol/service_worker_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698