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

Side by Side Diff: extensions/browser/api/networking_private/networking_private_api.cc

Issue 2814023002: Don't show network config UI when networkingPrivate.startConenct fails (Closed)
Patch Set: . Created 3 years, 8 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 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 "extensions/browser/api/networking_private/networking_private_api.h" 5 #include "extensions/browser/api/networking_private/networking_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 ExtensionFunction::ResponseAction NetworkingPrivateStartConnectFunction::Run() { 580 ExtensionFunction::ResponseAction NetworkingPrivateStartConnectFunction::Run() {
581 std::unique_ptr<private_api::StartConnect::Params> params = 581 std::unique_ptr<private_api::StartConnect::Params> params =
582 private_api::StartConnect::Params::Create(*args_); 582 private_api::StartConnect::Params::Create(*args_);
583 EXTENSION_FUNCTION_VALIDATE(params); 583 EXTENSION_FUNCTION_VALIDATE(params);
584 584
585 GetDelegate(browser_context()) 585 GetDelegate(browser_context())
586 ->StartConnect( 586 ->StartConnect(
587 params->network_guid, 587 params->network_guid,
588 base::Bind(&NetworkingPrivateStartConnectFunction::Success, this), 588 base::Bind(&NetworkingPrivateStartConnectFunction::Success, this),
589 base::Bind(&NetworkingPrivateStartConnectFunction::Failure, this)); 589 base::Bind(&NetworkingPrivateStartConnectFunction::Failure, this,
590 params->network_guid));
590 // Success() or Failure() might have been called synchronously at this point. 591 // Success() or Failure() might have been called synchronously at this point.
591 // In that case this function has already called Respond(). Return 592 // In that case this function has already called Respond(). Return
592 // AlreadyResponded() in that case. 593 // AlreadyResponded() in that case.
593 return did_respond() ? AlreadyResponded() : RespondLater(); 594 return did_respond() ? AlreadyResponded() : RespondLater();
594 } 595 }
595 596
596 void NetworkingPrivateStartConnectFunction::Success() { 597 void NetworkingPrivateStartConnectFunction::Success() {
597 Respond(NoArguments()); 598 Respond(NoArguments());
598 } 599 }
599 600
600 void NetworkingPrivateStartConnectFunction::Failure(const std::string& error) { 601 void NetworkingPrivateStartConnectFunction::Failure(const std::string& guid,
602 const std::string& error) {
603 // TODO(stevenjb): Temporary workaround to show the configuration UI.
604 // Eventually the caller (e.g. Settings) should handle any failures and
605 // show its own configuration UI. crbug.com/380937.
606 if (source_context_type() == Feature::WEBUI_CONTEXT) {
stevenjb 2017/04/12 18:14:57 This seems fine, but I am unfamiliar with the code
tbarzic 2017/04/12 18:50:36 this checks whether startConnect function was call
607 const NetworkingPrivateDelegate::UIDelegate* ui_delegate =
608 GetDelegate(browser_context())->ui_delegate();
609 if (ui_delegate && ui_delegate->HandleConnectFailed(guid, error)) {
610 Success();
611 return;
612 }
613 }
stevenjb 2017/04/12 18:14:57 Did you verify that the dialog shows up on connect
tbarzic 2017/04/12 18:50:36 yes I have
601 Respond(Error(error)); 614 Respond(Error(error));
602 } 615 }
603 616
604 //////////////////////////////////////////////////////////////////////////////// 617 ////////////////////////////////////////////////////////////////////////////////
605 // NetworkingPrivateStartDisconnectFunction 618 // NetworkingPrivateStartDisconnectFunction
606 619
607 NetworkingPrivateStartDisconnectFunction:: 620 NetworkingPrivateStartDisconnectFunction::
608 ~NetworkingPrivateStartDisconnectFunction() { 621 ~NetworkingPrivateStartDisconnectFunction() {
609 } 622 }
610 623
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // private_api::GlobalPolicy is a subset of the global policy dictionary 1034 // private_api::GlobalPolicy is a subset of the global policy dictionary
1022 // (by definition), so use the api setter/getter to generate the subset. 1035 // (by definition), so use the api setter/getter to generate the subset.
1023 std::unique_ptr<private_api::GlobalPolicy> policy( 1036 std::unique_ptr<private_api::GlobalPolicy> policy(
1024 private_api::GlobalPolicy::FromValue(*policy_dict)); 1037 private_api::GlobalPolicy::FromValue(*policy_dict));
1025 DCHECK(policy); 1038 DCHECK(policy);
1026 return RespondNow( 1039 return RespondNow(
1027 ArgumentList(private_api::GetGlobalPolicy::Results::Create(*policy))); 1040 ArgumentList(private_api::GetGlobalPolicy::Results::Create(*policy)));
1028 } 1041 }
1029 1042
1030 } // namespace extensions 1043 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698