1513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef WEBKIT_GLUE_WEBKIT_GLUE_H_
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define WEBKIT_GLUE_WEBKIT_GLUE_H_
7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/basictypes.h"
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN)
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <windows.h>
12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string>
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <vector>
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/file_path.h"
183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "base/platform_file.h"
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/string16.h"
2072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h"
2172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h"
2272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "ui/base/clipboard/clipboard.h"
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass GURL;
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass SkBitmap;
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace base {
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass StringPiece;
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace skia {
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass PlatformCanvas;
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace WebKit {
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass WebFrame;
37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass WebString;
38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass WebView;
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
4121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsennamespace webkit {
4221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsennamespace npapi {
4321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstruct WebPluginInfo;
4421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen}
4521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen}
4621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace webkit_glue {
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//---- BEGIN FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE -----------------------------
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
523345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickvoid SetJavaScriptFlags(const std::string& flags);
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Turn on logging for flags in the provided comma delimited list.
55dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenvoid EnableWebCoreLogChannels(const std::string& channels);
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the text of the document element.
5821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstring16 DumpDocumentText(WebKit::WebFrame* web_frame);
59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the text of the document element and optionally its child frames.
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// If recursive is false, this is equivalent to DumpDocumentText followed by
62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// a newline.  If recursive is true, it recursively dumps all frames as text.
6321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstring16 DumpFramesAsText(WebKit::WebFrame* web_frame, bool recursive);
64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the renderer's description of its tree (its externalRepresentation).
6621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstring16 DumpRenderer(WebKit::WebFrame* web_frame);
67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Fill the value of counter in the element specified by the id into
69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// counter_value.  Return false when the specified id doesn't exist.
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool CounterValueForElementById(WebKit::WebFrame* web_frame,
71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                const std::string& id,
7221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                                string16* counter_value);
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the number of page where the specified element will be put.
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochint PageNumberForElementById(WebKit::WebFrame* web_frame,
76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             const std::string& id,
77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             float page_width_in_pixels,
78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             float page_height_in_pixels);
79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the number of pages to be printed.
81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochint NumberOfPages(WebKit::WebFrame* web_frame,
82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                  float page_width_in_pixels,
83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                  float page_height_in_pixels);
84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns a dump of the scroll position of the webframe.
8621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstring16 DumpFrameScrollPosition(WebKit::WebFrame* web_frame, bool recursive);
87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns a dump of the given history state suitable for implementing the
89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// dumpBackForwardList command of the layoutTestController.
9021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstring16 DumpHistoryState(const std::string& history_state, int indent,
9121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                          bool is_current);
92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the WebKit version (major.minor).
94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstd::string GetWebKitVersion();
95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to override the default user agent with a custom one.  Call this
97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// before anyone actually asks for the user agent in order to prevent
98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// inconsistent behavior.
99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid SetUserAgent(const std::string& new_user_agent);
100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the user agent to use for the given URL, which is usually the
102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// default user agent but may be overriden by a call to SetUserAgent() (which
103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// should be done at startup).
104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochconst std::string& GetUserAgent(const GURL& url);
105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Creates serialized state for the specified URL. This is a variant of
107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// HistoryItemToString (in glue_serialize) that is used during session restore
108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// if the saved state is empty.
109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstd::string CreateHistoryStateForURL(const GURL& url);
110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Removes any form data state from the history state string |content_state|.
112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstd::string RemoveFormDataFromHistoryState(const std::string& content_state);
113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen// Removes scroll offset from the history state string |content_state|.
11521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenstd::string RemoveScrollOffsetFromHistoryState(
11621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen    const std::string& content_state);
11721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef NDEBUG
119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Checks various important objects to see if there are any in memory, and
120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// calls AppendToLog with any leaked objects. Designed to be called on shutdown
121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CheckForLeaks();
122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Decodes the image from the data in |image_data| into |image|.
125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns false if the image could not be decoded.
126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool DecodeImage(const std::string& image_data, SkBitmap* image);
127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Tells the plugin thread to terminate the process forcefully instead of
129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// exiting cleanly.
130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid SetForcefullyTerminatePluginProcess(bool value);
131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if the plugin thread should terminate the process forcefully
133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// instead of exiting cleanly.
134c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool ShouldForcefullyTerminatePluginProcess();
135c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// File path string conversions.
137c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochFilePath::StringType WebStringToFilePathString(const WebKit::WebString& str);
138c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochWebKit::WebString FilePathStringToWebString(const FilePath::StringType& str);
139c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochFilePath WebStringToFilePath(const WebKit::WebString& str);
140c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochWebKit::WebString FilePathToWebString(const FilePath& file_path);
141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
1423345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// File error conversion
1433345a6884c488ff3a535c2c9acdd33d74b37e311Iain MerrickWebKit::WebFileError PlatformFileErrorToWebFileError(
1443345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    base::PlatformFileError error_code);
1453345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns a WebCanvas pointer associated with the given Skia canvas.
147c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochWebKit::WebCanvas* ToWebCanvas(skia::PlatformCanvas*);
148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the number of currently-active glyph pages this process is using.
150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// There can be many such pages (maps of 256 character -> glyph) so this is
151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// used to get memory usage statistics.
152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochint GetGlyphPageCount();
153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//---- END FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE -------------------------------
155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//---- BEGIN FUNCTIONS IMPLEMENTED BY EMBEDDER --------------------------------
158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// This function is called to add a line to the application's log file.
160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid AppendToLog(const char* filename, int line, const char* message);
161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Glue to get resources from the embedder.
163c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
164c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets a localized string given a message id.  Returns an empty string if the
165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// message id is not found.
166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstring16 GetLocalizedString(int message_id);
167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the raw data for a resource.  This resource must have been
169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// specified as BINDATA in the relevant .rc file.
170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbase::StringPiece GetDataResource(int resource_id);
171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN)
173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Loads and returns a cursor.
174c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochHCURSOR LoadCursor(int cursor_id);
175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
176c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Glue to access the clipboard.
178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Get a clipboard that can be used to construct a ScopedClipboardWriterGlue.
18072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenui::Clipboard* ClipboardGetClipboard();
181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Tests whether the clipboard contains a certain format
18372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenbool ClipboardIsFormatAvailable(const ui::Clipboard::FormatType& format,
18472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                ui::Clipboard::Buffer buffer);
185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
186ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Reads the available types from the clipboard, if available.
187ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
188ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                 std::vector<string16>* types,
189ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                 bool* contains_filenames);
190ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Reads UNICODE text from the clipboard, if available.
19272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenvoid ClipboardReadText(ui::Clipboard::Buffer buffer, string16* result);
193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
194c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Reads ASCII text from the clipboard, if available.
19572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenvoid ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result);
196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Reads HTML from the clipboard, if available.
19872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenvoid ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup,
19972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                       GURL* url);
200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
201ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data);
202c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Reads one type of data from the clipboard, if available.
20472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenbool ClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type,
205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       string16* data, string16* metadata);
206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Reads filenames from the clipboard, if available.
20872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenbool ClipboardReadFilenames(ui::Clipboard::Buffer buffer,
209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                            std::vector<string16>* filenames);
210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets the directory where the application data and libraries exist.  This
212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// may be a versioned subdirectory, or it may be the same directory as the
213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// GetExeDirectory(), depending on the embedder's implementation.
214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Path is an output parameter to receive the path.
215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if successful, false otherwise.
216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool GetApplicationDirectory(FilePath* path);
217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
218c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets the directory where the launching executable resides on disk.
219c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Path is an output parameter to receive the path.
220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if successful, false otherwise.
221c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool GetExeDirectory(FilePath* path);
222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Embedders implement this function to return the list of plugins to Webkit.
22421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenvoid GetPlugins(bool refresh,
22521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                std::vector<webkit::npapi::WebPluginInfo>* plugins);
226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if the plugins run in the same process as the renderer, and
228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// false otherwise.
229c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool IsPluginRunningInRendererProcess();
230c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
231c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns a bool indicating if the Null plugin should be enabled or not.
232c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool IsDefaultPluginEnabled();
233c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
234c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if the protocol implemented to serve |url| supports features
235c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// required by the media engine.
236c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool IsProtocolSupportedForMedia(const GURL& url);
237c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
238c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN)
239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Downloads the file specified by the URL. On sucess a WM_COPYDATA message
240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// will be sent to the caller_window.
241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool DownloadUrl(const std::string& url, HWND caller_window);
242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the plugin finder URL.
245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool GetPluginFinderURL(std::string* plugin_finder_url);
246c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Resolves the proxies for the url, returns true on success.
248c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool FindProxyForUrl(const GURL& url, std::string* proxy_list);
249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the locale that this instance of webkit is running as.  This is of
251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the form language-country (e.g., en-US or pt-BR).
2523345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstd::string GetWebKitLocale();
253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Close current connections.  Used for debugging.
255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid CloseCurrentConnections();
256c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Enable or disable the disk cache.  Used for debugging.
258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid SetCacheMode(bool enabled);
259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
260c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Clear the disk cache.  Used for debugging.
261dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// |preserve_ssl_host_info| indicates whether disk cache entries related to
262dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// SSL information should be purged.
263dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenvoid ClearCache(bool preserve_ssl_host_info);
264c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
265ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Clear the host resolver cache.  Used for debugging.
266ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid ClearHostResolverCache();
267ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
268ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Clear the predictor cache (for DNS prefetch and preconnect).  Used for
269ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// debugging.
270ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid ClearPredictorCache();
271ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the product version.  E.g., Chrome/4.1.333.0
273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstd::string GetProductVersion();
274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns true if the embedder is running in single process mode.
276c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool IsSingleProcess();
277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
2783345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Enables/Disables Spdy for requests afterwards. Used for benchmarking.
2793345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickvoid EnableSpdy(bool enable);
2803345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
281513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch// Notifies the browser that the given action has been performed.
282513209b27ff55e2841eac0e4120199c23acce758Ben Murdochvoid UserMetricsRecordAction(const std::string& action);
283513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
28421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#if !defined(DISABLE_NACL)
28521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen// Launch NaCl's sel_ldr process.
28621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenbool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles,
28721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                  void* nacl_process_handle, int* nacl_process_id);
28821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#endif
28921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_LINUX)
291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Return a read-only file descriptor to the font which best matches the given
292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// properties or -1 on failure.
293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   charset: specifies the language(s) that the font must cover. See
294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// render_sandbox_host_linux.cc for more information.
295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochint MatchFontWithFallback(const std::string& face, bool bold,
296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                          bool italic, int charset);
297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// GetFontTable loads a specified font table from an open SFNT file.
299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   fd: a file descriptor to the SFNT file. The position doesn't matter.
300c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   table: the table in *big-endian* format, or 0 for the whole font file.
301c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   output: a buffer of size output_length that gets the data.  can be 0, in
302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//     which case output_length will be set to the required size in bytes.
303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   output_length: size of output, if it's not 0.
304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   returns: true on success.
306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochbool GetFontTable(int fd, uint32_t table, uint8_t* output,
307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                  size_t* output_length);
308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// ---- END FUNCTIONS IMPLEMENTED BY EMBEDDER ---------------------------------
311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
313c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} // namespace webkit_glue
314c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif  // WEBKIT_GLUE_WEBKIT_GLUE_H_
316