| 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_TABS_TABS_H__ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_H__ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "chrome/browser/extensions/extension_function.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 | |
| 17 class BackingStore; | |
| 18 class GURL; | |
| 19 class PrefServiceSyncable; | |
| 20 class SkBitmap; | |
| 21 | |
| 22 namespace base { | |
| 23 class DictionaryValue; | |
| 24 } | |
| 25 | |
| 26 namespace content { | |
| 27 class WebContents; | |
| 28 } | |
| 29 | |
| 30 namespace skia { | |
| 31 class PlatformBitmap; | |
| 32 } | |
| 33 | |
| 34 // Windows | |
| 35 class GetWindowFunction : public SyncExtensionFunction { | |
| 36 virtual ~GetWindowFunction() {} | |
| 37 virtual bool RunImpl() OVERRIDE; | |
| 38 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") | |
| 39 }; | |
| 40 class GetCurrentWindowFunction : public SyncExtensionFunction { | |
| 41 virtual ~GetCurrentWindowFunction() {} | |
| 42 virtual bool RunImpl() OVERRIDE; | |
| 43 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") | |
| 44 }; | |
| 45 class GetLastFocusedWindowFunction : public SyncExtensionFunction { | |
| 46 virtual ~GetLastFocusedWindowFunction() {} | |
| 47 virtual bool RunImpl() OVERRIDE; | |
| 48 DECLARE_EXTENSION_FUNCTION_NAME("windows.getLastFocused") | |
| 49 }; | |
| 50 class GetAllWindowsFunction : public SyncExtensionFunction { | |
| 51 virtual ~GetAllWindowsFunction() {} | |
| 52 virtual bool RunImpl() OVERRIDE; | |
| 53 DECLARE_EXTENSION_FUNCTION_NAME("windows.getAll") | |
| 54 }; | |
| 55 class CreateWindowFunction : public SyncExtensionFunction { | |
| 56 virtual ~CreateWindowFunction() {} | |
| 57 virtual bool RunImpl() OVERRIDE; | |
| 58 // Returns whether the window should be created in incognito mode. | |
| 59 // |urls| is the list of urls to open. If we are creating an incognito window, | |
| 60 // the function will remove these urls which may not be opened in incognito | |
| 61 // mode. If window creation leads the browser into an erroneous state, | |
| 62 // |is_error| is set to true (also, error_ member variable is assigned | |
| 63 // the proper error message). | |
| 64 bool ShouldOpenIncognitoWindow(const base::DictionaryValue* args, | |
| 65 std::vector<GURL>* urls, | |
| 66 bool* is_error); | |
| 67 DECLARE_EXTENSION_FUNCTION_NAME("windows.create") | |
| 68 }; | |
| 69 class UpdateWindowFunction : public SyncExtensionFunction { | |
| 70 virtual ~UpdateWindowFunction() {} | |
| 71 virtual bool RunImpl() OVERRIDE; | |
| 72 DECLARE_EXTENSION_FUNCTION_NAME("windows.update") | |
| 73 }; | |
| 74 class RemoveWindowFunction : public SyncExtensionFunction { | |
| 75 virtual ~RemoveWindowFunction() {} | |
| 76 virtual bool RunImpl() OVERRIDE; | |
| 77 DECLARE_EXTENSION_FUNCTION_NAME("windows.remove") | |
| 78 }; | |
| 79 | |
| 80 // Tabs | |
| 81 class GetTabFunction : public SyncExtensionFunction { | |
| 82 virtual ~GetTabFunction() {} | |
| 83 virtual bool RunImpl() OVERRIDE; | |
| 84 DECLARE_EXTENSION_FUNCTION_NAME("tabs.get") | |
| 85 }; | |
| 86 class GetCurrentTabFunction : public SyncExtensionFunction { | |
| 87 virtual ~GetCurrentTabFunction() {} | |
| 88 virtual bool RunImpl() OVERRIDE; | |
| 89 DECLARE_EXTENSION_FUNCTION_NAME("tabs.getCurrent") | |
| 90 }; | |
| 91 class GetSelectedTabFunction : public SyncExtensionFunction { | |
| 92 virtual ~GetSelectedTabFunction() {} | |
| 93 virtual bool RunImpl() OVERRIDE; | |
| 94 DECLARE_EXTENSION_FUNCTION_NAME("tabs.getSelected") | |
| 95 }; | |
| 96 class GetAllTabsInWindowFunction : public SyncExtensionFunction { | |
| 97 virtual ~GetAllTabsInWindowFunction() {} | |
| 98 virtual bool RunImpl() OVERRIDE; | |
| 99 DECLARE_EXTENSION_FUNCTION_NAME("tabs.getAllInWindow") | |
| 100 }; | |
| 101 class QueryTabsFunction : public SyncExtensionFunction { | |
| 102 virtual ~QueryTabsFunction() {} | |
| 103 virtual bool RunImpl() OVERRIDE; | |
| 104 DECLARE_EXTENSION_FUNCTION_NAME("tabs.query") | |
| 105 }; | |
| 106 class CreateTabFunction : public SyncExtensionFunction { | |
| 107 virtual ~CreateTabFunction() {} | |
| 108 virtual bool RunImpl() OVERRIDE; | |
| 109 DECLARE_EXTENSION_FUNCTION_NAME("tabs.create") | |
| 110 }; | |
| 111 class DuplicateTabFunction : public SyncExtensionFunction { | |
| 112 virtual ~DuplicateTabFunction() {} | |
| 113 virtual bool RunImpl() OVERRIDE; | |
| 114 DECLARE_EXTENSION_FUNCTION_NAME("tabs.duplicate") | |
| 115 }; | |
| 116 class HighlightTabsFunction : public SyncExtensionFunction { | |
| 117 virtual ~HighlightTabsFunction() {} | |
| 118 virtual bool RunImpl() OVERRIDE; | |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") | |
| 120 }; | |
| 121 class UpdateTabFunction : public AsyncExtensionFunction { | |
| 122 public: | |
| 123 UpdateTabFunction(); | |
| 124 | |
| 125 protected: | |
| 126 virtual ~UpdateTabFunction() {} | |
| 127 virtual bool UpdateURLIfPresent(base::DictionaryValue* update_props, | |
| 128 int tab_id, | |
| 129 bool* is_async); | |
| 130 virtual void PopulateResult(); | |
| 131 | |
| 132 content::WebContents* web_contents_; | |
| 133 | |
| 134 private: | |
| 135 virtual bool RunImpl() OVERRIDE; | |
| 136 void OnExecuteCodeFinished(const std::string& error, | |
| 137 int32 on_page_id, | |
| 138 const GURL& on_url, | |
| 139 const ListValue& script_result); | |
| 140 | |
| 141 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") | |
| 142 }; | |
| 143 class MoveTabsFunction : public SyncExtensionFunction { | |
| 144 virtual ~MoveTabsFunction() {} | |
| 145 virtual bool RunImpl() OVERRIDE; | |
| 146 DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") | |
| 147 }; | |
| 148 class ReloadTabFunction : public SyncExtensionFunction { | |
| 149 virtual ~ReloadTabFunction() {} | |
| 150 virtual bool RunImpl() OVERRIDE; | |
| 151 DECLARE_EXTENSION_FUNCTION_NAME("tabs.reload") | |
| 152 }; | |
| 153 class RemoveTabsFunction : public SyncExtensionFunction { | |
| 154 virtual ~RemoveTabsFunction() {} | |
| 155 virtual bool RunImpl() OVERRIDE; | |
| 156 DECLARE_EXTENSION_FUNCTION_NAME("tabs.remove") | |
| 157 }; | |
| 158 class DetectTabLanguageFunction : public AsyncExtensionFunction, | |
| 159 public content::NotificationObserver { | |
| 160 private: | |
| 161 virtual ~DetectTabLanguageFunction() {} | |
| 162 virtual bool RunImpl() OVERRIDE; | |
| 163 | |
| 164 virtual void Observe(int type, | |
| 165 const content::NotificationSource& source, | |
| 166 const content::NotificationDetails& details) OVERRIDE; | |
| 167 void GotLanguage(const std::string& language); | |
| 168 content::NotificationRegistrar registrar_; | |
| 169 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") | |
| 170 }; | |
| 171 class CaptureVisibleTabFunction : public AsyncExtensionFunction, | |
| 172 public content::NotificationObserver { | |
| 173 public: | |
| 174 static void RegisterUserPrefs(PrefServiceSyncable* service); | |
| 175 | |
| 176 protected: | |
| 177 enum ImageFormat { | |
| 178 FORMAT_JPEG, | |
| 179 FORMAT_PNG | |
| 180 }; | |
| 181 | |
| 182 // The default quality setting used when encoding jpegs. | |
| 183 static const int kDefaultQuality; | |
| 184 | |
| 185 virtual ~CaptureVisibleTabFunction() {} | |
| 186 virtual bool RunImpl() OVERRIDE; | |
| 187 virtual bool GetTabToCapture(content::WebContents** web_contents); | |
| 188 virtual void Observe(int type, | |
| 189 const content::NotificationSource& source, | |
| 190 const content::NotificationDetails& details) OVERRIDE; | |
| 191 void SendResultFromBitmap(const SkBitmap& screen_capture); | |
| 192 | |
| 193 private: | |
| 194 void CopyFromBackingStoreComplete(skia::PlatformBitmap* bitmap, | |
| 195 bool succeeded); | |
| 196 | |
| 197 content::NotificationRegistrar registrar_; | |
| 198 | |
| 199 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). | |
| 200 ImageFormat image_format_; | |
| 201 | |
| 202 // Quality setting to use when encoding jpegs. Set in RunImpl(). | |
| 203 int image_quality_; | |
| 204 | |
| 205 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") | |
| 206 }; | |
| 207 | |
| 208 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_H__ | |
| OLD | NEW |