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.
5 #ifndef WEBKIT_GLUE_WEBKIT_GLUE_H_
6 #define WEBKIT_GLUE_WEBKIT_GLUE_H_
8 #include "base/basictypes.h"
17 #include "base/platform_file.h"
18 #include "base/string16.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h"
21 #include "webkit/glue/webkit_glue_export.h"
35 namespace webkit_glue
{
37 WEBKIT_GLUE_EXPORT
void SetJavaScriptFlags(const std::string
& flags
);
39 // Turn on logging for flags in the provided comma delimited list.
40 WEBKIT_GLUE_EXPORT
void EnableWebCoreLogChannels(const std::string
& channels
);
42 // Returns the text of the document element.
43 WEBKIT_GLUE_EXPORT
base::string16
DumpDocumentText(WebKit::WebFrame
* web_frame
);
45 // Returns the text of the document element and optionally its child frames.
46 // If recursive is false, this is equivalent to DumpDocumentText followed by
47 // a newline. If recursive is true, it recursively dumps all frames as text.
48 base::string16
DumpFramesAsText(WebKit::WebFrame
* web_frame
, bool recursive
);
50 // Returns the renderer's description of its tree (its externalRepresentation).
51 WEBKIT_GLUE_EXPORT
base::string16
DumpRenderer(WebKit::WebFrame
* web_frame
);
53 // Returns the number of page where the specified element will be put.
54 int PageNumberForElementById(WebKit::WebFrame
* web_frame
,
55 const std::string
& id
,
56 float page_width_in_pixels
,
57 float page_height_in_pixels
);
59 // Returns the number of pages to be printed.
60 int NumberOfPages(WebKit::WebFrame
* web_frame
,
61 float page_width_in_pixels
,
62 float page_height_in_pixels
);
64 // Returns a dump of the scroll position of the webframe.
65 base::string16
DumpFrameScrollPosition(WebKit::WebFrame
* web_frame
,
68 // Returns a dump of the given history state suitable for implementing the
69 // dumpBackForwardList command of the testRunner.
70 WEBKIT_GLUE_EXPORT
base::string16
DumpHistoryState(
71 const std::string
& history_state
,
76 // Checks various important objects to see if there are any in memory, and
77 // calls AppendToLog with any leaked objects. Designed to be called on
79 WEBKIT_GLUE_EXPORT
void CheckForLeaks();
82 // Decodes the image from the data in |image_data| into |image|.
83 // Returns false if the image could not be decoded.
84 WEBKIT_GLUE_EXPORT
bool DecodeImage(const std::string
& image_data
,
87 // Tells the plugin thread to terminate the process forcefully instead of
89 void SetForcefullyTerminatePluginProcess(bool value
);
91 // Returns true if the plugin thread should terminate the process forcefully
92 // instead of exiting cleanly.
93 WEBKIT_GLUE_EXPORT
bool ShouldForcefullyTerminatePluginProcess();
95 // File info conversion
96 WEBKIT_GLUE_EXPORT
void PlatformFileInfoToWebFileInfo(
97 const base::PlatformFileInfo
& file_info
,
98 WebKit::WebFileInfo
* web_file_info
);
100 // Returns a WebCanvas pointer associated with the given Skia canvas.
101 WEBKIT_GLUE_EXPORT
WebKit::WebCanvas
* ToWebCanvas(SkCanvas
*);
103 // Returns the number of currently-active glyph pages this process is using.
104 // There can be many such pages (maps of 256 character -> glyph) so this is
105 // used to get memory usage statistics.
106 WEBKIT_GLUE_EXPORT
int GetGlyphPageCount();
108 // Returns WebKit Web Inspector protocol version.
109 std::string
GetInspectorProtocolVersion();
111 // Tells caller whether the given protocol version is supported by the.
112 WEBKIT_GLUE_EXPORT
bool IsInspectorProtocolVersionSupported(
113 const std::string
& version
);
115 // Configures the URLRequest according to the referrer policy.
116 WEBKIT_GLUE_EXPORT
void ConfigureURLRequestForReferrerPolicy(
117 net::URLRequest
* request
, WebKit::WebReferrerPolicy referrer_policy
);
119 // Returns an estimate of the memory usage of the renderer process. Different
120 // platforms implement this function differently, and count in different
121 // allocations. Results are not comparable across platforms. The estimate is
122 // computed inside the sandbox and thus its not always accurate.
123 WEBKIT_GLUE_EXPORT
size_t MemoryUsageKB();
125 // Converts from zoom factor (zoom percent / 100) to zoom level, where 0 means
126 // no zoom, positive numbers mean zoom in, negatives mean zoom out.
127 WEBKIT_GLUE_EXPORT
double ZoomFactorToZoomLevel(double factor
);
129 } // namespace webkit_glue
131 #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_