| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/gcd_private/gcd_private_api.h" | 5 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 callback.Run(success); | 345 callback.Run(success); |
| 346 } | 346 } |
| 347 | 347 |
| 348 void GcdPrivateAPI::StartWifiIfNotStarted() { | 348 void GcdPrivateAPI::StartWifiIfNotStarted() { |
| 349 if (!wifi_manager_) { | 349 if (!wifi_manager_) { |
| 350 wifi_manager_ = local_discovery::wifi::WifiManager::Create(); | 350 wifi_manager_ = local_discovery::wifi::WifiManager::Create(); |
| 351 wifi_manager_->Start(); | 351 wifi_manager_->Start(); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | |
| 355 #endif | 354 #endif |
| 356 | 355 |
| 357 void GcdPrivateAPI::RemoveSession(int session_id) { | 356 void GcdPrivateAPI::RemoveSession(int session_id) { |
| 358 sessions_.erase(session_id); | 357 sessions_.erase(session_id); |
| 359 } | 358 } |
| 360 | 359 |
| 360 scoped_ptr<base::ListValue> GcdPrivateAPI::GetPrefetchedSSIDList() { |
| 361 scoped_ptr<base::ListValue> retval(new base::ListValue); |
| 362 |
| 363 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
| 364 for (PasswordMap::iterator i = wifi_passwords_.begin(); |
| 365 i != wifi_passwords_.end(); |
| 366 i++) { |
| 367 retval->AppendString(i->first); |
| 368 } |
| 369 #endif |
| 370 |
| 371 return retval.Pass(); |
| 372 } |
| 373 |
| 361 // static | 374 // static |
| 362 void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( | 375 void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( |
| 363 GCDApiFlowFactoryForTests* factory) { | 376 GCDApiFlowFactoryForTests* factory) { |
| 364 g_gcd_api_flow_factory = factory; | 377 g_gcd_api_flow_factory = factory; |
| 365 } | 378 } |
| 366 | 379 |
| 367 GcdPrivateRequest::GcdPrivateRequest( | 380 GcdPrivateRequest::GcdPrivateRequest( |
| 368 const std::string& api, | 381 const std::string& api, |
| 369 const base::DictionaryValue& input, | 382 const base::DictionaryValue& input, |
| 370 const GcdPrivateAPI::MessageResponseCallback& callback, | 383 const GcdPrivateAPI::MessageResponseCallback& callback, |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 } | 749 } |
| 737 | 750 |
| 738 GcdPrivateGetCommandDefinitionsFunction:: | 751 GcdPrivateGetCommandDefinitionsFunction:: |
| 739 GcdPrivateGetCommandDefinitionsFunction() { | 752 GcdPrivateGetCommandDefinitionsFunction() { |
| 740 } | 753 } |
| 741 | 754 |
| 742 GcdPrivateGetCommandDefinitionsFunction:: | 755 GcdPrivateGetCommandDefinitionsFunction:: |
| 743 ~GcdPrivateGetCommandDefinitionsFunction() { | 756 ~GcdPrivateGetCommandDefinitionsFunction() { |
| 744 } | 757 } |
| 745 | 758 |
| 759 GcdPrivateGetPrefetchedWifiNameListFunction:: |
| 760 GcdPrivateGetPrefetchedWifiNameListFunction() { |
| 761 } |
| 762 |
| 763 GcdPrivateGetPrefetchedWifiNameListFunction:: |
| 764 ~GcdPrivateGetPrefetchedWifiNameListFunction() { |
| 765 } |
| 766 |
| 767 bool GcdPrivateGetPrefetchedWifiNameListFunction::RunSync() { |
| 768 GcdPrivateAPI* gcd_api = |
| 769 BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
| 770 |
| 771 DCHECK(gcd_api); |
| 772 scoped_ptr<base::ListValue> ssid_list = gcd_api->GetPrefetchedSSIDList(); |
| 773 |
| 774 SetResult(ssid_list.release()); |
| 775 |
| 776 return true; |
| 777 } |
| 778 |
| 746 bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() { | 779 bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() { |
| 747 return false; | 780 return false; |
| 748 } | 781 } |
| 749 | 782 |
| 750 GcdPrivateInsertCommandFunction::GcdPrivateInsertCommandFunction() { | 783 GcdPrivateInsertCommandFunction::GcdPrivateInsertCommandFunction() { |
| 751 } | 784 } |
| 752 | 785 |
| 753 GcdPrivateInsertCommandFunction::~GcdPrivateInsertCommandFunction() { | 786 GcdPrivateInsertCommandFunction::~GcdPrivateInsertCommandFunction() { |
| 754 } | 787 } |
| 755 | 788 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 781 } | 814 } |
| 782 | 815 |
| 783 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { | 816 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { |
| 784 } | 817 } |
| 785 | 818 |
| 786 bool GcdPrivateGetCommandsListFunction::RunAsync() { | 819 bool GcdPrivateGetCommandsListFunction::RunAsync() { |
| 787 return false; | 820 return false; |
| 788 } | 821 } |
| 789 | 822 |
| 790 } // namespace extensions | 823 } // namespace extensions |
| OLD | NEW |