Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extension_function_details.h
blob8ea440e38100e289ee6cfea7c5766f62a859c2cc
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"
9 #include "ui/gfx/native_widget_types.h"
11 class Browser;
12 class Profile;
13 class UIThreadExtensionFunction;
15 namespace content {
16 class WebContents;
19 namespace extensions {
20 class WindowController;
21 } // namespace extensions
23 // Provides Chrome-specific details to UIThreadExtensionFunction
24 // implementations.
25 class ChromeExtensionFunctionDetails {
26 public:
27 // Constructs a new ChromeExtensionFunctionDetails instance for |function|.
28 // This instance does not own |function| and must outlive it.
29 explicit ChromeExtensionFunctionDetails(UIThreadExtensionFunction* function);
30 ~ChromeExtensionFunctionDetails();
32 Profile* GetProfile() const;
34 // Gets the "current" browser, if any.
36 // Many extension APIs operate relative to the current browser, which is the
37 // browser the calling code is running inside of. For example, popups and tabs
38 // all have a containing browser, but background pages and notification
39 // bubbles do not.
41 // If there is no containing window, the current browser defaults to the
42 // foremost one.
44 // Incognito browsers are not considered unless the calling extension has
45 // incognito access enabled.
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
49 // shutdown when there are no active windows.
51 // TODO(stevenjb): Replace this with GetExtensionWindowController().
52 Browser* GetCurrentBrowser() const;
54 // Same as above but uses WindowControllerList instead of BrowserList.
55 extensions::WindowController* GetExtensionWindowController() const;
57 // Gets the "current" web contents if any. If there is no associated web
58 // contents then defaults to the foremost one.
59 content::WebContents* GetAssociatedWebContents();
61 // Gets the web contents where the function is originated. This will return
62 // the sender's web contents if it's not from a background page. Otherwise
63 // this method will try to find the web contents from source_tab_id if it's
64 // not TabStripModel::kNoTab, or find the app's web contents by the extension
65 // id. If the web contents still can't be found, NULL will be returned.
66 content::WebContents* GetOriginWebContents();
68 // Find a UI surface to display any UI (like a permission prompt) for the
69 // extension calling this function. If the origin's window can't be found,
70 // the browser's window will be returned.
71 gfx::NativeWindow GetNativeWindowForUI();
73 // Returns a pointer to the associated UIThreadExtensionFunction
74 UIThreadExtensionFunction* function() { return function_; }
75 const UIThreadExtensionFunction* function() const { return function_; }
77 private:
78 // The function for which these details have been created. Must outlive the
79 // ChromeExtensionFunctionDetails instance.
80 UIThreadExtensionFunction* function_;
82 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionFunctionDetails);
85 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_