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& policyURL, const String& value);
80 static String cookies(const KURL& url, const KURL& policyURL);
82 // DNS ----------------------------------------------------------------
83 static void prefetchDNS(const String& hostname);
85 // Font ---------------------------------------------------------------
87 static bool ensureFontLoaded(HFONT font);
90 // Forms --------------------------------------------------------------
91 static void notifyFormStateChanged(const Document*);
93 // JavaScript ---------------------------------------------------------
94 static void notifyJSOutOfMemory(Frame*);
95 static bool allowScriptDespiteSettings(const KURL& documentURL);
97 // Language -----------------------------------------------------------
98 static String computedDefaultLanguage();
100 // LayoutTestMode -----------------------------------------------------
101 static bool layoutTestMode();
103 // MimeType -----------------------------------------------------------
104 static bool isSupportedImageMIMEType(const String& mimeType);
105 static bool isSupportedJavaScriptMIMEType(const String& mimeType);
106 static bool isSupportedNonImageMIMEType(const String& mimeType);
107 static String mimeTypeForExtension(const String& fileExtension);
108 static String mimeTypeFromFile(const String& filePath);
109 static String preferredExtensionForMIMEType(const String& mimeType);
111 // Plugin -------------------------------------------------------------
112 static bool plugins(bool refresh, Vector<PluginInfo*>*);
113 static NPObject* pluginScriptableObject(Widget*);
114 static bool popupsAllowed(NPP);
116 // Protocol -----------------------------------------------------------
117 static String uiResourceProtocol(); // deprecated
119 // Resources ----------------------------------------------------------
120 static PassRefPtr<Image> loadPlatformImageResource(const char* name);
122 // Screen -------------------------------------------------------------
123 static int screenDepth(Widget*);
124 static int screenDepthPerComponent(Widget*);
125 static bool screenIsMonochrome(Widget*);
126 static IntRect screenRect(Widget*);
127 static IntRect screenAvailableRect(Widget*);
129 // SharedTimers -------------------------------------------------------
130 static void setSharedTimerFiredFunction(void (*func)());
131 static void setSharedTimerFireTime(double fireTime);
132 static void stopSharedTimer();
134 // StatsCounters ------------------------------------------------------
135 static void decrementStatsCounter(const char* name);
136 static void incrementStatsCounter(const char* name);
138 // Sudden Termination
139 static void suddenTerminationChanged(bool enabled);
141 // SystemTime ---------------------------------------------------------
142 static double currentTime();
144 // Theming ------------------------------------------------------------
146 static void paintButton(
147 GraphicsContext*, int part, int state, int classicState, const IntRect&);
148 static void paintMenuList(
149 GraphicsContext*, int part, int state, int classicState, const IntRect&);
150 static void paintScrollbarArrow(
151 GraphicsContext*, int state, int classicState, const IntRect&);
152 static void paintScrollbarThumb(
153 GraphicsContext*, int part, int state, int classicState, const IntRect&);
154 static void paintScrollbarTrack(
155 GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect);
156 static void paintTextField(
157 GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges);
158 static void paintTrackbar(
159 GraphicsContext*, int part, int state, int classicState, const IntRect&);
162 // Trace Event --------------------------------------------------------
163 static void traceEventBegin(const char* name, void* id, const char* extra);
164 static void traceEventEnd(const char* name, void* id, const char* extra);
166 // Visited links ------------------------------------------------------
167 static LinkHash visitedLinkHash(const UChar* url, unsigned length);
168 static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL);
169 static bool isLinkVisited(LinkHash);
171 // Widget -------------------------------------------------------------
172 static void widgetSetCursor(Widget*, const Cursor&);
173 static void widgetSetFocus(Widget*);
176 } // namespace WebCore