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
35 #include "PassRefPtr.h"
36 #include "PasteboardPrivate.h"
38 class NativeImageSkia;
40 typedef struct NPObject NPObject;
41 typedef struct _NPP NPP_t;
45 typedef struct HFONT__* HFONT;
54 class GraphicsContext;
63 // An interface to the embedding layer, which has the ability to answer
64 // questions about the system and so on...
66 class ChromiumBridge {
68 // Clipboard ----------------------------------------------------------
69 static bool clipboardIsFormatAvailable(PasteboardPrivate::ClipboardFormat);
71 static String clipboardReadPlainText();
72 static void clipboardReadHTML(String*, KURL*);
74 static void clipboardWriteSelection(const String&, const KURL&, const String&, bool);
75 static void clipboardWriteURL(const KURL&, const String&);
76 static void clipboardWriteImage(const NativeImageSkia*, const KURL&, const String&);
78 // Cookies ------------------------------------------------------------
79 static void setCookies(const KURL& url, const KURL& firstPartyForCookies, const String& value);
80 static String cookies(const KURL& url, const KURL& firstPartyForCookies);
82 // DNS ----------------------------------------------------------------
83 static void prefetchDNS(const String& hostname);
85 // Font ---------------------------------------------------------------
87 static bool ensureFontLoaded(HFONT font);
90 static String getFontFamilyForCharacters(const UChar*, size_t numCharacters);
93 // Forms --------------------------------------------------------------
94 static void notifyFormStateChanged(const Document*);
96 // JavaScript ---------------------------------------------------------
97 static void notifyJSOutOfMemory(Frame*);
98 static bool allowScriptDespiteSettings(const KURL& documentURL);
100 // Language -----------------------------------------------------------
101 static String computedDefaultLanguage();
103 // LayoutTestMode -----------------------------------------------------
104 static bool layoutTestMode();
106 // MimeType -----------------------------------------------------------
107 static bool isSupportedImageMIMEType(const String& mimeType);
108 static bool isSupportedJavaScriptMIMEType(const String& mimeType);
109 static bool isSupportedNonImageMIMEType(const String& mimeType);
110 static String mimeTypeForExtension(const String& fileExtension);
111 static String mimeTypeFromFile(const String& filePath);
112 static String preferredExtensionForMIMEType(const String& mimeType);
114 // Plugin -------------------------------------------------------------
115 static bool plugins(bool refresh, Vector<PluginInfo*>*);
116 static NPObject* pluginScriptableObject(Widget*);
117 static bool popupsAllowed(NPP);
119 // Protocol -----------------------------------------------------------
120 static String uiResourceProtocol(); // deprecated
122 // Resources ----------------------------------------------------------
123 static PassRefPtr<Image> loadPlatformImageResource(const char* name);
125 // Screen -------------------------------------------------------------
126 static int screenDepth(Widget*);
127 static int screenDepthPerComponent(Widget*);
128 static bool screenIsMonochrome(Widget*);
129 static IntRect screenRect(Widget*);
130 static IntRect screenAvailableRect(Widget*);
132 // SharedTimers -------------------------------------------------------
133 static void setSharedTimerFiredFunction(void (*func)());
134 static void setSharedTimerFireTime(double fireTime);
135 static void stopSharedTimer();
137 // StatsCounters ------------------------------------------------------
138 static void decrementStatsCounter(const char* name);
139 static void incrementStatsCounter(const char* name);
141 // Sudden Termination
142 static void suddenTerminationChanged(bool enabled);
144 // SystemTime ---------------------------------------------------------
145 static double currentTime();
147 // Theming ------------------------------------------------------------
149 static void paintButton(
150 GraphicsContext*, int part, int state, int classicState, const IntRect&);
151 static void paintMenuList(
152 GraphicsContext*, int part, int state, int classicState, const IntRect&);
153 static void paintScrollbarArrow(
154 GraphicsContext*, int state, int classicState, const IntRect&);
155 static void paintScrollbarThumb(
156 GraphicsContext*, int part, int state, int classicState, const IntRect&);
157 static void paintScrollbarTrack(
158 GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect);
159 static void paintTextField(
160 GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges);
161 static void paintTrackbar(
162 GraphicsContext*, int part, int state, int classicState, const IntRect&);
165 // Trace Event --------------------------------------------------------
166 static void traceEventBegin(const char* name, void* id, const char* extra);
167 static void traceEventEnd(const char* name, void* id, const char* extra);
169 // Visited links ------------------------------------------------------
170 static LinkHash visitedLinkHash(const UChar* url, unsigned length);
171 static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL);
172 static bool isLinkVisited(LinkHash);
174 // Widget -------------------------------------------------------------
175 static void widgetSetCursor(Widget*, const Cursor&);
176 static void widgetSetFocus(Widget*);
179 } // namespace WebCore