Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 class Browser; | |
| 11 class Profile; | |
| 12 class UIThreadExtensionFunction; | |
| 13 | |
| 14 namespace content { | |
| 15 class WebContents; | |
| 16 } | |
| 17 | |
| 18 namespace extensions { | |
| 19 class WindowController; | |
| 20 } // namespace extensions | |
| 21 | |
| 22 // This can be used to provide a a UIThreadExtensionFunction implementation with | |
|
scheib
2014/09/05 03:17:22
" a a " typo.
Ken Rockot(use gerrit already)
2014/09/05 16:47:39
Done.
| |
| 23 // some additional Chrome-specific details. | |
|
scheib
2014/09/05 03:17:22
consider shortening to: "Provides UIThreadExtensio
Ken Rockot(use gerrit already)
2014/09/05 16:47:39
Done.
| |
| 24 class ChromeExtensionFunctionDetails { | |
| 25 public: | |
| 26 explicit ChromeExtensionFunctionDetails(UIThreadExtensionFunction* function); | |
| 27 ~ChromeExtensionFunctionDetails(); | |
| 28 | |
| 29 Profile* GetProfile() const; | |
| 30 | |
| 31 // Returns true if this function (and the profile and extension that it was | |
| 32 // invoked from) can operate on the window wrapped by |window_controller|. | |
| 33 bool CanOperateOnWindow( | |
| 34 const extensions::WindowController* window_controller) const; | |
| 35 | |
| 36 // Gets the "current" browser, if any. | |
| 37 // | |
| 38 // Many extension APIs operate relative to the current browser, which is the | |
| 39 // browser the calling code is running inside of. For example, popups, tabs, | |
| 40 // and infobars all have a containing browser, but background pages and | |
| 41 // notification bubbles do not. | |
| 42 // | |
| 43 // If there is no containing window, the current browser defaults to the | |
| 44 // foremost one. | |
| 45 // | |
| 46 // Incognito browsers are not considered unless the calling extension has | |
| 47 // incognito access enabled. | |
| 48 // | |
| 49 // This method can return NULL if there is no matching browser, which can | |
| 50 // happen if only incognito windows are open, or early in startup or shutdown | |
| 51 // shutdown when there are no active windows. | |
| 52 // | |
| 53 // TODO(stevenjb): Replace this with GetExtensionWindowController(). | |
| 54 Browser* GetCurrentBrowser() const; | |
| 55 | |
| 56 // Same as above but uses WindowControllerList instead of BrowserList. | |
| 57 extensions::WindowController* GetExtensionWindowController() const; | |
| 58 | |
| 59 // Gets the "current" web contents if any. If there is no associated web | |
| 60 // contents then defaults to the foremost one. | |
| 61 content::WebContents* GetAssociatedWebContents(); | |
| 62 | |
| 63 private: | |
| 64 // The function for which these details have been created. Must outlive the | |
|
scheib
2014/09/05 03:17:22
Consider making this point at the class or constru
Ken Rockot(use gerrit already)
2014/09/05 16:47:39
Done.
| |
| 65 // ChromeExtensionFunctionDetails instance. | |
| 66 UIThreadExtensionFunction* function_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionFunctionDetails); | |
| 69 }; | |
| 70 | |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_ | |
| OLD | NEW |