OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_EXTENSION_OFFSCREEN_TABS_MODULE_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_OFFSCREEN_TABS_MODULE_H__ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/extension_function.h" |
| 13 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 14 #include "content/common/notification_observer.h" |
| 15 #include "content/common/notification_registrar.h" |
| 16 |
| 17 class BackingStore; |
| 18 class SkBitmap; |
| 19 class TabContents; |
| 20 class TabContentsWrapper; |
| 21 |
| 22 namespace base { |
| 23 class DictionaryValue; |
| 24 class ListValue; |
| 25 } |
| 26 |
| 27 // Creates an offscreen tab and adds it to a map of tabs and their child |
| 28 // offscreen tabs. |
| 29 class CreateOffscreenTabFunction : public SyncExtensionFunction { |
| 30 public: |
| 31 CreateOffscreenTabFunction(); |
| 32 virtual ~CreateOffscreenTabFunction(); |
| 33 virtual bool RunImpl() OVERRIDE; |
| 34 |
| 35 private: |
| 36 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.create") |
| 37 DISALLOW_COPY_AND_ASSIGN(CreateOffscreenTabFunction); |
| 38 }; |
| 39 |
| 40 // Gets info about an offscreen tab. |
| 41 class GetOffscreenTabFunction : public SyncExtensionFunction { |
| 42 public: |
| 43 GetOffscreenTabFunction(); |
| 44 virtual ~GetOffscreenTabFunction(); |
| 45 virtual bool RunImpl() OVERRIDE; |
| 46 |
| 47 private: |
| 48 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.get") |
| 49 DISALLOW_COPY_AND_ASSIGN(GetOffscreenTabFunction); |
| 50 }; |
| 51 |
| 52 // Gets all offscreen tabs created by the tab that invoked this function. |
| 53 class GetAllOffscreenTabFunction : public SyncExtensionFunction { |
| 54 public: |
| 55 GetAllOffscreenTabFunction(); |
| 56 virtual ~GetAllOffscreenTabFunction(); |
| 57 virtual bool RunImpl() OVERRIDE; |
| 58 |
| 59 private: |
| 60 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.getAll") |
| 61 DISALLOW_COPY_AND_ASSIGN(GetAllOffscreenTabFunction); |
| 62 }; |
| 63 |
| 64 // Removes an offscreen tab. |
| 65 class RemoveOffscreenTabFunction : public SyncExtensionFunction { |
| 66 public: |
| 67 RemoveOffscreenTabFunction(); |
| 68 virtual ~RemoveOffscreenTabFunction(); |
| 69 virtual bool RunImpl() OVERRIDE; |
| 70 |
| 71 private: |
| 72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.remove") |
| 73 DISALLOW_COPY_AND_ASSIGN(RemoveOffscreenTabFunction); |
| 74 }; |
| 75 |
| 76 // Synthesizes a keyboard event based on a passed-in JavaScript keyboard event. |
| 77 class SendKeyboardEventOffscreenTabFunction : public SyncExtensionFunction { |
| 78 public: |
| 79 SendKeyboardEventOffscreenTabFunction(); |
| 80 virtual ~SendKeyboardEventOffscreenTabFunction(); |
| 81 virtual bool RunImpl() OVERRIDE; |
| 82 |
| 83 private: |
| 84 DECLARE_EXTENSION_FUNCTION_NAME( |
| 85 "experimental.offscreenTabs.sendKeyboardEvent") |
| 86 DISALLOW_COPY_AND_ASSIGN(SendKeyboardEventOffscreenTabFunction); |
| 87 }; |
| 88 |
| 89 // Synthesizes a mouse event based on a passed-in JavaScript mouse event. |
| 90 // Since only the application knows where the user clicks, x and y coordinates |
| 91 // need to be passed in as well in this case of click, mousedown, and mouseup. |
| 92 class SendMouseEventOffscreenTabFunction : public SyncExtensionFunction { |
| 93 public: |
| 94 SendMouseEventOffscreenTabFunction(); |
| 95 virtual ~SendMouseEventOffscreenTabFunction(); |
| 96 virtual bool RunImpl() OVERRIDE; |
| 97 |
| 98 private: |
| 99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.sendMouseEvent") |
| 100 DISALLOW_COPY_AND_ASSIGN(SendMouseEventOffscreenTabFunction); |
| 101 }; |
| 102 |
| 103 // Gets a snapshot of the offscreen tabs and returns it as a data URL. |
| 104 class ToDataUrlOffscreenTabFunction : public AsyncExtensionFunction, |
| 105 public NotificationObserver { |
| 106 public: |
| 107 ToDataUrlOffscreenTabFunction(); |
| 108 virtual ~ToDataUrlOffscreenTabFunction(); |
| 109 virtual bool RunImpl() OVERRIDE; |
| 110 |
| 111 private: |
| 112 enum ImageFormat { |
| 113 FORMAT_JPEG, |
| 114 FORMAT_PNG |
| 115 }; |
| 116 |
| 117 // The default quality setting used when encoding jpegs. |
| 118 static const int kDefaultQuality = 90; |
| 119 virtual bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); |
| 120 virtual void Observe(int type, |
| 121 const NotificationSource& source, |
| 122 const NotificationDetails& details) OVERRIDE; |
| 123 virtual void SendResultFromBitmap(const SkBitmap& screen_capture); |
| 124 |
| 125 NotificationRegistrar registrar_; |
| 126 |
| 127 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). |
| 128 ImageFormat image_format_; |
| 129 |
| 130 // Quality setting to use when encoding jpegs. Set in RunImpl(). |
| 131 int image_quality_; |
| 132 |
| 133 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.toDataUrl") |
| 134 DISALLOW_COPY_AND_ASSIGN(ToDataUrlOffscreenTabFunction); |
| 135 }; |
| 136 |
| 137 // Updates an offscreen tab. |
| 138 class UpdateOffscreenTabFunction : public AsyncExtensionFunction, |
| 139 public TabContentsObserver { |
| 140 public: |
| 141 UpdateOffscreenTabFunction(); |
| 142 virtual ~UpdateOffscreenTabFunction(); |
| 143 virtual bool RunImpl() OVERRIDE; |
| 144 |
| 145 private: |
| 146 virtual bool OnMessageReceived(const IPC::Message& message); |
| 147 void OnExecuteCodeFinished(int request_id, |
| 148 bool success, |
| 149 const std::string& error); |
| 150 |
| 151 DECLARE_EXTENSION_FUNCTION_NAME("experimental.offscreenTabs.update") |
| 152 DISALLOW_COPY_AND_ASSIGN(UpdateOffscreenTabFunction); |
| 153 }; |
| 154 |
| 155 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_OFFSCREEN_TABS_MODULE_H__ |
| 156 |
OLD | NEW |