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

Side by Side Diff: components/ui_devtools/devtools_server.cc

Issue 2894673005: Enable chrome devtools server to be accessible by DevTool clients within internal network. (Closed)
Patch Set: . Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ui_devtools/devtools_server.h" 5 #include "components/ui_devtools/devtools_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 devtools_server_ = nullptr; 67 devtools_server_ = nullptr;
68 } 68 }
69 69
70 // static 70 // static
71 std::unique_ptr<UiDevToolsServer> UiDevToolsServer::Create( 71 std::unique_ptr<UiDevToolsServer> UiDevToolsServer::Create(
72 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { 72 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) {
73 std::unique_ptr<UiDevToolsServer> server; 73 std::unique_ptr<UiDevToolsServer> server;
74 if (IsUiDevToolsEnabled() && !devtools_server_) { 74 if (IsUiDevToolsEnabled() && !devtools_server_) {
75 // TODO(mhashmi): Change port if more than one inspectable clients 75 // TODO(mhashmi): Change port if more than one inspectable clients
76 server.reset(new UiDevToolsServer(io_thread_task_runner)); 76 server.reset(new UiDevToolsServer(io_thread_task_runner));
77 server->Start("127.0.0.1", GetUiDevToolsPort()); 77 server->Start("0.0.0.0", GetUiDevToolsPort());
78 } 78 }
79 return server; 79 return server;
80 } 80 }
81 81
82 // static 82 // static
83 std::vector<UiDevToolsServer::NameUrlPair> 83 std::vector<UiDevToolsServer::NameUrlPair>
84 UiDevToolsServer::GetClientNamesAndUrls() { 84 UiDevToolsServer::GetClientNamesAndUrls() {
85 std::vector<NameUrlPair> pairs; 85 std::vector<NameUrlPair> pairs;
86 if (!devtools_server_) 86 if (!devtools_server_)
87 return pairs; 87 return pairs;
88 88
89 for (ClientsList::size_type i = 0; i != devtools_server_->clients_.size(); 89 for (ClientsList::size_type i = 0; i != devtools_server_->clients_.size();
90 i++) { 90 i++) {
91 pairs.push_back(std::pair<std::string, std::string>( 91 pairs.push_back(std::pair<std::string, std::string>(
92 devtools_server_->clients_[i]->name(), 92 devtools_server_->clients_[i]->name(),
93 base::StringPrintf("%slocalhost:%d/%" PRIuS, 93 base::StringPrintf("%s0.0.0.0:%d/%" PRIuS, kChromeDeveloperToolsPrefix,
94 kChromeDeveloperToolsPrefix, GetUiDevToolsPort(), 94 GetUiDevToolsPort(), i)));
95 i)));
96 } 95 }
97 return pairs; 96 return pairs;
98 } 97 }
99 98
100 void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) { 99 void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) {
101 clients_.push_back(std::move(client)); 100 clients_.push_back(std::move(client));
102 } 101 }
103 102
104 void UiDevToolsServer::SendOverWebSocket(int connection_id, 103 void UiDevToolsServer::SendOverWebSocket(int connection_id,
105 const String& message) { 104 const String& message) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 UiDevToolsClient* client = it->second; 175 UiDevToolsClient* client = it->second;
177 DCHECK(client); 176 DCHECK(client);
178 main_thread_task_runner_->PostTask( 177 main_thread_task_runner_->PostTask(
179 FROM_HERE, 178 FROM_HERE,
180 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client))); 179 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client)));
181 connections_.erase(it); 180 connections_.erase(it);
182 } 181 }
183 182
184 } // namespace devtools 183 } // namespace devtools
185 } // namespace ui 184 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698