| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/values.h" | |
| 12 #include "chrome/browser/extensions/extension_function.h" | |
| 13 #include "chrome/browser/extensions/extension_tabs_module.h" | |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 #include "content/public/browser/notification_registrar.h" | |
| 16 #include "content/public/browser/web_contents_observer.h" | |
| 17 | |
| 18 // The offscreen tabs module depends on the tabs module so we can share | |
| 19 // code between them. The long-term goal is to fold the offscreen tabs | |
| 20 // functionality into the tabs API. While these methods seem very similar to | |
| 21 // those in tabs, there are a few key differences that need to be resolved. | |
| 22 // - Offscreen tabs are invisible (maybe this could be a property on Tab). | |
| 23 // - The lifetime of an offscreen tab is tied to the parent tab that opened | |
| 24 // it. We do this to prevent leaking these tabs, since users wouldn't have | |
| 25 // a way of directly closing them or knowing they're open. | |
| 26 // - Offscreen tabs have a width and height, while regular tabs don't. This | |
| 27 // lets clients control the dimensions of the images in ToDataUrl. | |
| 28 | |
| 29 class BackingStore; | |
| 30 class SkBitmap; | |
| 31 class TabContentsWrapper; | |
| 32 namespace content { | |
| 33 class WebContents; | |
| 34 } // namespace content | |
| 35 | |
| 36 // Creates an offscreen tab. | |
| 37 class CreateOffscreenTabFunction : public SyncExtensionFunction { | |
| 38 public: | |
| 39 CreateOffscreenTabFunction(); | |
| 40 private: | |
| 41 virtual ~CreateOffscreenTabFunction(); | |
| 42 virtual bool RunImpl() OVERRIDE; | |
| 43 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.create") | |
| 44 DISALLOW_COPY_AND_ASSIGN(CreateOffscreenTabFunction); | |
| 45 }; | |
| 46 | |
| 47 // Gets info about an offscreen tab. | |
| 48 class GetOffscreenTabFunction : public SyncExtensionFunction { | |
| 49 public: | |
| 50 GetOffscreenTabFunction(); | |
| 51 private: | |
| 52 virtual ~GetOffscreenTabFunction(); | |
| 53 virtual bool RunImpl() OVERRIDE; | |
| 54 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.get") | |
| 55 DISALLOW_COPY_AND_ASSIGN(GetOffscreenTabFunction); | |
| 56 }; | |
| 57 | |
| 58 // Gets all offscreen tabs created by the tab that invoked this function. | |
| 59 class GetAllOffscreenTabFunction : public SyncExtensionFunction { | |
| 60 public: | |
| 61 GetAllOffscreenTabFunction(); | |
| 62 private: | |
| 63 virtual ~GetAllOffscreenTabFunction(); | |
| 64 virtual bool RunImpl() OVERRIDE; | |
| 65 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.getAll") | |
| 66 DISALLOW_COPY_AND_ASSIGN(GetAllOffscreenTabFunction); | |
| 67 }; | |
| 68 | |
| 69 // Removes an offscreen tab. | |
| 70 class RemoveOffscreenTabFunction : public SyncExtensionFunction { | |
| 71 public: | |
| 72 RemoveOffscreenTabFunction(); | |
| 73 private: | |
| 74 virtual ~RemoveOffscreenTabFunction(); | |
| 75 virtual bool RunImpl() OVERRIDE; | |
| 76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.remove") | |
| 77 DISALLOW_COPY_AND_ASSIGN(RemoveOffscreenTabFunction); | |
| 78 }; | |
| 79 | |
| 80 // Synthesizes a keyboard event based on a passed-in JavaScript keyboard event. | |
| 81 // TODO(jstritar): This would be useful on the chrome.tabs API. | |
| 82 class SendKeyboardEventOffscreenTabFunction : public SyncExtensionFunction { | |
| 83 public: | |
| 84 SendKeyboardEventOffscreenTabFunction(); | |
| 85 private: | |
| 86 virtual ~SendKeyboardEventOffscreenTabFunction(); | |
| 87 virtual bool RunImpl() OVERRIDE; | |
| 88 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 89 "experimental.offscreenTabs.sendKeyboardEvent") | |
| 90 DISALLOW_COPY_AND_ASSIGN(SendKeyboardEventOffscreenTabFunction); | |
| 91 }; | |
| 92 | |
| 93 // Synthesizes a mouse event based on a passed-in JavaScript mouse event. | |
| 94 // Since only the application knows where the user clicks, x and y coordinates | |
| 95 // need to be passed in as well in this case of click, mousedown, and mouseup. | |
| 96 // TODO(jstritar): This would be useful on the chrome.tabs API. | |
| 97 class SendMouseEventOffscreenTabFunction : public SyncExtensionFunction { | |
| 98 public: | |
| 99 SendMouseEventOffscreenTabFunction(); | |
| 100 private: | |
| 101 virtual ~SendMouseEventOffscreenTabFunction(); | |
| 102 virtual bool RunImpl() OVERRIDE; | |
| 103 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.sendMouseEvent") | |
| 104 DISALLOW_COPY_AND_ASSIGN(SendMouseEventOffscreenTabFunction); | |
| 105 }; | |
| 106 | |
| 107 // Gets a snapshot of the offscreen tab and returns it as a data URL. | |
| 108 class ToDataUrlOffscreenTabFunction : public CaptureVisibleTabFunction { | |
| 109 public: | |
| 110 ToDataUrlOffscreenTabFunction(); | |
| 111 private: | |
| 112 virtual ~ToDataUrlOffscreenTabFunction(); | |
| 113 virtual bool GetTabToCapture(content::WebContents** web_contents, | |
| 114 TabContentsWrapper** wrapper) OVERRIDE; | |
| 115 // TODO(jstritar): Rename to toDataUrl. | |
| 116 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.toDataUrl") | |
| 117 DISALLOW_COPY_AND_ASSIGN(ToDataUrlOffscreenTabFunction); | |
| 118 }; | |
| 119 | |
| 120 // Updates an offscreen tab. | |
| 121 class UpdateOffscreenTabFunction : public UpdateTabFunction { | |
| 122 public: | |
| 123 UpdateOffscreenTabFunction(); | |
| 124 private: | |
| 125 virtual ~UpdateOffscreenTabFunction(); | |
| 126 virtual bool RunImpl() OVERRIDE; | |
| 127 virtual void PopulateResult() OVERRIDE; | |
| 128 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.update") | |
| 129 DISALLOW_COPY_AND_ASSIGN(UpdateOffscreenTabFunction); | |
| 130 }; | |
| 131 | |
| 132 #endif // CHROME_BROWSER_EXTENSIONS_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_ | |
| OLD | NEW |