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

Side by Side Diff: extensions/browser/api/vpn_provider/vpn_provider_api.cc

Issue 1014053002: Provide warning message for setParameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Print only when there is a warning and fix unittest error Created 5 years, 9 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/vpn_provider/vpn_provider_api.h" 5 #include "extensions/browser/api/vpn_provider/vpn_provider_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 void VpnThreadExtensionFunction::SignalCallCompletionSuccess() { 149 void VpnThreadExtensionFunction::SignalCallCompletionSuccess() {
150 Respond(NoArguments()); 150 Respond(NoArguments());
151 } 151 }
152 152
153 void VpnThreadExtensionFunction::SignalCallCompletionSuccessWithId( 153 void VpnThreadExtensionFunction::SignalCallCompletionSuccessWithId(
154 const std::string& configuration_id) { 154 const std::string& configuration_id) {
155 Respond(OneArgument(new base::StringValue(configuration_id))); 155 Respond(OneArgument(new base::StringValue(configuration_id)));
156 } 156 }
157 157
158 void VpnThreadExtensionFunction::SignalCallCompletionSuccessWithWarning(
159 const std::string& warning) {
160 if (!warning.empty()) {
161 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, warning);
162 }
163 Respond(NoArguments());
164 }
165
158 void VpnThreadExtensionFunction::SignalCallCompletionFailure( 166 void VpnThreadExtensionFunction::SignalCallCompletionFailure(
159 const std::string& error_name, 167 const std::string& error_name,
160 const std::string& error_message) { 168 const std::string& error_message) {
161 if (!error_name.empty() && !error_message.empty()) { 169 if (!error_name.empty() && !error_message.empty()) {
162 Respond(Error(error_name + ": " + error_message)); 170 Respond(Error(error_name + ": " + error_message));
163 } else if (!error_name.empty()) { 171 } else if (!error_name.empty()) {
164 Respond(Error(error_name)); 172 Respond(Error(error_name));
165 } else { 173 } else {
166 Respond(Error(error_message)); 174 Respond(Error(error_message));
167 } 175 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 250
243 base::DictionaryValue parameter_value; 251 base::DictionaryValue parameter_value;
244 std::string error; 252 std::string error;
245 ConvertParameters(params->parameters, &parameter_value, &error); 253 ConvertParameters(params->parameters, &parameter_value, &error);
246 if (!error.empty()) { 254 if (!error.empty()) {
247 return RespondNow(Error(error)); 255 return RespondNow(Error(error));
248 } 256 }
249 257
250 service->SetParameters( 258 service->SetParameters(
251 extension_id(), parameter_value, 259 extension_id(), parameter_value,
252 base::Bind(&VpnProviderSetParametersFunction::SignalCallCompletionSuccess, 260 base::Bind(&VpnProviderSetParametersFunction::
261 SignalCallCompletionSuccessWithWarning,
253 this), 262 this),
254 base::Bind(&VpnProviderNotifyConnectionStateChangedFunction:: 263 base::Bind(&VpnProviderNotifyConnectionStateChangedFunction::
255 SignalCallCompletionFailure, 264 SignalCallCompletionFailure,
256 this)); 265 this));
257 266
258 return RespondLater(); 267 return RespondLater();
259 } 268 }
260 269
261 VpnProviderSendPacketFunction::~VpnProviderSendPacketFunction() { 270 VpnProviderSendPacketFunction::~VpnProviderSendPacketFunction() {
262 } 271 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 SignalCallCompletionSuccess, 318 SignalCallCompletionSuccess,
310 this), 319 this),
311 base::Bind(&VpnProviderNotifyConnectionStateChangedFunction:: 320 base::Bind(&VpnProviderNotifyConnectionStateChangedFunction::
312 SignalCallCompletionFailure, 321 SignalCallCompletionFailure,
313 this)); 322 this));
314 323
315 return RespondLater(); 324 return RespondLater();
316 } 325 }
317 326
318 } // namespace extensions 327 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698