| OLD | NEW |
| 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_API_TABS_TABS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 virtual ~TabsDetectLanguageFunction() {} | 167 virtual ~TabsDetectLanguageFunction() {} |
| 168 virtual bool RunImpl() OVERRIDE; | 168 virtual bool RunImpl() OVERRIDE; |
| 169 | 169 |
| 170 virtual void Observe(int type, | 170 virtual void Observe(int type, |
| 171 const content::NotificationSource& source, | 171 const content::NotificationSource& source, |
| 172 const content::NotificationDetails& details) OVERRIDE; | 172 const content::NotificationDetails& details) OVERRIDE; |
| 173 void GotLanguage(const std::string& language); | 173 void GotLanguage(const std::string& language); |
| 174 content::NotificationRegistrar registrar_; | 174 content::NotificationRegistrar registrar_; |
| 175 DECLARE_EXTENSION_FUNCTION("tabs.detectLanguage", TABS_DETECTLANGUAGE) | 175 DECLARE_EXTENSION_FUNCTION("tabs.detectLanguage", TABS_DETECTLANGUAGE) |
| 176 }; | 176 }; |
| 177 class TabsCaptureVisibleTabFunction : public AsyncExtensionFunction { | 177 class TabsCaptureVisibleTabFunction : public AsyncExtensionFunction, |
| 178 public content::NotificationObserver { |
| 178 public: | 179 public: |
| 179 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 180 static void RegisterUserPrefs(PrefRegistrySyncable* registry); |
| 180 | 181 |
| 181 protected: | 182 protected: |
| 182 enum ImageFormat { | 183 enum ImageFormat { |
| 183 FORMAT_JPEG, | 184 FORMAT_JPEG, |
| 184 FORMAT_PNG | 185 FORMAT_PNG |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 // The default quality setting used when encoding jpegs. | 188 // The default quality setting used when encoding jpegs. |
| 188 static const int kDefaultQuality; | 189 static const int kDefaultQuality; |
| 189 | 190 |
| 190 virtual ~TabsCaptureVisibleTabFunction() {} | 191 virtual ~TabsCaptureVisibleTabFunction() {} |
| 191 virtual bool RunImpl() OVERRIDE; | 192 virtual bool RunImpl() OVERRIDE; |
| 192 virtual bool GetTabToCapture(content::WebContents** web_contents); | 193 virtual bool GetTabToCapture(content::WebContents** web_contents); |
| 194 virtual void Observe(int type, |
| 195 const content::NotificationSource& source, |
| 196 const content::NotificationDetails& details) OVERRIDE; |
| 193 void SendResultFromBitmap(const SkBitmap& screen_capture); | 197 void SendResultFromBitmap(const SkBitmap& screen_capture); |
| 194 | 198 |
| 195 private: | 199 private: |
| 196 // Callback for the RWH::CopyFromBackingStore call. | |
| 197 void CopyFromBackingStoreComplete(bool succeeded, | 200 void CopyFromBackingStoreComplete(bool succeeded, |
| 198 const SkBitmap& bitmap); | 201 const SkBitmap& bitmap); |
| 199 | 202 |
| 200 // Callback for the RWH::GetSnapshotFromRenderer call. This path is used if | 203 content::NotificationRegistrar registrar_; |
| 201 // CopyFromBackingStore fails for some reason. | |
| 202 void GetSnapshotFromRendererComplete(bool succeeded, | |
| 203 const SkBitmap& bitmap); | |
| 204 void SendInternalError(); | |
| 205 | 204 |
| 206 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). | 205 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). |
| 207 ImageFormat image_format_; | 206 ImageFormat image_format_; |
| 208 | 207 |
| 209 // Quality setting to use when encoding jpegs. Set in RunImpl(). | 208 // Quality setting to use when encoding jpegs. Set in RunImpl(). |
| 210 int image_quality_; | 209 int image_quality_; |
| 211 | 210 |
| 212 DECLARE_EXTENSION_FUNCTION("tabs.captureVisibleTab", TABS_CAPTUREVISIBLETAB) | 211 DECLARE_EXTENSION_FUNCTION("tabs.captureVisibleTab", TABS_CAPTUREVISIBLETAB) |
| 213 }; | 212 }; |
| 214 | 213 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 }; | 277 }; |
| 279 | 278 |
| 280 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { | 279 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { |
| 281 private: | 280 private: |
| 282 virtual ~TabsInsertCSSFunction() {} | 281 virtual ~TabsInsertCSSFunction() {} |
| 283 | 282 |
| 284 DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS) | 283 DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS) |
| 285 }; | 284 }; |
| 286 | 285 |
| 287 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ | 286 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
| OLD | NEW |