2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef ChromiumBridge_h
32 #define ChromiumBridge_h
34 #include "FileSystem.h"
36 #include "PassRefPtr.h"
37 #include "PasteboardPrivate.h"
39 class NativeImageSkia;
41 typedef struct NPObject NPObject;
42 typedef struct _NPP NPP_t;
46 typedef struct HFONT__* HFONT;
55 class GraphicsContext;
64 // An interface to the embedding layer, which has the ability to answer
65 // questions about the system and so on...
67 class ChromiumBridge {
69 // Clipboard ----------------------------------------------------------
70 static bool clipboardIsFormatAvailable(PasteboardPrivate::ClipboardFormat);
72 static String clipboardReadPlainText();
73 static void clipboardReadHTML(String*, KURL*);
75 static void clipboardWriteSelection(const String&, const KURL&, const String&, bool);
76 static void clipboardWriteURL(const KURL&, const String&);
77 static void clipboardWriteImage(const NativeImageSkia*, const KURL&, const String&);
79 // Cookies ------------------------------------------------------------
80 static void setCookies(const KURL& url, const KURL& firstPartyForCookies, const String& value);
81 static String cookies(const KURL& url, const KURL& firstPartyForCookies);
83 // DNS ----------------------------------------------------------------
84 static void prefetchDNS(const String& hostname);
86 // File ---------------------------------------------------------------
87 static bool getFileSize(const String& path, long long& result);
89 // Font ---------------------------------------------------------------
91 static bool ensureFontLoaded(HFONT font);
94 static String getFontFamilyForCharacters(const UChar*, size_t numCharacters);
97 // Forms --------------------------------------------------------------
98 static void notifyFormStateChanged(const Document*);
100 // JavaScript ---------------------------------------------------------
101 static void notifyJSOutOfMemory(Frame*);
102 static bool allowScriptDespiteSettings(const KURL& documentURL);
104 // Language -----------------------------------------------------------
105 static String computedDefaultLanguage();
107 // LayoutTestMode -----------------------------------------------------
108 static bool layoutTestMode();
110 // MimeType -----------------------------------------------------------
111 static bool isSupportedImageMIMEType(const String& mimeType);
112 static bool isSupportedJavaScriptMIMEType(const String& mimeType);
113 static bool isSupportedNonImageMIMEType(const String& mimeType);
114 static String mimeTypeForExtension(const String& fileExtension);
115 static String mimeTypeFromFile(const String& filePath);
116 static String preferredExtensionForMIMEType(const String& mimeType);
118 // Plugin -------------------------------------------------------------
119 static bool plugins(bool refresh, Vector<PluginInfo*>*);
120 static NPObject* pluginScriptableObject(Widget*);
121 static bool popupsAllowed(NPP);
123 // Protocol -----------------------------------------------------------
124 static String uiResourceProtocol(); // deprecated
126 // Resources ----------------------------------------------------------
127 static PassRefPtr<Image> loadPlatformImageResource(const char* name);
129 // Screen -------------------------------------------------------------
130 static int screenDepth(Widget*);
131 static int screenDepthPerComponent(Widget*);
132 static bool screenIsMonochrome(Widget*);
133 static IntRect screenRect(Widget*);
134 static IntRect screenAvailableRect(Widget*);
136 // SharedTimers -------------------------------------------------------
137 static void setSharedTimerFiredFunction(void (*func)());
138 static void setSharedTimerFireTime(double fireTime);
139 static void stopSharedTimer();
141 // StatsCounters ------------------------------------------------------
142 static void decrementStatsCounter(const char* name);
143 static void incrementStatsCounter(const char* name);
145 // Sudden Termination
146 static void suddenTerminationChanged(bool enabled);
148 // SystemTime ---------------------------------------------------------
149 static double currentTime();
151 // Theming ------------------------------------------------------------
153 static void paintButton(
154 GraphicsContext*, int part, int state, int classicState, const IntRect&);
155 static void paintMenuList(
156 GraphicsContext*, int part, int state, int classicState, const IntRect&);
157 static void paintScrollbarArrow(
158 GraphicsContext*, int state, int classicState, const IntRect&);
159 static void paintScrollbarThumb(
160 GraphicsContext*, int part, int state, int classicState, const IntRect&);
161 static void paintScrollbarTrack(
162 GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect);
163 static void paintTextField(
164 GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges);
165 static void paintTrackbar(
166 GraphicsContext*, int part, int state, int classicState, const IntRect&);
169 // Trace Event --------------------------------------------------------
170 static void traceEventBegin(const char* name, void* id, const char* extra);
171 static void traceEventEnd(const char* name, void* id, const char* extra);
173 // Visited links ------------------------------------------------------
174 static LinkHash visitedLinkHash(const UChar* url, unsigned length);
175 static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL);
176 static bool isLinkVisited(LinkHash);
178 // Widget -------------------------------------------------------------
179 static void widgetSetCursor(Widget*, const Cursor&);
180 static void widgetSetFocus(Widget*);
182 // HTML5 DB -----------------------------------------------------------
185 // Opens a database file
186 // 'desiredFlags' is a collection of OR'd SQLite constants that
187 // determine how the file should be opened
188 static PlatformFileHandle databaseOpenFile(const String& fileName, int desiredFlags);
190 // Deletes a database file
191 // Returns 'true' if the file was deleted; 'false' otherwise
192 static bool databaseDeleteFile(const String& fileName);
194 // Returns the file attributes of the given database file
195 static long databaseGetFileAttributes(const String& fileName);
197 // Returns size of the given file
198 static long long databaseGetFileSize(const String& fileName);
202 } // namespace WebCore