Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/extensions/extension_tabs_module.h

Issue 9234042: Re-land alexbost's experimental offscreenTabs API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge / rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/extensions/extension_function.h" 13 #include "chrome/browser/extensions/extension_function.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 class BackingStore; 19 class BackingStore;
20 class Extension;
21 class GURL;
20 class SkBitmap; 22 class SkBitmap;
23 class TabContentsWrapper;
21 namespace base { 24 namespace base {
22 class DictionaryValue; 25 class DictionaryValue;
23 } // namespace base 26 } // namespace base
24 namespace content { 27 namespace content {
25 class WebContents; 28 class WebContents;
26 } // namespace content 29 } // namespace content
30
31
32 // TODO(jstritar): These helper methods are exposed so the offscreen tabs API
33 // can use them. We should remove these once the APIs are combined.
asargent_no_longer_on_chrome 2012/02/29 18:20:52 Would it be appropriate for these to go in extensi
jstritar 2012/03/12 14:53:06 Yeah, they can probably go there.
34 namespace extensions {
35 namespace tabs_module {
36
37 // Takes |url_string| and returns a GURL which is either valid and absolute
38 // or invalid. If |url_string| is not directly interpretable as a valid (it is
39 // likely a relative URL) an attempt is made to resolve it. |extension| is
40 // provided so it can be resolved relative to its extension base
41 // (chrome-extension://<id>/). Using the source frame url would be more correct,
42 // but because the api shipped with urls resolved relative to their extension
43 // base, we decided it wasn't worth breaking existing extensions to fix.
44 GURL ResolvePossiblyRelativeURL(const std::string& url_string,
45 const Extension* extension);
46
47 // Returns true if |url| is used for testing crashes.
48 bool IsCrashURL(const GURL& url);
49
50 } // namespace tabs_module
51 } // namespace extensions
52
27 // Windows 53 // Windows
28 class GetWindowFunction : public SyncExtensionFunction { 54 class GetWindowFunction : public SyncExtensionFunction {
29 virtual ~GetWindowFunction() {} 55 virtual ~GetWindowFunction() {}
30 virtual bool RunImpl() OVERRIDE; 56 virtual bool RunImpl() OVERRIDE;
31 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") 57 DECLARE_EXTENSION_FUNCTION_NAME("windows.get")
32 }; 58 };
33 class GetCurrentWindowFunction : public SyncExtensionFunction { 59 class GetCurrentWindowFunction : public SyncExtensionFunction {
34 virtual ~GetCurrentWindowFunction() {} 60 virtual ~GetCurrentWindowFunction() {}
35 virtual bool RunImpl() OVERRIDE; 61 virtual bool RunImpl() OVERRIDE;
36 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") 62 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent")
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }; 129 };
104 class HighlightTabsFunction : public SyncExtensionFunction { 130 class HighlightTabsFunction : public SyncExtensionFunction {
105 virtual ~HighlightTabsFunction() {} 131 virtual ~HighlightTabsFunction() {}
106 virtual bool RunImpl() OVERRIDE; 132 virtual bool RunImpl() OVERRIDE;
107 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") 133 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight")
108 }; 134 };
109 class UpdateTabFunction : public AsyncExtensionFunction, 135 class UpdateTabFunction : public AsyncExtensionFunction,
110 public content::WebContentsObserver { 136 public content::WebContentsObserver {
111 public: 137 public:
112 UpdateTabFunction(); 138 UpdateTabFunction();
139
140 protected:
141 virtual ~UpdateTabFunction() {}
142 virtual bool UpdateURLIfPresent(base::DictionaryValue* update_props,
143 bool* is_async);
144 void PopulateResult();
145
146 content::WebContents* web_contents_;
147
113 private: 148 private:
114 virtual ~UpdateTabFunction() {}
115 virtual bool RunImpl() OVERRIDE; 149 virtual bool RunImpl() OVERRIDE;
116 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; 150 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
117 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 151 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
118 void OnExecuteCodeFinished(int request_id, 152 void OnExecuteCodeFinished(int request_id,
119 bool success, 153 bool success,
120 const std::string& error); 154 const std::string& error);
121 void PopulateResult();
122 155
123 content::WebContents* web_contents_;
124 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") 156 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update")
125 }; 157 };
126 class MoveTabsFunction : public SyncExtensionFunction { 158 class MoveTabsFunction : public SyncExtensionFunction {
127 virtual ~MoveTabsFunction() {} 159 virtual ~MoveTabsFunction() {}
128 virtual bool RunImpl() OVERRIDE; 160 virtual bool RunImpl() OVERRIDE;
129 DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") 161 DECLARE_EXTENSION_FUNCTION_NAME("tabs.move")
130 }; 162 };
131 class ReloadTabFunction : public SyncExtensionFunction { 163 class ReloadTabFunction : public SyncExtensionFunction {
132 virtual ~ReloadTabFunction() {} 164 virtual ~ReloadTabFunction() {}
133 virtual bool RunImpl() OVERRIDE; 165 virtual bool RunImpl() OVERRIDE;
(...skipping 12 matching lines...) Expand all
146 178
147 virtual void Observe(int type, 179 virtual void Observe(int type,
148 const content::NotificationSource& source, 180 const content::NotificationSource& source,
149 const content::NotificationDetails& details) OVERRIDE; 181 const content::NotificationDetails& details) OVERRIDE;
150 void GotLanguage(const std::string& language); 182 void GotLanguage(const std::string& language);
151 content::NotificationRegistrar registrar_; 183 content::NotificationRegistrar registrar_;
152 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") 184 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage")
153 }; 185 };
154 class CaptureVisibleTabFunction : public AsyncExtensionFunction, 186 class CaptureVisibleTabFunction : public AsyncExtensionFunction,
155 public content::NotificationObserver { 187 public content::NotificationObserver {
156 private: 188 protected:
157 enum ImageFormat { 189 enum ImageFormat {
158 FORMAT_JPEG, 190 FORMAT_JPEG,
159 FORMAT_PNG 191 FORMAT_PNG
160 }; 192 };
161 193
162 // The default quality setting used when encoding jpegs. 194 // The default quality setting used when encoding jpegs.
163 static const int kDefaultQuality; 195 static const int kDefaultQuality;
164 196
165 virtual ~CaptureVisibleTabFunction() {} 197 virtual ~CaptureVisibleTabFunction() {}
166 virtual bool RunImpl() OVERRIDE; 198 virtual bool RunImpl() OVERRIDE;
167 virtual bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); 199 virtual bool GetTabToCapture(content::WebContents** web_contents,
200 TabContentsWrapper** wrapper);
201 virtual bool CaptureSnapshotFromBackingStore(
202 content::WebContents* backing_store);
168 virtual void Observe(int type, 203 virtual void Observe(int type,
169 const content::NotificationSource& source, 204 const content::NotificationSource& source,
170 const content::NotificationDetails& details) OVERRIDE; 205 const content::NotificationDetails& details) OVERRIDE;
171 virtual void SendResultFromBitmap(const SkBitmap& screen_capture); 206 virtual void SendResultFromBitmap(const SkBitmap& screen_capture);
172 207
173 content::NotificationRegistrar registrar_; 208 content::NotificationRegistrar registrar_;
174 209
175 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). 210 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl().
176 ImageFormat image_format_; 211 ImageFormat image_format_;
177 212
178 // Quality setting to use when encoding jpegs. Set in RunImpl(). 213 // Quality setting to use when encoding jpegs. Set in RunImpl().
179 int image_quality_; 214 int image_quality_;
180 215
181 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") 216 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab")
182 }; 217 };
183 218
184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ 219 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698