| 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_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; | |
| 22 class SkBitmap; | 20 class SkBitmap; |
| 23 class TabContentsWrapper; | |
| 24 namespace base { | 21 namespace base { |
| 25 class DictionaryValue; | 22 class DictionaryValue; |
| 26 } // namespace base | 23 } // namespace base |
| 27 namespace content { | 24 namespace content { |
| 28 class WebContents; | 25 class WebContents; |
| 29 } // namespace content | 26 } // namespace content |
| 30 | |
| 31 // Windows | 27 // Windows |
| 32 class GetWindowFunction : public SyncExtensionFunction { | 28 class GetWindowFunction : public SyncExtensionFunction { |
| 33 virtual ~GetWindowFunction() {} | 29 virtual ~GetWindowFunction() {} |
| 34 virtual bool RunImpl() OVERRIDE; | 30 virtual bool RunImpl() OVERRIDE; |
| 35 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") | 31 DECLARE_EXTENSION_FUNCTION_NAME("windows.get") |
| 36 }; | 32 }; |
| 37 class GetCurrentWindowFunction : public SyncExtensionFunction { | 33 class GetCurrentWindowFunction : public SyncExtensionFunction { |
| 38 virtual ~GetCurrentWindowFunction() {} | 34 virtual ~GetCurrentWindowFunction() {} |
| 39 virtual bool RunImpl() OVERRIDE; | 35 virtual bool RunImpl() OVERRIDE; |
| 40 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") | 36 DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 }; | 103 }; |
| 108 class HighlightTabsFunction : public SyncExtensionFunction { | 104 class HighlightTabsFunction : public SyncExtensionFunction { |
| 109 virtual ~HighlightTabsFunction() {} | 105 virtual ~HighlightTabsFunction() {} |
| 110 virtual bool RunImpl() OVERRIDE; | 106 virtual bool RunImpl() OVERRIDE; |
| 111 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") | 107 DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") |
| 112 }; | 108 }; |
| 113 class UpdateTabFunction : public AsyncExtensionFunction, | 109 class UpdateTabFunction : public AsyncExtensionFunction, |
| 114 public content::WebContentsObserver { | 110 public content::WebContentsObserver { |
| 115 public: | 111 public: |
| 116 UpdateTabFunction(); | 112 UpdateTabFunction(); |
| 117 | 113 private: |
| 118 protected: | |
| 119 virtual ~UpdateTabFunction() {} | 114 virtual ~UpdateTabFunction() {} |
| 120 virtual bool UpdateURLIfPresent(base::DictionaryValue* update_props, | |
| 121 bool* is_async); | |
| 122 virtual void PopulateResult(); | |
| 123 | |
| 124 content::WebContents* web_contents_; | |
| 125 | |
| 126 private: | |
| 127 virtual bool RunImpl() OVERRIDE; | 115 virtual bool RunImpl() OVERRIDE; |
| 128 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | 116 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
| 129 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 117 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 130 void OnExecuteCodeFinished(int request_id, | 118 void OnExecuteCodeFinished(int request_id, |
| 131 bool success, | 119 bool success, |
| 132 const std::string& error); | 120 const std::string& error); |
| 121 void PopulateResult(); |
| 133 | 122 |
| 123 content::WebContents* web_contents_; |
| 134 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") | 124 DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") |
| 135 }; | 125 }; |
| 136 class MoveTabsFunction : public SyncExtensionFunction { | 126 class MoveTabsFunction : public SyncExtensionFunction { |
| 137 virtual ~MoveTabsFunction() {} | 127 virtual ~MoveTabsFunction() {} |
| 138 virtual bool RunImpl() OVERRIDE; | 128 virtual bool RunImpl() OVERRIDE; |
| 139 DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") | 129 DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") |
| 140 }; | 130 }; |
| 141 class ReloadTabFunction : public SyncExtensionFunction { | 131 class ReloadTabFunction : public SyncExtensionFunction { |
| 142 virtual ~ReloadTabFunction() {} | 132 virtual ~ReloadTabFunction() {} |
| 143 virtual bool RunImpl() OVERRIDE; | 133 virtual bool RunImpl() OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 156 | 146 |
| 157 virtual void Observe(int type, | 147 virtual void Observe(int type, |
| 158 const content::NotificationSource& source, | 148 const content::NotificationSource& source, |
| 159 const content::NotificationDetails& details) OVERRIDE; | 149 const content::NotificationDetails& details) OVERRIDE; |
| 160 void GotLanguage(const std::string& language); | 150 void GotLanguage(const std::string& language); |
| 161 content::NotificationRegistrar registrar_; | 151 content::NotificationRegistrar registrar_; |
| 162 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") | 152 DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") |
| 163 }; | 153 }; |
| 164 class CaptureVisibleTabFunction : public AsyncExtensionFunction, | 154 class CaptureVisibleTabFunction : public AsyncExtensionFunction, |
| 165 public content::NotificationObserver { | 155 public content::NotificationObserver { |
| 166 protected: | 156 private: |
| 167 enum ImageFormat { | 157 enum ImageFormat { |
| 168 FORMAT_JPEG, | 158 FORMAT_JPEG, |
| 169 FORMAT_PNG | 159 FORMAT_PNG |
| 170 }; | 160 }; |
| 171 | 161 |
| 172 // The default quality setting used when encoding jpegs. | 162 // The default quality setting used when encoding jpegs. |
| 173 static const int kDefaultQuality; | 163 static const int kDefaultQuality; |
| 174 | 164 |
| 175 virtual ~CaptureVisibleTabFunction() {} | 165 virtual ~CaptureVisibleTabFunction() {} |
| 176 virtual bool RunImpl() OVERRIDE; | 166 virtual bool RunImpl() OVERRIDE; |
| 177 virtual bool GetTabToCapture(content::WebContents** web_contents, | |
| 178 TabContentsWrapper** wrapper); | |
| 179 virtual void Observe(int type, | 167 virtual void Observe(int type, |
| 180 const content::NotificationSource& source, | 168 const content::NotificationSource& source, |
| 181 const content::NotificationDetails& details) OVERRIDE; | 169 const content::NotificationDetails& details) OVERRIDE; |
| 170 bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); |
| 182 void SendResultFromBitmap(const SkBitmap& screen_capture); | 171 void SendResultFromBitmap(const SkBitmap& screen_capture); |
| 183 | 172 |
| 184 content::NotificationRegistrar registrar_; | 173 content::NotificationRegistrar registrar_; |
| 185 | 174 |
| 186 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). | 175 // The format (JPEG vs PNG) of the resulting image. Set in RunImpl(). |
| 187 ImageFormat image_format_; | 176 ImageFormat image_format_; |
| 188 | 177 |
| 189 // Quality setting to use when encoding jpegs. Set in RunImpl(). | 178 // Quality setting to use when encoding jpegs. Set in RunImpl(). |
| 190 int image_quality_; | 179 int image_quality_; |
| 191 | 180 |
| 192 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") | 181 DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") |
| 193 }; | 182 }; |
| 194 | 183 |
| 195 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ | 184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TABS_MODULE_H__ |
| OLD | NEW |