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

Unified Diff: extensions/renderer/bindings/api_last_error.h

Issue 2953133002: [Extensions Bindings] Support chrome.extension.lastError (Closed)
Patch Set: jbroman's, lazyboy's Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/bindings/api_last_error.h
diff --git a/extensions/renderer/bindings/api_last_error.h b/extensions/renderer/bindings/api_last_error.h
index f07945878db2ab126c9ce01865991db6c38bc5d4..1082409ae38d4374b23a619ee7fc00bc7ed26c14 100644
--- a/extensions/renderer/bindings/api_last_error.h
+++ b/extensions/renderer/bindings/api_last_error.h
@@ -18,9 +18,14 @@ namespace extensions {
class APILastError {
public:
// Returns the object the 'lastError' property should be exposed on for the
- // given context.
- using GetParent =
- base::Callback<v8::Local<v8::Object>(v8::Local<v8::Context>)>;
+ // given context. Also allows for the population of a |secondary_parent|; if
+ // populated, this object will also have a lastError property, but it will be
+ // a simple object without getters/setters. This is to accommodate the
+ // legacy chrome.extension.lastError property.
+ // Note: |secondary_parent| may be null.
+ using GetParent = base::Callback<v8::Local<v8::Object>(
+ v8::Local<v8::Context>,
+ v8::Local<v8::Object>* secondary_parent)>;
// Adds an error message to the context's console.
using AddConsoleError =
base::Callback<void(v8::Local<v8::Context>, const std::string& error)>;
@@ -41,6 +46,18 @@ class APILastError {
bool HasError(v8::Local<v8::Context> context);
private:
+ // Sets the lastError property on the primary parent object (in practice, this
+ // is chrome.runtime.lastError);
+ void SetErrorOnPrimaryParent(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> parent,
+ const std::string& error);
+
+ // Sets the lastError property on the secondary parent object (in practice,
+ // this is chrome.extension.lastError).
+ void SetErrorOnSecondaryParent(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> parent,
+ const std::string& error);
+
GetParent get_parent_;
AddConsoleError add_console_error_;
« no previous file with comments | « extensions/renderer/bindings/api_bindings_system_unittest.cc ('k') | extensions/renderer/bindings/api_last_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698