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

Side by Side Diff: chrome/browser/extensions/chrome_extension_function.h

Issue 2360073002: [Extensions] Isolate ExtensionFunction results_ and error_ (Closed)
Patch Set: errorwithargs Created 4 years, 2 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 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 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_
7 7
8 #include "chrome/browser/extensions/chrome_extension_function_details.h" 8 #include "chrome/browser/extensions/chrome_extension_function_details.h"
9 #include "extensions/browser/extension_function.h" 9 #include "extensions/browser/extension_function.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // This method can return NULL if there is no matching browser, which can 47 // This method can return NULL if there is no matching browser, which can
48 // happen if only incognito windows are open, or early in startup or shutdown 48 // happen if only incognito windows are open, or early in startup or shutdown
49 // shutdown when there are no active windows. 49 // shutdown when there are no active windows.
50 // 50 //
51 // TODO(stevenjb): Replace this with GetExtensionWindowController(). 51 // TODO(stevenjb): Replace this with GetExtensionWindowController().
52 Browser* GetCurrentBrowser(); 52 Browser* GetCurrentBrowser();
53 53
54 // Same as above but uses WindowControllerList instead of BrowserList. 54 // Same as above but uses WindowControllerList instead of BrowserList.
55 extensions::WindowController* GetExtensionWindowController(); 55 extensions::WindowController* GetExtensionWindowController();
56 56
57 // Gets the "current" web contents if any. If there is no associated web 57 // ExtensionFunction:
58 // contents then defaults to the foremost one.
59 content::WebContents* GetAssociatedWebContents() override; 58 content::WebContents* GetAssociatedWebContents() override;
59 void SetError(const std::string& error) override;
60 const std::string& GetError() const override;
61
62 protected:
63 ~ChromeUIThreadExtensionFunction() override;
60 64
61 // Responds with success/failure. |results_| or |error_| should be set 65 // Responds with success/failure. |results_| or |error_| should be set
62 // accordingly. 66 // accordingly.
63 void SendResponse(bool success); 67 void SendResponse(bool success);
64 68
65 protected: 69 // Sets a single Value as the results of the function.
66 ~ChromeUIThreadExtensionFunction() override; 70 void SetResult(std::unique_ptr<base::Value> result);
71
72 // Sets multiple Values as the results of the function.
73 void SetResultList(std::unique_ptr<base::ListValue> results);
74
75 std::unique_ptr<base::ListValue> results_;
76 std::string error_;
lazyboy 2016/09/30 01:16:05 I'm finding this very hard to grok, can we use dif
Devlin 2016/09/30 18:29:09 We can't name these something different, because e
67 77
68 private: 78 private:
69 ChromeExtensionFunctionDetails chrome_details_; 79 ChromeExtensionFunctionDetails chrome_details_;
70 }; 80 };
71 81
72 // A chrome specific analog to AsyncExtensionFunction. This has access to a 82 // A chrome specific analog to AsyncExtensionFunction. This has access to a
73 // chrome Profile. 83 // chrome Profile.
74 // 84 //
75 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or 85 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or
76 // AsyncExtensionFunction directly. Then if you need access to Chrome details, 86 // AsyncExtensionFunction directly. Then if you need access to Chrome details,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static bool ValidationFailure(ChromeSyncExtensionFunction* function); 127 static bool ValidationFailure(ChromeSyncExtensionFunction* function);
118 128
119 private: 129 private:
120 // If you're hitting a compile error here due to "final" - great! You're doing 130 // If you're hitting a compile error here due to "final" - great! You're doing
121 // the right thing, you just need to extend ChromeUIThreadExtensionFunction 131 // the right thing, you just need to extend ChromeUIThreadExtensionFunction
122 // instead of ChromeSyncExtensionFunction. 132 // instead of ChromeSyncExtensionFunction.
123 ResponseAction Run() final; 133 ResponseAction Run() final;
124 }; 134 };
125 135
126 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_ 136 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698