blob: 9650ad8a934e10c067070d5d37f4c1cd7aa0fc72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_
#include <string>
#include "base/values.h"
#include "chrome/browser/extensions/api/tabs/tabs.h"
#include "chrome/browser/extensions/extension_function.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
// The offscreen tabs module depends on the tabs module so we can share
// code between them. The long-term goal is to fold the offscreen tabs
// functionality into the tabs API. While these methods seem very similar to
// those in tabs, there are a few key differences that need to be resolved.
// - Offscreen tabs are invisible (maybe this could be a property on Tab).
// - The lifetime of an offscreen tab is tied to the parent tab that opened
// it. We do this to prevent leaking these tabs, since users wouldn't have
// a way of directly closing them or knowing they're open.
// - Offscreen tabs have a width and height, while regular tabs don't. This
// lets clients control the dimensions of the images in ToDataUrl.
class BackingStore;
class SkBitmap;
namespace content {
class WebContents;
}
// Creates an offscreen tab.
class CreateOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.create")
CreateOffscreenTabFunction();
protected:
virtual ~CreateOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(CreateOffscreenTabFunction);
};
// Gets info about an offscreen tab.
class GetOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.get")
GetOffscreenTabFunction();
protected:
virtual ~GetOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(GetOffscreenTabFunction);
};
// Gets all offscreen tabs created by the tab that invoked this function.
class GetAllOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.getAll")
GetAllOffscreenTabFunction();
protected:
virtual ~GetAllOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(GetAllOffscreenTabFunction);
};
// Removes an offscreen tab.
class RemoveOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.remove")
RemoveOffscreenTabFunction();
protected:
virtual ~RemoveOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(RemoveOffscreenTabFunction);
};
// Synthesizes a keyboard event based on a passed-in JavaScript keyboard event.
// TODO(jstritar): This would be useful on the chrome.tabs API.
class SendKeyboardEventOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.offscreenTabs.sendKeyboardEvent")
SendKeyboardEventOffscreenTabFunction();
protected:
virtual ~SendKeyboardEventOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(SendKeyboardEventOffscreenTabFunction);
};
// Synthesizes a mouse event based on a passed-in JavaScript mouse event.
// Since only the application knows where the user clicks, x and y coordinates
// need to be passed in as well in this case of click, mousedown, and mouseup.
// TODO(jstritar): This would be useful on the chrome.tabs API.
class SendMouseEventOffscreenTabFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.sendMouseEvent")
SendMouseEventOffscreenTabFunction();
protected:
virtual ~SendMouseEventOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(SendMouseEventOffscreenTabFunction);
};
// Gets a snapshot of the offscreen tab and returns it as a data URL.
class ToDataUrlOffscreenTabFunction : public CaptureVisibleTabFunction {
public:
// TODO(jstritar): Rename to toDataUrl.
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.toDataUrl")
ToDataUrlOffscreenTabFunction();
protected:
virtual ~ToDataUrlOffscreenTabFunction();
// CaptureVisibleTabFunction:
virtual bool GetTabToCapture(content::WebContents** web_contents) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ToDataUrlOffscreenTabFunction);
};
// Updates an offscreen tab.
class UpdateOffscreenTabFunction : public UpdateTabFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.update")
UpdateOffscreenTabFunction();
protected:
virtual ~UpdateOffscreenTabFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
// UpdateTabFunction:
virtual void PopulateResult() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(UpdateOffscreenTabFunction);
};
#endif // CHROME_BROWSER_EXTENSIONS_API_OFFSCREEN_TABS_OFFSCREEN_TABS_API_H_
|