| OLD | NEW |
| 1 // Copyright (c) 2011 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 | 24 |
| 22 namespace base { | 25 namespace base { |
| 23 class DictionaryValue; | 26 class DictionaryValue; |
| 24 } // namespace base | 27 } // namespace base |
| 25 | 28 |
| 29 namespace content { |
| 30 class WebContents; |
| 31 } // namespace content |
| 32 |
| 33 |
| 34 // TODO(jstritar): These helper methods are exposed so the offscreen tabs API |
| 35 // can use them. We should remove these once the APIs are combined. |
| 36 namespace extensions { |
| 37 namespace tabs_module { |
| 38 |
| 39 // Takes |url_string| and returns a GURL which is either valid and absolute |
| 40 // or invalid. If |url_string| is not directly interpretable as a valid (it is |
| 41 // likely a relative URL) an attempt is made to resolve it. |extension| is |
| 42 // provided so it can be resolved relative to its extension base |
| 43 // (chrome-extension://<id>/). Using the source frame url would be more correct, |
| 44 // but because the api shipped with urls resolved relative to their extension |
| 45 // base, we decided it wasn't worth breaking existing extensions to fix. |
| 46 GURL ResolvePossiblyRelativeURL(const std::string& url_string, |
| 47 const Extension* extension); |
| 48 |
| 49 // Returns true if |url| is used for testing crashes. |
| 50 bool IsCrashURL(const GURL& url); |
| 51 |
| 52 } // namespace tabs_module |
| 53 } // namespace extensions |
| 54 |
| 26 // Windows | 55 // Windows |
| 27 class GetWindowFunction : public SyncExtensionFunction { | 56 class GetWindowFunction : public SyncExtensionFunction { |
| 28 virtual ~GetWindowFunction() {} | 57 virtual ~GetWindowFunction() {} |
| 29 virtual bool RunImpl() OVERRIDE; | 58 virtual bool RunImpl() OVERRIDE; |
| 30 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") | 59 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") |
| 31 }; | 60 }; |
| 32 class GetCurrentWindowFunction : public SyncExtensionFunction { | 61 class GetCurrentWindowFunction : public SyncExtensionFunction { |
| 33 virtual ~GetCurrentWindowFunction() {} | 62 virtual ~GetCurrentWindowFunction() {} |
| 34 virtual bool RunImpl() OVERRIDE; | 63 virtual bool RunImpl() OVERRIDE; |
| 35 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") | 64 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 }; | 131 }; |
| 103 class HighlightTabsFunction : public SyncExtensionFunction { | 132 class HighlightTabsFunction : public SyncExtensionFunction { |
| 104 virtual ~HighlightTabsFunction() {} | 133 virtual ~HighlightTabsFunction() {} |
| 105 virtual bool RunImpl() OVERRIDE; | 134 virtual bool RunImpl() OVERRIDE; |
| 106 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") | 135 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") |
| 107 }; | 136 }; |
| 108 class UpdateTabFunction : public AsyncExtensionFunction, | 137 class UpdateTabFunction : public AsyncExtensionFunction, |
| 109 public content::WebContentsObserver { | 138 public content::WebContentsObserver { |
| 110 public: | 139 public: |
| 111 UpdateTabFunction(); | 140 UpdateTabFunction(); |
| 141 protected: |
| 142 virtual ~UpdateTabFunction() {} |
| 143 virtual bool UpdateURLIfPresent(base::DictionaryValue* update_props, |
| 144 content::WebContents* web_contents, |
| 145 bool* is_async); |
| 112 private: | 146 private: |
| 113 virtual ~UpdateTabFunction() {} | |
| 114 virtual bool RunImpl() OVERRIDE; | 147 virtual bool RunImpl() OVERRIDE; |
| 115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 148 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 116 void OnExecuteCodeFinished(int request_id, | 149 void OnExecuteCodeFinished(int request_id, |
| 117 bool success, | 150 bool success, |
| 118 const std::string& error); | 151 const std::string& error); |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") | 152 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") |
| 120 }; | 153 }; |
| 121 class MoveTabsFunction : public SyncExtensionFunction { | 154 class MoveTabsFunction : public SyncExtensionFunction { |
| 122 virtual ~MoveTabsFunction() {} | 155 virtual ~MoveTabsFunction() {} |
| 123 virtual bool RunImpl() OVERRIDE; | 156 virtual bool RunImpl() OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 141 | 174 |
| 142 virtual void Observe(int type, | 175 virtual void Observe(int type, |
| 143 const content::NotificationSource& source, | 176 const content::NotificationSource& source, |
| 144 const content::NotificationDetails& details) OVERRIDE; | 177 const content::NotificationDetails& details) OVERRIDE; |
| 145 void GotLanguage(const std::string& language); | 178 void GotLanguage(const std::string& language); |
| 146 content::NotificationRegistrar registrar_; | 179 content::NotificationRegistrar registrar_; |
| 147 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") | 180 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") |
| 148 }; | 181 }; |
| 149 class CaptureVisibleTabFunction : public AsyncExtensionFunction, | 182 class CaptureVisibleTabFunction : public AsyncExtensionFunction, |
| 150 public content::NotificationObserver { | 183 public content::NotificationObserver { |
| 151 private: | 184 protected: |
| 152 enum ImageFormat { | 185 enum ImageFormat { |
| 153 FORMAT_JPEG, | 186 FORMAT_JPEG, |
| 154 FORMAT_PNG | 187 FORMAT_PNG |
| 155 }; | 188 }; |
| 156 | 189 |
| 157 // The default quality setting used when encoding jpegs. | 190 // The default quality setting used when encoding jpegs. |
| 158 static const int kDefaultQuality; | 191 static const int kDefaultQuality; |
| 159 | 192 |
| 160 virtual ~CaptureVisibleTabFunction() {} | 193 virtual ~CaptureVisibleTabFunction() {} |
| 161 virtual bool RunImpl() OVERRIDE; | 194 virtual bool RunImpl() OVERRIDE; |
| 195 virtual bool GetTabToCapture(content::WebContents** web_contents, |
| 196 TabContentsWrapper** wrapper); |
| 162 virtual bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); | 197 virtual bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); |
| 163 virtual void Observe(int type, | 198 virtual void Observe(int type, |
| 164 const content::NotificationSource& source, | 199 const content::NotificationSource& source, |
| 165 const content::NotificationDetails& details) OVERRIDE; | 200 const content::NotificationDetails& details) OVERRIDE; |
| 166 virtual void SendResultFromBitmap(const SkBitmap& screen_capture); | 201 virtual void SendResultFromBitmap(const SkBitmap& screen_capture); |
| 167 | 202 |
| 168 content::NotificationRegistrar registrar_; | 203 content::NotificationRegistrar registrar_; |
| 169 | 204 |
| 170 // 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(). |
| 171 ImageFormat image_format_; | 206 ImageFormat image_format_; |
| 172 | 207 |
| 173 // Quality setting to use when encoding jpegs. Set in RunImpl(). | 208 // Quality setting to use when encoding jpegs. Set in RunImpl(). |
| 174 int image_quality_; | 209 int image_quality_; |
| 175 | 210 |
| 176 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") | 211 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") |
| 177 }; | 212 }; |
| 178 | 213 |
| 179 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ | 214 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ |
| OLD | NEW |