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

Side by Side Diff: extensions/browser/extension_function.cc

Issue 885443010: WebstorePrivate extension API cleanup, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@testext_permission_prompt
Patch Set: remove dispatcher dependency 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 | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extension_function.h" 5 #include "extensions/browser/extension_function.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "content/public/browser/notification_source.h" 10 #include "content/public/browser/notification_source.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 ~ArgumentListResponseValue() override {} 54 ~ArgumentListResponseValue() override {}
55 55
56 bool Apply() override { return true; } 56 bool Apply() override { return true; }
57 57
58 private: 58 private:
59 std::string function_name_; 59 std::string function_name_;
60 const char* title_; 60 const char* title_;
61 }; 61 };
62 62
63 class ErrorWithArgumentsResponseValue : public ArgumentListResponseValue {
64 public:
65 ErrorWithArgumentsResponseValue(const std::string& function_name,
66 const char* title,
67 ExtensionFunction* function,
68 scoped_ptr<base::ListValue> result,
69 const std::string& error)
70 : ArgumentListResponseValue(function_name,
71 title,
72 function,
73 result.Pass()) {
74 function->SetError(error);
75 }
76
77 ~ErrorWithArgumentsResponseValue() override {}
78
79 bool Apply() override { return false; }
80 };
81
63 class ErrorResponseValue : public ExtensionFunction::ResponseValueObject { 82 class ErrorResponseValue : public ExtensionFunction::ResponseValueObject {
64 public: 83 public:
65 ErrorResponseValue(ExtensionFunction* function, const std::string& error) { 84 ErrorResponseValue(ExtensionFunction* function, const std::string& error) {
66 // It would be nice to DCHECK(!error.empty()) but too many legacy extension 85 // It would be nice to DCHECK(!error.empty()) but too many legacy extension
67 // function implementations don't set error but signal failure. 86 // function implementations don't set error but signal failure.
68 function->SetError(error); 87 function->SetError(error);
69 } 88 }
70 89
71 ~ErrorResponseValue() override {} 90 ~ErrorResponseValue() override {}
72 91
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 343
325 ExtensionFunction::ResponseValue ExtensionFunction::Error( 344 ExtensionFunction::ResponseValue ExtensionFunction::Error(
326 const std::string& format, 345 const std::string& format,
327 const std::string& s1, 346 const std::string& s1,
328 const std::string& s2, 347 const std::string& s2,
329 const std::string& s3) { 348 const std::string& s3) {
330 return ResponseValue(new ErrorResponseValue( 349 return ResponseValue(new ErrorResponseValue(
331 this, ErrorUtils::FormatErrorMessage(format, s1, s2, s3))); 350 this, ErrorUtils::FormatErrorMessage(format, s1, s2, s3)));
332 } 351 }
333 352
353 ExtensionFunction::ResponseValue ExtensionFunction::ErrorWithArguments(
354 scoped_ptr<base::ListValue> args,
355 const std::string& error) {
356 return ResponseValue(new ErrorWithArgumentsResponseValue(
357 name(), "ErrorWithArguments", this, args.Pass(), error));
358 }
359
334 ExtensionFunction::ResponseValue ExtensionFunction::BadMessage() { 360 ExtensionFunction::ResponseValue ExtensionFunction::BadMessage() {
335 return ResponseValue(new BadMessageResponseValue(this)); 361 return ResponseValue(new BadMessageResponseValue(this));
336 } 362 }
337 363
338 ExtensionFunction::ResponseAction ExtensionFunction::RespondNow( 364 ExtensionFunction::ResponseAction ExtensionFunction::RespondNow(
339 ResponseValue result) { 365 ResponseValue result) {
340 return ResponseAction(new RespondNowAction( 366 return ResponseAction(new RespondNowAction(
341 result.Pass(), base::Bind(&ExtensionFunction::SendResponse, this))); 367 result.Pass(), base::Bind(&ExtensionFunction::SendResponse, this)));
342 } 368 }
343 369
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 564
539 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { 565 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() {
540 return RespondNow(RunSync() ? ArgumentList(results_.Pass()) : Error(error_)); 566 return RespondNow(RunSync() ? ArgumentList(results_.Pass()) : Error(error_));
541 } 567 }
542 568
543 // static 569 // static
544 bool SyncIOThreadExtensionFunction::ValidationFailure( 570 bool SyncIOThreadExtensionFunction::ValidationFailure(
545 SyncIOThreadExtensionFunction* function) { 571 SyncIOThreadExtensionFunction* function) {
546 return false; 572 return false;
547 } 573 }
OLDNEW
« no previous file with comments | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698