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

Side by Side Diff: extensions/browser/api/networking_config/networking_config_api.cc

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 5 #include <string>
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "extensions/browser/api/networking_config/networking_config_api.h" 9 #include "extensions/browser/api/networking_config/networking_config_api.h"
10 #include "extensions/browser/api/networking_config/networking_config_service.h" 10 #include "extensions/browser/api/networking_config/networking_config_service.h"
(...skipping 14 matching lines...) Expand all
25 25
26 } // namespace 26 } // namespace
27 27
28 NetworkingConfigSetNetworkFilterFunction:: 28 NetworkingConfigSetNetworkFilterFunction::
29 NetworkingConfigSetNetworkFilterFunction() { 29 NetworkingConfigSetNetworkFilterFunction() {
30 } 30 }
31 31
32 ExtensionFunction::ResponseAction 32 ExtensionFunction::ResponseAction
33 NetworkingConfigSetNetworkFilterFunction::Run() { 33 NetworkingConfigSetNetworkFilterFunction::Run() {
34 parameters_ = 34 parameters_ =
35 core_api::networking_config::SetNetworkFilter::Params::Create(*args_); 35 api::networking_config::SetNetworkFilter::Params::Create(*args_);
36 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); 36 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
37 37
38 NetworkingConfigService* service = 38 NetworkingConfigService* service =
39 NetworkingConfigServiceFactory::GetForBrowserContext(browser_context()); 39 NetworkingConfigServiceFactory::GetForBrowserContext(browser_context());
40 DCHECK(service); 40 DCHECK(service);
41 41
42 // Remove previously registered networks. 42 // Remove previously registered networks.
43 service->UnregisterExtension(extension_id()); 43 service->UnregisterExtension(extension_id());
44 44
45 for (linked_ptr<core_api::networking_config::NetworkInfo>& ni : 45 for (linked_ptr<api::networking_config::NetworkInfo>& ni :
46 parameters_->networks) { 46 parameters_->networks) {
47 // |Type| field must be set to |WiFi| 47 // |Type| field must be set to |WiFi|
48 if (ni->type != core_api::networking_config::NETWORK_TYPE_WIFI) 48 if (ni->type != api::networking_config::NETWORK_TYPE_WIFI)
49 return RespondNow(Error(kUnsupportedNetworkType)); 49 return RespondNow(Error(kUnsupportedNetworkType));
50 50
51 // Either |ssid| or |hex_ssid| must be set. 51 // Either |ssid| or |hex_ssid| must be set.
52 if (!ni->ssid.get() && !ni->hex_ssid.get()) 52 if (!ni->ssid.get() && !ni->hex_ssid.get())
53 return RespondNow(Error(kMalformedFilterDescription)); 53 return RespondNow(Error(kMalformedFilterDescription));
54 54
55 std::string hex_ssid; 55 std::string hex_ssid;
56 if (ni->ssid.get()) { 56 if (ni->ssid.get()) {
57 auto ssid_field = ni->ssid.get(); 57 auto ssid_field = ni->ssid.get();
58 hex_ssid = base::HexEncode(ssid_field->c_str(), ssid_field->size()); 58 hex_ssid = base::HexEncode(ssid_field->c_str(), ssid_field->size());
(...skipping 12 matching lines...) Expand all
71 ~NetworkingConfigSetNetworkFilterFunction() { 71 ~NetworkingConfigSetNetworkFilterFunction() {
72 } 72 }
73 73
74 NetworkingConfigFinishAuthenticationFunction:: 74 NetworkingConfigFinishAuthenticationFunction::
75 NetworkingConfigFinishAuthenticationFunction() { 75 NetworkingConfigFinishAuthenticationFunction() {
76 } 76 }
77 77
78 ExtensionFunction::ResponseAction 78 ExtensionFunction::ResponseAction
79 NetworkingConfigFinishAuthenticationFunction::Run() { 79 NetworkingConfigFinishAuthenticationFunction::Run() {
80 parameters_ = 80 parameters_ =
81 core_api::networking_config::FinishAuthentication::Params::Create(*args_); 81 api::networking_config::FinishAuthentication::Params::Create(*args_);
82 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); 82 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
83 83
84 NetworkingConfigService* service = 84 NetworkingConfigService* service =
85 NetworkingConfigServiceFactory::GetForBrowserContext(browser_context()); 85 NetworkingConfigServiceFactory::GetForBrowserContext(browser_context());
86 DCHECK(service); 86 DCHECK(service);
87 87
88 const NetworkingConfigService::AuthenticationResult& last_result = 88 const NetworkingConfigService::AuthenticationResult& last_result =
89 service->GetAuthenticationResult(); 89 service->GetAuthenticationResult();
90 if (last_result.authentication_state != NetworkingConfigService::NOTRY || 90 if (last_result.authentication_state != NetworkingConfigService::NOTRY ||
91 last_result.guid != parameters_->guid) { 91 last_result.guid != parameters_->guid) {
92 return RespondNow(Error(kAuthenticationResultFailed)); 92 return RespondNow(Error(kAuthenticationResultFailed));
93 } 93 }
94 94
95 // Populate NetworkingCaptivePortalAPI::AuthenticationResult. 95 // Populate NetworkingCaptivePortalAPI::AuthenticationResult.
96 NetworkingConfigService::AuthenticationResult authentication_result = { 96 NetworkingConfigService::AuthenticationResult authentication_result = {
97 extension_id(), parameters_->guid, NetworkingConfigService::FAILED, 97 extension_id(), parameters_->guid, NetworkingConfigService::FAILED,
98 }; 98 };
99 switch (parameters_->result) { 99 switch (parameters_->result) {
100 case core_api::networking_config::AUTHENTICATION_RESULT_NONE: 100 case api::networking_config::AUTHENTICATION_RESULT_NONE:
101 NOTREACHED(); 101 NOTREACHED();
102 break; 102 break;
103 case core_api::networking_config::AUTHENTICATION_RESULT_UNHANDLED: 103 case api::networking_config::AUTHENTICATION_RESULT_UNHANDLED:
104 authentication_result.authentication_state = 104 authentication_result.authentication_state =
105 NetworkingConfigService::FAILED; 105 NetworkingConfigService::FAILED;
106 break; 106 break;
107 case core_api::networking_config::AUTHENTICATION_RESULT_REJECTED: 107 case api::networking_config::AUTHENTICATION_RESULT_REJECTED:
108 authentication_result.authentication_state = 108 authentication_result.authentication_state =
109 NetworkingConfigService::REJECTED; 109 NetworkingConfigService::REJECTED;
110 break; 110 break;
111 case core_api::networking_config::AUTHENTICATION_RESULT_FAILED: 111 case api::networking_config::AUTHENTICATION_RESULT_FAILED:
112 authentication_result.authentication_state = 112 authentication_result.authentication_state =
113 NetworkingConfigService::FAILED; 113 NetworkingConfigService::FAILED;
114 break; 114 break;
115 case core_api::networking_config::AUTHENTICATION_RESULT_SUCCEEDED: 115 case api::networking_config::AUTHENTICATION_RESULT_SUCCEEDED:
116 authentication_result.authentication_state = 116 authentication_result.authentication_state =
117 NetworkingConfigService::SUCCESS; 117 NetworkingConfigService::SUCCESS;
118 break; 118 break;
119 } 119 }
120 service->SetAuthenticationResult(authentication_result); 120 service->SetAuthenticationResult(authentication_result);
121 return RespondNow(NoArguments()); 121 return RespondNow(NoArguments());
122 } 122 }
123 123
124 NetworkingConfigFinishAuthenticationFunction:: 124 NetworkingConfigFinishAuthenticationFunction::
125 ~NetworkingConfigFinishAuthenticationFunction() { 125 ~NetworkingConfigFinishAuthenticationFunction() {
126 } 126 }
127 127
128 } // namespace extensions 128 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698