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

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

Issue 2408133004: [DevTools] Implement Target.setDiscoverTargets method. (Closed)
Patch Set: new fancy range-based iteration in observer list! Created 4 years, 2 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 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 "content/browser/devtools/protocol/browser_handler.h" 5 #include "content/browser/devtools/protocol/browser_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "content/browser/devtools/devtools_manager.h" 10 #include "content/browser/devtools/devtools_manager.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // For layering reasons this needs to be handled by 44 // For layering reasons this needs to be handled by
45 // DevToolsManagerDelegate::HandleCommand. 45 // DevToolsManagerDelegate::HandleCommand.
46 return Response::ServerError("Not supported"); 46 return Response::ServerError("Not supported");
47 } 47 }
48 48
49 Response BrowserHandler::CreateTarget(const std::string& url, 49 Response BrowserHandler::CreateTarget(const std::string& url,
50 const int* width, 50 const int* width,
51 const int* height, 51 const int* height,
52 const std::string* context_id, 52 const std::string* context_id,
53 std::string* out_target_id) { 53 std::string* out_target_id) {
54 DevToolsManagerDelegate* delegate = 54 DevToolsManagerDelegate* manager_delegate =
55 DevToolsManager::GetInstance()->delegate(); 55 DevToolsManager::GetInstance()->GetDelegate();
56 if (!delegate) 56 if (!manager_delegate)
57 return Response::ServerError("Not supported"); 57 return Response::ServerError("Not supported");
58 scoped_refptr<content::DevToolsAgentHost> agent_host = 58 scoped_refptr<content::DevToolsAgentHost> agent_host =
59 delegate->CreateNewTarget(GURL(url)); 59 manager_delegate->CreateNewTarget(GURL(url));
60 if (!agent_host) 60 if (!agent_host)
61 return Response::ServerError("Not supported"); 61 return Response::ServerError("Not supported");
62 *out_target_id = agent_host->GetId(); 62 *out_target_id = agent_host->GetId();
63 return Response::OK(); 63 return Response::OK();
64 } 64 }
65 65
66 Response BrowserHandler::CloseTarget(const std::string& target_id, 66 Response BrowserHandler::CloseTarget(const std::string& target_id,
67 bool* out_success) { 67 bool* out_success) {
68 scoped_refptr<DevToolsAgentHost> agent_host = 68 scoped_refptr<DevToolsAgentHost> agent_host =
69 DevToolsAgentHost::GetForId(target_id); 69 DevToolsAgentHost::GetForId(target_id);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bool replaced_with_another_client) { 161 bool replaced_with_another_client) {
162 auto it = std::find( 162 auto it = std::find(
163 attached_hosts_.begin(), attached_hosts_.end(), agent_host); 163 attached_hosts_.begin(), attached_hosts_.end(), agent_host);
164 if (it != attached_hosts_.end()) 164 if (it != attached_hosts_.end())
165 attached_hosts_.erase(it); 165 attached_hosts_.erase(it);
166 } 166 }
167 167
168 } // namespace browser 168 } // namespace browser
169 } // namespace devtools 169 } // namespace devtools
170 } // namespace content 170 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698