1 /* 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef Page_h 22 #define Page_h 23 24 #include "BackForwardList.h" 25 #include "Chrome.h" 26 #include "ContextMenuController.h" 27 #include "FrameLoaderTypes.h" 28 #include "LinkHash.h" 29 #include "PlatformString.h" 30 #include <wtf/HashSet.h> 31 #include <wtf/OwnPtr.h> 32 33 #if PLATFORM(MAC) 34 #include "SchedulePair.h" 35 #endif 36 37 #if PLATFORM(WIN) || (PLATFORM(WX) && PLATFORM(WIN_OS)) || (PLATFORM(QT) && defined(Q_WS_WIN)) 38 typedef struct HINSTANCE__* HINSTANCE; 39 #endif 40 41 namespace JSC { 42 class Debugger; 43 } 44 45 namespace WebCore { 46 47 class Chrome; 48 class ChromeClient; 49 class ContextMenuClient; 50 class ContextMenuController; 51 class Document; 52 class DragClient; 53 class DragController; 54 class EditorClient; 55 class FocusController; 56 class Frame; 57 class InspectorClient; 58 class InspectorController; 59 class Node; 60 class PageGroup; 61 class PluginData; 62 class PluginView; 63 class ProgressTracker; 64 class RenderTheme; 65 class VisibleSelection; 66 class SelectionController; 67 class Settings; 68 #if ENABLE(DOM_STORAGE) 69 class StorageNamespace; 70 #endif 71 #if ENABLE(WML) 72 class WMLPageState; 73 #endif 74 75 enum FindDirection { FindDirectionForward, FindDirectionBackward }; 76 77 class Page : public Noncopyable { 78 public: 79 static void setNeedsReapplyStyles(); 80 81 Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*); 82 ~Page(); 83 theme()84 RenderTheme* theme() const { return m_theme.get(); }; 85 86 static void refreshPlugins(bool reload); 87 PluginData* pluginData() const; 88 89 void setCanStartPlugins(bool); canStartPlugins()90 bool canStartPlugins() const { return m_canStartPlugins; } 91 void addUnstartedPlugin(PluginView*); 92 void removeUnstartedPlugin(PluginView*); 93 editorClient()94 EditorClient* editorClient() const { return m_editorClient; } 95 96 void setMainFrame(PassRefPtr<Frame>); mainFrame()97 Frame* mainFrame() const { return m_mainFrame.get(); } 98 99 BackForwardList* backForwardList(); 100 101 // FIXME: The following three methods don't fall under the responsibilities of the Page object 102 // They seem to fit a hypothetical Page-controller object that would be akin to the 103 // Frame-FrameLoader relationship. They have to live here now, but should move somewhere that 104 // makes more sense when that class exists. 105 bool goBack(); 106 bool goForward(); 107 void goToItem(HistoryItem*, FrameLoadType); 108 globalHistoryItem()109 HistoryItem* globalHistoryItem() const { return m_globalHistoryItem.get(); } 110 void setGlobalHistoryItem(HistoryItem*); 111 112 void setGroupName(const String&); 113 const String& groupName() const; 114 group()115 PageGroup& group() { if (!m_group) initGroup(); return *m_group; } groupPtr()116 PageGroup* groupPtr() { return m_group; } // can return 0 117 incrementFrameCount()118 void incrementFrameCount() { ++m_frameCount; } decrementFrameCount()119 void decrementFrameCount() { --m_frameCount; } frameCount()120 int frameCount() const { return m_frameCount; } 121 chrome()122 Chrome* chrome() const { return m_chrome.get(); } dragCaretController()123 SelectionController* dragCaretController() const { return m_dragCaretController.get(); } dragController()124 DragController* dragController() const { return m_dragController.get(); } focusController()125 FocusController* focusController() const { return m_focusController.get(); } contextMenuController()126 ContextMenuController* contextMenuController() const { return m_contextMenuController.get(); } inspectorController()127 InspectorController* inspectorController() const { return m_inspectorController.get(); } settings()128 Settings* settings() const { return m_settings.get(); } progress()129 ProgressTracker* progress() const { return m_progress.get(); } 130 setParentInspectorController(InspectorController * controller)131 void setParentInspectorController(InspectorController* controller) { m_parentInspectorController = controller; } parentInspectorController()132 InspectorController* parentInspectorController() const { return m_parentInspectorController; } 133 setTabKeyCyclesThroughElements(bool b)134 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; } tabKeyCyclesThroughElements()135 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; } 136 137 bool findString(const String&, TextCaseSensitivity, FindDirection, bool shouldWrap); 138 unsigned int markAllMatchesForText(const String&, TextCaseSensitivity, bool shouldHighlight, unsigned); 139 void unmarkAllTextMatches(); 140 141 #if PLATFORM(MAC) 142 void addSchedulePair(PassRefPtr<SchedulePair>); 143 void removeSchedulePair(PassRefPtr<SchedulePair>); scheduledRunLoopPairs()144 SchedulePairHashSet* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs.get(); } 145 146 OwnPtr<SchedulePairHashSet> m_scheduledRunLoopPairs; 147 #endif 148 149 const VisibleSelection& selection() const; 150 151 void setDefersLoading(bool); defersLoading()152 bool defersLoading() const { return m_defersLoading; } 153 154 void clearUndoRedoOperations(); 155 156 bool inLowQualityImageInterpolationMode() const; 157 void setInLowQualityImageInterpolationMode(bool = true); 158 cookieEnabled()159 bool cookieEnabled() const { return m_cookieEnabled; } setCookieEnabled(bool enabled)160 void setCookieEnabled(bool enabled) { m_cookieEnabled = enabled; } 161 mediaVolume()162 float mediaVolume() const { return m_mediaVolume; } 163 void setMediaVolume(float volume); 164 165 // Notifications when the Page starts and stops being presented via a native window. 166 void didMoveOnscreen(); 167 void willMoveOffscreen(); 168 169 void userStyleSheetLocationChanged(); 170 const String& userStyleSheet() const; 171 172 static void setDebuggerForAllPages(JSC::Debugger*); 173 void setDebugger(JSC::Debugger*); debugger()174 JSC::Debugger* debugger() const { return m_debugger; } 175 176 #if PLATFORM(WIN) || (PLATFORM(WX) && PLATFORM(WIN_OS)) || (PLATFORM(QT) && defined(Q_WS_WIN)) 177 // The global DLL or application instance used for all windows. setInstanceHandle(HINSTANCE instanceHandle)178 static void setInstanceHandle(HINSTANCE instanceHandle) { s_instanceHandle = instanceHandle; } instanceHandle()179 static HINSTANCE instanceHandle() { return s_instanceHandle; } 180 #endif 181 182 static void removeAllVisitedLinks(); 183 184 static void allVisitedStateChanged(PageGroup*); 185 static void visitedStateChanged(PageGroup*, LinkHash visitedHash); 186 187 #if ENABLE(DOM_STORAGE) 188 StorageNamespace* sessionStorage(bool optionalCreate = true); 189 void setSessionStorage(PassRefPtr<StorageNamespace>); 190 #endif 191 192 #if ENABLE(WML) 193 WMLPageState* wmlPageState(); 194 #endif 195 196 void setCustomHTMLTokenizerTimeDelay(double); hasCustomHTMLTokenizerTimeDelay()197 bool hasCustomHTMLTokenizerTimeDelay() const { return m_customHTMLTokenizerTimeDelay != -1; } customHTMLTokenizerTimeDelay()198 double customHTMLTokenizerTimeDelay() const { ASSERT(m_customHTMLTokenizerTimeDelay != -1); return m_customHTMLTokenizerTimeDelay; } 199 200 void setCustomHTMLTokenizerChunkSize(int); hasCustomHTMLTokenizerChunkSize()201 bool hasCustomHTMLTokenizerChunkSize() const { return m_customHTMLTokenizerChunkSize != -1; } customHTMLTokenizerChunkSize()202 int customHTMLTokenizerChunkSize() const { ASSERT(m_customHTMLTokenizerChunkSize != -1); return m_customHTMLTokenizerChunkSize; } 203 204 void setMemoryCacheClientCallsEnabled(bool); areMemoryCacheClientCallsEnabled()205 bool areMemoryCacheClientCallsEnabled() const { return m_areMemoryCacheClientCallsEnabled; } 206 207 void setJavaScriptURLsAreAllowed(bool); 208 bool javaScriptURLsAreAllowed() const; 209 210 private: 211 void initGroup(); 212 213 OwnPtr<Chrome> m_chrome; 214 OwnPtr<SelectionController> m_dragCaretController; 215 OwnPtr<DragController> m_dragController; 216 OwnPtr<FocusController> m_focusController; 217 OwnPtr<ContextMenuController> m_contextMenuController; 218 OwnPtr<InspectorController> m_inspectorController; 219 OwnPtr<Settings> m_settings; 220 OwnPtr<ProgressTracker> m_progress; 221 222 RefPtr<BackForwardList> m_backForwardList; 223 RefPtr<Frame> m_mainFrame; 224 225 RefPtr<HistoryItem> m_globalHistoryItem; 226 227 mutable RefPtr<PluginData> m_pluginData; 228 229 RefPtr<RenderTheme> m_theme; 230 231 EditorClient* m_editorClient; 232 233 int m_frameCount; 234 String m_groupName; 235 236 bool m_tabKeyCyclesThroughElements; 237 bool m_defersLoading; 238 239 bool m_inLowQualityInterpolationMode; 240 bool m_cookieEnabled; 241 bool m_areMemoryCacheClientCallsEnabled; 242 float m_mediaVolume; 243 244 bool m_javaScriptURLsAreAllowed; 245 246 InspectorController* m_parentInspectorController; 247 248 String m_userStyleSheetPath; 249 mutable String m_userStyleSheet; 250 mutable bool m_didLoadUserStyleSheet; 251 mutable time_t m_userStyleSheetModificationTime; 252 253 OwnPtr<PageGroup> m_singlePageGroup; 254 PageGroup* m_group; 255 256 JSC::Debugger* m_debugger; 257 258 double m_customHTMLTokenizerTimeDelay; 259 int m_customHTMLTokenizerChunkSize; 260 261 bool m_canStartPlugins; 262 HashSet<PluginView*> m_unstartedPlugins; 263 264 #if ENABLE(DOM_STORAGE) 265 RefPtr<StorageNamespace> m_sessionStorage; 266 #endif 267 268 #if PLATFORM(WIN) || (PLATFORM(WX) && defined(__WXMSW__)) || (PLATFORM(QT) && defined(Q_WS_WIN)) 269 static HINSTANCE s_instanceHandle; 270 #endif 271 272 #if ENABLE(WML) 273 OwnPtr<WMLPageState> m_wmlPageState; 274 #endif 275 }; 276 277 } // namespace WebCore 278 279 #endif // Page_h 280