Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extension_function.h
blobfefcda97e9443ca0f1f943b0ce57aa4c1b398f53
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 // Gets the "current" browser, if any.
35 // Many extension APIs operate relative to the current browser, which is the
36 // browser the calling code is running inside of. For example, popups, tabs,
37 // and infobars all have a containing browser, but background pages and
38 // notification bubbles do not.
40 // If there is no containing window, the current browser defaults to the
41 // foremost one.
43 // Incognito browsers are not considered unless the calling extension has
44 // incognito access enabled.
46 // This method can return NULL if there is no matching browser, which can
47 // happen if only incognito windows are open, or early in startup or shutdown
48 // shutdown when there are no active windows.
50 // TODO(stevenjb): Replace this with GetExtensionWindowController().
51 Browser* GetCurrentBrowser();
53 // Same as above but uses WindowControllerList instead of BrowserList.
54 extensions::WindowController* GetExtensionWindowController();
56 // Gets the "current" web contents if any. If there is no associated web
57 // contents then defaults to the foremost one.
58 content::WebContents* GetAssociatedWebContents() override;
60 protected:
61 ~ChromeUIThreadExtensionFunction() override;
64 // A chrome specific analog to AsyncExtensionFunction. This has access to a
65 // chrome Profile.
67 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or
68 // AsyncExtensionFunction directly. Then if you need access to Chrome details,
69 // you can construct a ChromeExtensionFunctionDetails object within your
70 // function implementation.
71 class ChromeAsyncExtensionFunction : public ChromeUIThreadExtensionFunction {
72 public:
73 ChromeAsyncExtensionFunction();
75 protected:
76 ~ChromeAsyncExtensionFunction() override;
78 // Deprecated, see AsyncExtensionFunction::RunAsync.
79 virtual bool RunAsync() = 0;
81 // ValidationFailure override to match RunAsync().
82 static bool ValidationFailure(ChromeAsyncExtensionFunction* function);
84 private:
85 // If you're hitting a compile error here due to "final" - great! You're doing
86 // the right thing, you just need to extend ChromeUIThreadExtensionFunction
87 // instead of ChromeAsyncExtensionFunction.
88 ResponseAction Run() final;
91 // A chrome specific analog to SyncExtensionFunction. This has access to a
92 // chrome Profile.
94 // DEPRECATED: Please consider inherting UIThreadExtensionFunction or
95 // SyncExtensionFunction directly. Then if you need access to Chrome details,
96 // you can construct a ChromeExtensionFunctionDetails object within your
97 // function implementation.
98 class ChromeSyncExtensionFunction : public ChromeUIThreadExtensionFunction {
99 public:
100 ChromeSyncExtensionFunction();
102 protected:
103 ~ChromeSyncExtensionFunction() override;
105 // Deprecated, see SyncExtensionFunction::RunSync.
106 virtual bool RunSync() = 0;
108 // ValidationFailure override to match RunSync().
109 static bool ValidationFailure(ChromeSyncExtensionFunction* function);
111 private:
112 // If you're hitting a compile error here due to "final" - great! You're doing
113 // the right thing, you just need to extend ChromeUIThreadExtensionFunction
114 // instead of ChromeSyncExtensionFunction.
115 ResponseAction Run() final;
118 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_H_