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 class ChromeExtensionFunctionDetails { | |
|
Yoyo Zhou
2014/09/04 23:41:59
class description comment?
Ken Rockot(use gerrit already)
2014/09/05 00:45:02
Done.
| |
| 23 public: | |
| 24 explicit ChromeExtensionFunctionDetails(UIThreadExtensionFunction* function); | |
| 25 ~ChromeExtensionFunctionDetails(); | |
| 26 | |
| 27 Profile* GetProfile() const; | |
| 28 | |
| 29 // Returns true if this function (and the profile and extension that it was | |
| 30 // invoked from) can operate on the window wrapped by |window_controller|. | |
| 31 bool CanOperateOnWindow( | |
| 32 const extensions::WindowController* window_controller) const; | |
| 33 | |
| 34 // Gets the "current" browser, if any. | |
| 35 // | |
| 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, tabs, | |
| 38 // and infobars all have a containing browser, but background pages and | |
| 39 // notification bubbles do not. | |
| 40 // | |
| 41 // If there is no containing window, the current browser defaults to the | |
| 42 // foremost one. | |
| 43 // | |
| 44 // Incognito browsers are not considered unless the calling extension has | |
| 45 // incognito access enabled. | |
| 46 // | |
| 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. | |
| 50 // | |
| 51 // TODO(stevenjb): Replace this with GetExtensionWindowController(). | |
| 52 Browser* GetCurrentBrowser() const; | |
| 53 | |
| 54 // Same as above but uses WindowControllerList instead of BrowserList. | |
| 55 extensions::WindowController* GetExtensionWindowController() const; | |
| 56 | |
| 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(); | |
| 60 | |
| 61 private: | |
| 62 // The function for which these details have been created. Must outlive the | |
| 63 // ChromeExtensionFunctionDetails instance; this should not be a problem | |
| 64 // since such instances should only be created and owned exclusively by | |
|
Yoyo Zhou
2014/09/04 23:41:58
This doesn't look exactly as you've described in t
Ken Rockot(use gerrit already)
2014/09/05 00:45:03
I just removed the inaccurate part.
| |
| 65 // the functions themselves. | |
| 66 UIThreadExtensionFunction* function_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionFunctionDetails); | |
| 69 }; | |
| 70 | |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_FUNCTION_DETAILS_H_ | |
| OLD | NEW |