| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 WEBKIT_GLUE_WEBKIT_GLUE_H_ | 5 #ifndef WEBKIT_GLUE_WEBKIT_GLUE_H_ |
| 6 #define WEBKIT_GLUE_WEBKIT_GLUE_H_ | 6 #define WEBKIT_GLUE_WEBKIT_GLUE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include <windows.h> | 11 #include <windows.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 18 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
| 19 #include "base/string16.h" | 19 #include "base/string16.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
| 22 #include "webkit/glue/webkit_glue_export.h" |
| 22 | 23 |
| 23 class GURL; | 24 class GURL; |
| 24 class SkBitmap; | 25 class SkBitmap; |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 class StringPiece; | 28 class StringPiece; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace skia { | 31 namespace skia { |
| 31 class PlatformCanvas; | 32 class PlatformCanvas; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace WebKit { | 35 namespace WebKit { |
| 35 class WebFrame; | 36 class WebFrame; |
| 36 class WebString; | 37 class WebString; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace webkit_glue { | 40 namespace webkit_glue { |
| 40 | 41 |
| 41 void SetJavaScriptFlags(const std::string& flags); | 42 WEBKIT_GLUE_EXPORT void SetJavaScriptFlags(const std::string& flags); |
| 42 | 43 |
| 43 // Turn on logging for flags in the provided comma delimited list. | 44 // Turn on logging for flags in the provided comma delimited list. |
| 44 void EnableWebCoreLogChannels(const std::string& channels); | 45 WEBKIT_GLUE_EXPORT void EnableWebCoreLogChannels(const std::string& channels); |
| 45 | 46 |
| 46 // Returns the text of the document element. | 47 // Returns the text of the document element. |
| 47 string16 DumpDocumentText(WebKit::WebFrame* web_frame); | 48 WEBKIT_GLUE_EXPORT string16 DumpDocumentText(WebKit::WebFrame* web_frame); |
| 48 | 49 |
| 49 // Returns the text of the document element and optionally its child frames. | 50 // Returns the text of the document element and optionally its child frames. |
| 50 // If recursive is false, this is equivalent to DumpDocumentText followed by | 51 // If recursive is false, this is equivalent to DumpDocumentText followed by |
| 51 // a newline. If recursive is true, it recursively dumps all frames as text. | 52 // a newline. If recursive is true, it recursively dumps all frames as text. |
| 52 string16 DumpFramesAsText(WebKit::WebFrame* web_frame, bool recursive); | 53 string16 DumpFramesAsText(WebKit::WebFrame* web_frame, bool recursive); |
| 53 | 54 |
| 54 // Returns the renderer's description of its tree (its externalRepresentation). | 55 // Returns the renderer's description of its tree (its externalRepresentation). |
| 55 string16 DumpRenderer(WebKit::WebFrame* web_frame); | 56 WEBKIT_GLUE_EXPORT string16 DumpRenderer(WebKit::WebFrame* web_frame); |
| 56 | 57 |
| 57 // Fill the value of counter in the element specified by the id into | 58 // Fill the value of counter in the element specified by the id into |
| 58 // counter_value. Return false when the specified id doesn't exist. | 59 // counter_value. Return false when the specified id doesn't exist. |
| 59 bool CounterValueForElementById(WebKit::WebFrame* web_frame, | 60 bool CounterValueForElementById(WebKit::WebFrame* web_frame, |
| 60 const std::string& id, | 61 const std::string& id, |
| 61 string16* counter_value); | 62 string16* counter_value); |
| 62 | 63 |
| 63 // Returns the number of page where the specified element will be put. | 64 // Returns the number of page where the specified element will be put. |
| 64 int PageNumberForElementById(WebKit::WebFrame* web_frame, | 65 int PageNumberForElementById(WebKit::WebFrame* web_frame, |
| 65 const std::string& id, | 66 const std::string& id, |
| 66 float page_width_in_pixels, | 67 float page_width_in_pixels, |
| 67 float page_height_in_pixels); | 68 float page_height_in_pixels); |
| 68 | 69 |
| 69 // Returns the number of pages to be printed. | 70 // Returns the number of pages to be printed. |
| 70 int NumberOfPages(WebKit::WebFrame* web_frame, | 71 int NumberOfPages(WebKit::WebFrame* web_frame, |
| 71 float page_width_in_pixels, | 72 float page_width_in_pixels, |
| 72 float page_height_in_pixels); | 73 float page_height_in_pixels); |
| 73 | 74 |
| 74 // Returns a dump of the scroll position of the webframe. | 75 // Returns a dump of the scroll position of the webframe. |
| 75 string16 DumpFrameScrollPosition(WebKit::WebFrame* web_frame, bool recursive); | 76 string16 DumpFrameScrollPosition(WebKit::WebFrame* web_frame, bool recursive); |
| 76 | 77 |
| 77 // Returns a dump of the given history state suitable for implementing the | 78 // Returns a dump of the given history state suitable for implementing the |
| 78 // dumpBackForwardList command of the layoutTestController. | 79 // dumpBackForwardList command of the layoutTestController. |
| 79 string16 DumpHistoryState(const std::string& history_state, int indent, | 80 WEBKIT_GLUE_EXPORT string16 DumpHistoryState(const std::string& history_state, |
| 80 bool is_current); | 81 int indent, |
| 82 bool is_current); |
| 81 | 83 |
| 82 // Sets the user agent. Pass true for overriding if this is a custom | 84 // Sets the user agent. Pass true for overriding if this is a custom |
| 83 // user agent instead of the default one (in order to turn off any browser | 85 // user agent instead of the default one (in order to turn off any browser |
| 84 // sniffing workarounds). This must be called before GetUserAgent() can | 86 // sniffing workarounds). This must be called before GetUserAgent() can |
| 85 // be called. | 87 // be called. |
| 86 void SetUserAgent(const std::string& user_agent, bool overriding); | 88 WEBKIT_GLUE_EXPORT void SetUserAgent(const std::string& user_agent, |
| 89 bool overriding); |
| 87 | 90 |
| 88 // Returns the user agent to use for the given URL. SetUserAgent() must | 91 // Returns the user agent to use for the given URL. SetUserAgent() must |
| 89 // be called prior to calling this function. | 92 // be called prior to calling this function. |
| 90 const std::string& GetUserAgent(const GURL& url); | 93 WEBKIT_GLUE_EXPORT const std::string& GetUserAgent(const GURL& url); |
| 91 | 94 |
| 92 // Creates serialized state for the specified URL. This is a variant of | 95 // Creates serialized state for the specified URL. This is a variant of |
| 93 // HistoryItemToString (in glue_serialize) that is used during session restore | 96 // HistoryItemToString (in glue_serialize) that is used during session restore |
| 94 // if the saved state is empty. | 97 // if the saved state is empty. |
| 95 std::string CreateHistoryStateForURL(const GURL& url); | 98 WEBKIT_GLUE_EXPORT std::string CreateHistoryStateForURL(const GURL& url); |
| 96 | 99 |
| 97 // Removes any form data state from the history state string |content_state|. | 100 // Removes any form data state from the history state string |content_state|. |
| 98 std::string RemoveFormDataFromHistoryState(const std::string& content_state); | 101 WEBKIT_GLUE_EXPORT std::string RemoveFormDataFromHistoryState( |
| 102 const std::string& content_state); |
| 99 | 103 |
| 100 // Removes scroll offset from the history state string |content_state|. | 104 // Removes scroll offset from the history state string |content_state|. |
| 101 std::string RemoveScrollOffsetFromHistoryState( | 105 WEBKIT_GLUE_EXPORT std::string RemoveScrollOffsetFromHistoryState( |
| 102 const std::string& content_state); | 106 const std::string& content_state); |
| 103 | 107 |
| 104 #ifndef NDEBUG | 108 #ifndef NDEBUG |
| 105 // Checks various important objects to see if there are any in memory, and | 109 // Checks various important objects to see if there are any in memory, and |
| 106 // calls AppendToLog with any leaked objects. Designed to be called on | 110 // calls AppendToLog with any leaked objects. Designed to be called on |
| 107 // shutdown. | 111 // shutdown. |
| 108 void CheckForLeaks(); | 112 WEBKIT_GLUE_EXPORT void CheckForLeaks(); |
| 109 #endif | 113 #endif |
| 110 | 114 |
| 111 // Decodes the image from the data in |image_data| into |image|. | 115 // Decodes the image from the data in |image_data| into |image|. |
| 112 // Returns false if the image could not be decoded. | 116 // Returns false if the image could not be decoded. |
| 113 bool DecodeImage(const std::string& image_data, SkBitmap* image); | 117 WEBKIT_GLUE_EXPORT bool DecodeImage(const std::string& image_data, |
| 118 SkBitmap* image); |
| 114 | 119 |
| 115 // Tells the plugin thread to terminate the process forcefully instead of | 120 // Tells the plugin thread to terminate the process forcefully instead of |
| 116 // exiting cleanly. | 121 // exiting cleanly. |
| 117 void SetForcefullyTerminatePluginProcess(bool value); | 122 void SetForcefullyTerminatePluginProcess(bool value); |
| 118 | 123 |
| 119 // Returns true if the plugin thread should terminate the process forcefully | 124 // Returns true if the plugin thread should terminate the process forcefully |
| 120 // instead of exiting cleanly. | 125 // instead of exiting cleanly. |
| 121 bool ShouldForcefullyTerminatePluginProcess(); | 126 WEBKIT_GLUE_EXPORT bool ShouldForcefullyTerminatePluginProcess(); |
| 122 | 127 |
| 123 // File path string conversions. | 128 // File path string conversions. |
| 124 FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str); | 129 WEBKIT_GLUE_EXPORT FilePath::StringType WebStringToFilePathString( |
| 125 WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str); | 130 const WebKit::WebString& str); |
| 126 FilePath WebStringToFilePath(const WebKit::WebString& str); | 131 WEBKIT_GLUE_EXPORT WebKit::WebString FilePathStringToWebString( |
| 127 WebKit::WebString FilePathToWebString(const FilePath& file_path); | 132 const FilePath::StringType& str); |
| 133 WEBKIT_GLUE_EXPORT FilePath WebStringToFilePath(const WebKit::WebString& str); |
| 134 WEBKIT_GLUE_EXPORT WebKit::WebString FilePathToWebString( |
| 135 const FilePath& file_path); |
| 128 | 136 |
| 129 // File error conversion | 137 // File error conversion |
| 130 WebKit::WebFileError PlatformFileErrorToWebFileError( | 138 WEBKIT_GLUE_EXPORT WebKit::WebFileError PlatformFileErrorToWebFileError( |
| 131 base::PlatformFileError error_code); | 139 base::PlatformFileError error_code); |
| 132 | 140 |
| 133 // Returns a WebCanvas pointer associated with the given Skia canvas. | 141 // Returns a WebCanvas pointer associated with the given Skia canvas. |
| 134 WebKit::WebCanvas* ToWebCanvas(skia::PlatformCanvas*); | 142 WEBKIT_GLUE_EXPORT WebKit::WebCanvas* ToWebCanvas(skia::PlatformCanvas*); |
| 135 | 143 |
| 136 // Returns the number of currently-active glyph pages this process is using. | 144 // Returns the number of currently-active glyph pages this process is using. |
| 137 // There can be many such pages (maps of 256 character -> glyph) so this is | 145 // There can be many such pages (maps of 256 character -> glyph) so this is |
| 138 // used to get memory usage statistics. | 146 // used to get memory usage statistics. |
| 139 int GetGlyphPageCount(); | 147 WEBKIT_GLUE_EXPORT int GetGlyphPageCount(); |
| 140 | 148 |
| 141 // Returns WebKit Web Inspector protocol version. | 149 // Returns WebKit Web Inspector protocol version. |
| 142 std::string GetInspectorProtocolVersion(); | 150 std::string GetInspectorProtocolVersion(); |
| 143 | 151 |
| 144 // Tells caller whether the given protocol version is supported by the. | 152 // Tells caller whether the given protocol version is supported by the. |
| 145 bool IsInspectorProtocolVersionSupported(const std::string& version); | 153 WEBKIT_GLUE_EXPORT bool IsInspectorProtocolVersionSupported( |
| 154 const std::string& version); |
| 146 | 155 |
| 147 } // namespace webkit_glue | 156 } // namespace webkit_glue |
| 148 | 157 |
| 149 #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_ | 158 #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_ |
| OLD | NEW |