Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extension_function.h
blobdbf00997a24865d96994d9345059603e30a25c7f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_
8 #include "extensions/browser/extension_function.h"
10 class Browser;
11 class Profile;
13 namespace content {
14 class WebContents;
17 namespace extensions {
18 class WindowController;
21 // A chrome specific analog to AsyncExtensionFunction. This has access to a
22 // chrome Profile.
24 // DEPRECATED: Please consider inherting UIThreadExtensionFunction directly.
25 // Then if you need access to Chrome details, you can construct a
26 // ChromeExtensionFunctionDetails object within your function implementation.
27 class ChromeUIThreadExtensionFunction : public UIThreadExtensionFunction {
28 public:
29 ChromeUIThreadExtensionFunction();
31 Profile* GetProfile() const;
33 // Returns true if this function (and the profile and extension that it was
34 // invoked from) can operate on the window wrapped by |window_controller|.
35 bool CanOperateOnWindow(const extensions::WindowController* window_controller)
36 const;
38 // Gets the "current" browser, if any.
40 // Many extension APIs operate relative to the current browser, which is the
41 // browser the calling code is running inside of. For example, popups, tabs,
42 // and infobars all have a containing browser, but background pages and
43 // notification bubbles do not.
45 // If there is no containing window, the current browser defaults to the
46 // foremost one.
48 // Incognito browsers are not considered unless the calling extension has
49 // incognito access enabled.
51 // This method can return NULL if there is no matching browser, which can
52 // happen if only incognito windows are open, or early in startup or shutdown
53 // shutdown when there are no active windows.
55 // TODO(stevenjb): Replace this with GetExtensionWindowController().
56 Browser* GetCurrentBrowser();
58 // Same as above but uses WindowControllerList instead of BrowserList.
59 extensions::WindowController* GetExtensionWindowController();
61 // Gets the "current" web contents if any. If there is no associated web
62 // contents then defaults to the foremost one.
63 content::WebContents* GetAssociatedWebContents() override;
65 protected:
66 ~ChromeUIThreadExtensionFunction() override;
69 // A chrome specific analog to AsyncExtensionFunction. This has access to a
70 // chrome Profile.
72 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or
73 // AsyncExtensionFunction directly. Then if you need access to Chrome details,
74 // you can construct a ChromeExtensionFunctionDetails object within your
75 // function implementation.
76 class ChromeAsyncExtensionFunction : public ChromeUIThreadExtensionFunction {
77 public:
78 ChromeAsyncExtensionFunction();
80 protected:
81 ~ChromeAsyncExtensionFunction() override;
83 // Deprecated, see AsyncExtensionFunction::RunAsync.
84 virtual bool RunAsync() = 0;
86 // ValidationFailure override to match RunAsync().
87 static bool ValidationFailure(ChromeAsyncExtensionFunction* function);
89 private:
90 // If you're hitting a compile error here due to "final" - great! You're doing
91 // the right thing, you just need to extend ChromeUIThreadExtensionFunction
92 // instead of ChromeAsyncExtensionFunction.
93 ResponseAction Run() final;
96 // A chrome specific analog to SyncExtensionFunction. This has access to a
97 // chrome Profile.
99 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or
100 // SyncExtensionFunction directly. Then if you need access to Chrome details,
101 // you can construct a ChromeExtensionFunctionDetails object within your
102 // function implementation.
103 class ChromeSyncExtensionFunction : public ChromeUIThreadExtensionFunction {
104 public:
105 ChromeSyncExtensionFunction();
107 protected:
108 ~ChromeSyncExtensionFunction() override;
110 // Deprecated, see SyncExtensionFunction::RunSync.
111 virtual bool RunSync() = 0;
113 // ValidationFailure override to match RunSync().
114 static bool ValidationFailure(ChromeSyncExtensionFunction* function);
116 private:
117 // If you're hitting a compile error here due to "final" - great! You're doing
118 // the right thing, you just need to extend ChromeUIThreadExtensionFunction
119 // instead of ChromeSyncExtensionFunction.
120 ResponseAction Run() final;
123 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_