| 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 "chrome/browser/devtools/port_forwarding_controller.h" | 5 #include "chrome/browser/devtools/port_forwarding_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 void PortForwardingController::Connection::OnPrefsChange() { | 352 void PortForwardingController::Connection::OnPrefsChange() { |
| 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 354 | 354 |
| 355 ForwardingMap new_forwarding_map; | 355 ForwardingMap new_forwarding_map; |
| 356 | 356 |
| 357 PrefService* pref_service = pref_change_registrar_.prefs(); | 357 PrefService* pref_service = pref_change_registrar_.prefs(); |
| 358 bool enabled = | 358 bool enabled = |
| 359 pref_service->GetBoolean(prefs::kDevToolsPortForwardingEnabled); | 359 pref_service->GetBoolean(prefs::kDevToolsPortForwardingEnabled); |
| 360 if (enabled) { | 360 if (enabled) { |
| 361 const DictionaryValue* dict = | 361 const base::DictionaryValue* dict = |
| 362 pref_service->GetDictionary(prefs::kDevToolsPortForwardingConfig); | 362 pref_service->GetDictionary(prefs::kDevToolsPortForwardingConfig); |
| 363 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 363 for (base::DictionaryValue::Iterator it(*dict); |
| 364 !it.IsAtEnd(); it.Advance()) { |
| 364 int port_num; | 365 int port_num; |
| 365 std::string location; | 366 std::string location; |
| 366 if (base::StringToInt(it.key(), &port_num) && | 367 if (base::StringToInt(it.key(), &port_num) && |
| 367 dict->GetString(it.key(), &location)) | 368 dict->GetString(it.key(), &location)) |
| 368 new_forwarding_map[port_num] = location; | 369 new_forwarding_map[port_num] = location; |
| 369 } | 370 } |
| 370 } | 371 } |
| 371 | 372 |
| 372 adb_thread_->message_loop()->PostTask( | 373 adb_thread_->message_loop()->PostTask( |
| 373 FROM_HERE, | 374 FROM_HERE, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 return true; | 535 return true; |
| 535 | 536 |
| 536 scoped_ptr<DevToolsProtocol::Notification> notification( | 537 scoped_ptr<DevToolsProtocol::Notification> notification( |
| 537 DevToolsProtocol::ParseNotification(message)); | 538 DevToolsProtocol::ParseNotification(message)); |
| 538 if (!notification) | 539 if (!notification) |
| 539 return false; | 540 return false; |
| 540 | 541 |
| 541 if (notification->method() != kTetheringAccepted) | 542 if (notification->method() != kTetheringAccepted) |
| 542 return false; | 543 return false; |
| 543 | 544 |
| 544 DictionaryValue* params = notification->params(); | 545 base::DictionaryValue* params = notification->params(); |
| 545 if (!params) | 546 if (!params) |
| 546 return false; | 547 return false; |
| 547 | 548 |
| 548 int port; | 549 int port; |
| 549 std::string connection_id; | 550 std::string connection_id; |
| 550 if (!params->GetInteger(kPortAttribute, &port) || | 551 if (!params->GetInteger(kPortAttribute, &port) || |
| 551 !params->GetString(kConnectionIdAttribute, &connection_id)) | 552 !params->GetString(kConnectionIdAttribute, &connection_id)) |
| 552 return false; | 553 return false; |
| 553 | 554 |
| 554 std::map<int, std::string>::iterator it = forwarding_map_.find(port); | 555 std::map<int, std::string>::iterator it = forwarding_map_.find(port); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 BrowserContextDependencyManager::GetInstance()) {} | 619 BrowserContextDependencyManager::GetInstance()) {} |
| 619 | 620 |
| 620 PortForwardingController::Factory::~Factory() {} | 621 PortForwardingController::Factory::~Factory() {} |
| 621 | 622 |
| 622 BrowserContextKeyedService* | 623 BrowserContextKeyedService* |
| 623 PortForwardingController::Factory::BuildServiceInstanceFor( | 624 PortForwardingController::Factory::BuildServiceInstanceFor( |
| 624 content::BrowserContext* context) const { | 625 content::BrowserContext* context) const { |
| 625 Profile* profile = Profile::FromBrowserContext(context); | 626 Profile* profile = Profile::FromBrowserContext(context); |
| 626 return new PortForwardingController(profile->GetPrefs()); | 627 return new PortForwardingController(profile->GetPrefs()); |
| 627 } | 628 } |
| OLD | NEW |