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

Side by Side Diff: chrome/browser/extensions/api/gcd_private/gcd_private_api.cc

Issue 877613002: Added pairing with Spake SHA224 key exchange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@brillo1
Patch Set: Thu Jan 29 23:44:10 PST 2015 Created 5 years, 10 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 | chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/linked_ptr.h" 8 #include "base/memory/linked_ptr.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const base::DictionaryValue* input_actual = &input; 351 const base::DictionaryValue* input_actual = &input;
352 scoped_ptr<base::DictionaryValue> input_cloned; 352 scoped_ptr<base::DictionaryValue> input_cloned;
353 353
354 if (api == kPrivatAPISetup) { 354 if (api == kPrivatAPISetup) {
355 const base::DictionaryValue* wifi = NULL; 355 const base::DictionaryValue* wifi = NULL;
356 356
357 if (input.GetDictionary(kPrivetKeyWifi, &wifi)) { 357 if (input.GetDictionary(kPrivetKeyWifi, &wifi)) {
358 std::string ssid; 358 std::string ssid;
359 359
360 if (!wifi->GetString(kPrivetKeySSID, &ssid)) { 360 if (!wifi->GetString(kPrivetKeySSID, &ssid)) {
361 callback.Run(gcd_private::STATUS_SETUPPARSEERROR, 361 return callback.Run(gcd_private::STATUS_SETUPPARSEERROR,
362 base::DictionaryValue()); 362 base::DictionaryValue());
363 return;
364 } 363 }
365 364
366 if (!wifi->HasKey(kPrivetKeyPassphrase)) { 365 if (!wifi->HasKey(kPrivetKeyPassphrase)) {
367 // If the message is a setup message, has a wifi section, try sending 366 // If the message is a setup message, has a wifi section, try sending
368 // the passphrase. 367 // the passphrase.
369 368
370 PasswordMap::iterator found = wifi_passwords_.find(ssid); 369 PasswordMap::iterator found = wifi_passwords_.find(ssid);
371 if (found == wifi_passwords_.end()) { 370 if (found == wifi_passwords_.end()) {
372 callback.Run(gcd_private::STATUS_WIFIPASSWORDERROR, 371 return callback.Run(gcd_private::STATUS_WIFIPASSWORDERROR,
373 base::DictionaryValue()); 372 base::DictionaryValue());
374 return;
375 } 373 }
376 374
377 input_cloned.reset(input.DeepCopy()); 375 input_cloned.reset(input.DeepCopy());
378 input_cloned->SetString(kPrivetKeyPassphraseDotted, found->second); 376 input_cloned->SetString(kPrivetKeyPassphraseDotted, found->second);
379 input_actual = input_cloned.get(); 377 input_actual = input_cloned.get();
380 } 378 }
381 } 379 }
382 } 380 }
383 381
384 auto found = sessions_.find(session_id); 382 auto found = sessions_.find(session_id);
385 383
386 if (found == sessions_.end()) { 384 if (found == sessions_.end()) {
387 callback.Run(gcd_private::STATUS_UNKNOWNSESSIONERROR, 385 return callback.Run(gcd_private::STATUS_UNKNOWNSESSIONERROR,
388 base::DictionaryValue()); 386 base::DictionaryValue());
389 return;
390 } 387 }
391 388
392 found->second->SendMessage(api, *input_actual, callback); 389 found->second->SendMessage(api, *input_actual, callback);
393 } 390 }
394 391
395 void GcdPrivateAPIImpl::RequestWifiPassword(const std::string& ssid, 392 void GcdPrivateAPIImpl::RequestWifiPassword(const std::string& ssid,
396 const SuccessCallback& callback) { 393 const SuccessCallback& callback) {
397 #if defined(ENABLE_WIFI_BOOTSTRAPPING) 394 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
398 StartWifiIfNotStarted(); 395 StartWifiIfNotStarted();
399 wifi_manager_->RequestNetworkCredentials( 396 wifi_manager_->RequestNetworkCredentials(
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 798 }
802 799
803 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { 800 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() {
804 } 801 }
805 802
806 bool GcdPrivateGetCommandsListFunction::RunAsync() { 803 bool GcdPrivateGetCommandsListFunction::RunAsync() {
807 return false; 804 return false;
808 } 805 }
809 806
810 } // namespace extensions 807 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/gcd_private/gcd_private_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698