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

Side by Side Diff: chrome/browser/devtools/devtools_targets_ui.cc

Issue 2014103002: Remove deprecated ListValue::Append(Value*) overload on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ADL fail Created 4 years, 3 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 "chrome/browser/devtools/devtools_targets_ui.h" 5 #include "chrome/browser/devtools/devtools_targets_ui.h"
6 6
7 #include <memory>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ptr_util.h"
10 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
11 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
15 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/values.h" 18 #include "base/values.h"
17 #include "base/version.h" 19 #include "base/version.h"
18 #include "chrome/browser/devtools/device/devtools_android_bridge.h" 20 #include "chrome/browser/devtools/device/devtools_android_bridge.h"
19 #include "content/public/browser/browser_child_process_observer.h" 21 #include "content/public/browser/browser_child_process_observer.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 233 }
232 234
233 void LocalTargetsUIHandler::SendTargets( 235 void LocalTargetsUIHandler::SendTargets(
234 const content::DevToolsAgentHost::List& targets) { 236 const content::DevToolsAgentHost::List& targets) {
235 base::ListValue list_value; 237 base::ListValue list_value;
236 std::map<std::string, base::DictionaryValue*> id_to_descriptor; 238 std::map<std::string, base::DictionaryValue*> id_to_descriptor;
237 239
238 targets_.clear(); 240 targets_.clear();
239 for (scoped_refptr<DevToolsAgentHost> host : targets) { 241 for (scoped_refptr<DevToolsAgentHost> host : targets) {
240 targets_[host->GetId()] = host; 242 targets_[host->GetId()] = host;
241 id_to_descriptor[host->GetId()] = Serialize(host); 243 id_to_descriptor[host->GetId()] = Serialize(host).release();
242 } 244 }
243 245
244 for (auto& it : targets_) { 246 for (auto& it : targets_) {
245 scoped_refptr<DevToolsAgentHost> host = it.second; 247 scoped_refptr<DevToolsAgentHost> host = it.second;
246 base::DictionaryValue* descriptor = id_to_descriptor[host->GetId()]; 248 base::DictionaryValue* descriptor = id_to_descriptor[host->GetId()];
249 DCHECK(descriptor);
247 std::string parent_id = host->GetParentId(); 250 std::string parent_id = host->GetParentId();
248 if (parent_id.empty() || id_to_descriptor.count(parent_id) == 0) { 251 if (parent_id.empty() || id_to_descriptor.count(parent_id) == 0) {
249 list_value.Append(descriptor); 252 list_value.Append(base::WrapUnique(descriptor));
250 } else { 253 } else {
251 base::DictionaryValue* parent = id_to_descriptor[parent_id]; 254 base::DictionaryValue* parent = id_to_descriptor[parent_id];
252 base::ListValue* guests = NULL; 255 base::ListValue* guests = NULL;
253 if (!parent->GetList(kGuestList, &guests)) { 256 if (!parent->GetList(kGuestList, &guests)) {
254 guests = new base::ListValue(); 257 guests = new base::ListValue();
255 parent->Set(kGuestList, guests); 258 parent->Set(kGuestList, guests);
256 } 259 }
257 guests->Append(descriptor); 260 guests->Append(base::WrapUnique(descriptor));
258 } 261 }
259 } 262 }
260 263
261 SendSerializedTargets(list_value); 264 SendSerializedTargets(list_value);
262 } 265 }
263 266
264 // AdbTargetsUIHandler -------------------------------------------------------- 267 // AdbTargetsUIHandler --------------------------------------------------------
265 268
266 class AdbTargetsUIHandler 269 class AdbTargetsUIHandler
267 : public DevToolsTargetsUIHandler, 270 : public DevToolsTargetsUIHandler,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 std::string browser_id = browser->GetId(); 365 std::string browser_id = browser->GetId();
363 browser_data->SetString(kTargetIdField, browser_id); 366 browser_data->SetString(kTargetIdField, browser_id);
364 browser_data->SetString(kTargetSourceField, source_id()); 367 browser_data->SetString(kTargetSourceField, source_id());
365 368
366 base::ListValue* page_list = new base::ListValue(); 369 base::ListValue* page_list = new base::ListValue();
367 remote_browsers_[browser_id] = browser; 370 remote_browsers_[browser_id] = browser;
368 browser_data->Set(kAdbPagesList, page_list); 371 browser_data->Set(kAdbPagesList, page_list);
369 for (const auto& page : browser->pages()) { 372 for (const auto& page : browser->pages()) {
370 scoped_refptr<DevToolsAgentHost> host = 373 scoped_refptr<DevToolsAgentHost> host =
371 android_bridge_->CreatePageTarget(page); 374 android_bridge_->CreatePageTarget(page);
372 base::DictionaryValue* target_data = Serialize(host); 375 std::unique_ptr<base::DictionaryValue> target_data = Serialize(host);
373 target_data->SetBoolean( 376 target_data->SetBoolean(
374 kAdbAttachedForeignField, 377 kAdbAttachedForeignField,
375 host->IsAttached() && 378 host->IsAttached() &&
376 !android_bridge_->HasDevToolsWindow(host->GetId())); 379 !android_bridge_->HasDevToolsWindow(host->GetId()));
377 // Pass the screen size in the target object to make sure that 380 // Pass the screen size in the target object to make sure that
378 // the caching logic does not prevent the target item from updating 381 // the caching logic does not prevent the target item from updating
379 // when the screen size changes. 382 // when the screen size changes.
380 gfx::Size screen_size = device->screen_size(); 383 gfx::Size screen_size = device->screen_size();
381 target_data->SetInteger(kAdbScreenWidthField, screen_size.width()); 384 target_data->SetInteger(kAdbScreenWidthField, screen_size.width());
382 target_data->SetInteger(kAdbScreenHeightField, screen_size.height()); 385 target_data->SetInteger(kAdbScreenHeightField, screen_size.height());
383 targets_[host->GetId()] = host; 386 targets_[host->GetId()] = host;
384 page_list->Append(target_data); 387 page_list->Append(std::move(target_data));
385 } 388 }
386 browser_list->Append(std::move(browser_data)); 389 browser_list->Append(std::move(browser_data));
387 } 390 }
388 391
389 device_list.Append(std::move(device_data)); 392 device_list.Append(std::move(device_data));
390 } 393 }
391 SendSerializedTargets(device_list); 394 SendSerializedTargets(device_list);
392 } 395 }
393 396
394 } // namespace 397 } // namespace
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 435
433 void DevToolsTargetsUIHandler::Open(const std::string& browser_id, 436 void DevToolsTargetsUIHandler::Open(const std::string& browser_id,
434 const std::string& url) { 437 const std::string& url) {
435 } 438 }
436 439
437 scoped_refptr<DevToolsAgentHost> 440 scoped_refptr<DevToolsAgentHost>
438 DevToolsTargetsUIHandler::GetBrowserAgentHost(const std::string& browser_id) { 441 DevToolsTargetsUIHandler::GetBrowserAgentHost(const std::string& browser_id) {
439 return NULL; 442 return NULL;
440 } 443 }
441 444
442 base::DictionaryValue* DevToolsTargetsUIHandler::Serialize( 445 std::unique_ptr<base::DictionaryValue> DevToolsTargetsUIHandler::Serialize(
443 scoped_refptr<DevToolsAgentHost> host) { 446 scoped_refptr<DevToolsAgentHost> host) {
444 base::DictionaryValue* target_data = new base::DictionaryValue(); 447 auto target_data = base::MakeUnique<base::DictionaryValue>();
445 target_data->SetString(kTargetSourceField, source_id_); 448 target_data->SetString(kTargetSourceField, source_id_);
446 target_data->SetString(kTargetIdField, host->GetId()); 449 target_data->SetString(kTargetIdField, host->GetId());
447 target_data->SetString(kTargetTypeField, host->GetType()); 450 target_data->SetString(kTargetTypeField, host->GetType());
448 target_data->SetBoolean(kAttachedField, host->IsAttached()); 451 target_data->SetBoolean(kAttachedField, host->IsAttached());
449 target_data->SetString(kUrlField, host->GetURL().spec()); 452 target_data->SetString(kUrlField, host->GetURL().spec());
450 target_data->SetString(kNameField, host->GetTitle()); 453 target_data->SetString(kNameField, host->GetTitle());
451 target_data->SetString(kFaviconUrlField, host->GetFaviconURL().spec()); 454 target_data->SetString(kFaviconUrlField, host->GetFaviconURL().spec());
452 target_data->SetString(kDescriptionField, host->GetDescription()); 455 target_data->SetString(kDescriptionField, host->GetDescription());
453 return target_data; 456 return target_data;
454 } 457 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 device_status_dict->SetString(kPortForwardingBrowserId, 500 device_status_dict->SetString(kPortForwardingBrowserId,
498 sit->first->GetId()); 501 sit->first->GetId());
499 502
500 std::string device_id = base::StringPrintf( 503 std::string device_id = base::StringPrintf(
501 kAdbDeviceIdFormat, 504 kAdbDeviceIdFormat,
502 sit->first->serial().c_str()); 505 sit->first->serial().c_str());
503 result.Set(device_id, device_status_dict); 506 result.Set(device_id, device_status_dict);
504 } 507 }
505 callback_.Run(result); 508 callback_.Run(result);
506 } 509 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_targets_ui.h ('k') | chrome/browser/devtools/devtools_ui_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698