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*);
96 // Language -----------------------------------------------------------
97 static String computedDefaultLanguage();
99 // LayoutTestMode -----------------------------------------------------
100 static bool layoutTestMode();
102 // MimeType -----------------------------------------------------------
103 static bool isSupportedImageMIMEType(const String& mimeType);
104 static bool isSupportedJavaScriptMIMEType(const String& mimeType);
105 static bool isSupportedNonImageMIMEType(const String& mimeType);
106 static String mimeTypeForExtension(const String& fileExtension);
107 static String mimeTypeFromFile(const String& filePath);
108 static String preferredExtensionForMIMEType(const String& mimeType);
110 // Plugin -------------------------------------------------------------
111 static bool plugins(bool refresh, Vector<PluginInfo*>*);
112 static NPObject* pluginScriptableObject(Widget*);
113 static bool popupsAllowed(NPP);
115 // Protocol -----------------------------------------------------------
116 static String uiResourceProtocol();
118 // Resources ----------------------------------------------------------
119 static PassRefPtr<Image> loadPlatformImageResource(const char* name);
121 // Screen -------------------------------------------------------------
122 static int screenDepth(Widget*);
123 static int screenDepthPerComponent(Widget*);
124 static bool screenIsMonochrome(Widget*);
125 static IntRect screenRect(Widget*);
126 static IntRect screenAvailableRect(Widget*);
128 // SharedTimers -------------------------------------------------------
129 static void setSharedTimerFiredFunction(void (*func)());
130 static void setSharedTimerFireTime(double fireTime);
131 static void stopSharedTimer();
133 // StatsCounters ------------------------------------------------------
134 static void decrementStatsCounter(const char* name);
135 static void incrementStatsCounter(const char* name);
136 static void initV8CounterFunction();
138 // SystemTime ---------------------------------------------------------
139 static double currentTime();
141 // Theming ------------------------------------------------------------
143 static void paintButton(
144 GraphicsContext*, int part, int state, int classicState, const IntRect&);
145 static void paintMenuList(
146 GraphicsContext*, int part, int state, int classicState, const IntRect&);
147 static void paintScrollbarArrow(
148 GraphicsContext*, int state, int classicState, const IntRect&);
149 static void paintScrollbarThumb(
150 GraphicsContext*, int part, int state, int classicState, const IntRect&);
151 static void paintScrollbarTrack(
152 GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect);
153 static void paintTextField(
154 GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges);
157 // Trace Event --------------------------------------------------------
158 static void traceEventBegin(const char* name, void* id, const char* extra);
159 static void traceEventEnd(const char* name, void* id, const char* extra);
161 // URL ----------------------------------------------------------------
162 static KURL inspectorURL();
164 // Visited links ------------------------------------------------------
165 static LinkHash visitedLinkHash(const UChar* url, unsigned length);
166 static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL);
167 static bool isLinkVisited(LinkHash);
169 // Widget -------------------------------------------------------------
170 static void widgetSetCursor(Widget*, const Cursor&);
171 static void widgetSetFocus(Widget*);
174 } // namespace WebCore