Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extension_function_details.h
blob2484158ff4dafd219f7fd8542df23eb2a19eec58
1 // Copyright 2014 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_DETAILS_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_
8 #include "base/macros.h"
10 class Browser;
11 class Profile;
12 class UIThreadExtensionFunction;
14 namespace content {
15 class WebContents;
18 namespace extensions {
19 class WindowController;
20 } // namespace extensions
22 // Provides Chrome-specific details to UIThreadExtensionFunction
23 // implementations.
24 class ChromeExtensionFunctionDetails {
25 public:
26 // Constructs a new ChromeExtensionFunctionDetails instance for |function|.
27 // This instance does not own |function| and must outlive it.
28 explicit ChromeExtensionFunctionDetails(UIThreadExtensionFunction* function);
29 ~ChromeExtensionFunctionDetails();
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(
36 const extensions::WindowController* window_controller) 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 and tabs
42 // all have a containing browser, but background pages and notification
43 // 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() const;
58 // Same as above but uses WindowControllerList instead of BrowserList.
59 extensions::WindowController* GetExtensionWindowController() const;
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();
65 // Returns a pointer to the associated UIThreadExtensionFunction
66 UIThreadExtensionFunction* function() { return function_; }
67 const UIThreadExtensionFunction* function() const { return function_; }
69 private:
70 // The function for which these details have been created. Must outlive the
71 // ChromeExtensionFunctionDetails instance.
72 UIThreadExtensionFunction* function_;
74 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionFunctionDetails);
77 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_