diff options
author | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 00:20:51 +0000 |
---|---|---|
committer | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 00:20:51 +0000 |
commit | f5b16fed647e941aa66933178da85db2860d639b (patch) | |
tree | f00e9856c04aad3b558a140955e7674add33f051 /webkit/glue/webview.h | |
parent | 920c091ac3ee15079194c82ae8a7a18215f3f23c (diff) | |
download | chromium_src-f5b16fed647e941aa66933178da85db2860d639b.zip chromium_src-f5b16fed647e941aa66933178da85db2860d639b.tar.gz chromium_src-f5b16fed647e941aa66933178da85db2860d639b.tar.bz2 |
Add webkit to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview.h')
-rw-r--r-- | webkit/glue/webview.h | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h new file mode 100644 index 0000000..9f44769 --- /dev/null +++ b/webkit/glue/webview.h @@ -0,0 +1,219 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef WEBKIT_GLUE_WEBVIEW_H__ +#define WEBKIT_GLUE_WEBVIEW_H__ + +#include <string> + +#include "base/basictypes.h" +#include "base/ref_counted.h" +#include "webkit/glue/webwidget.h" + +struct WebDropData; +struct WebPreferences; +class GURL; +class WebFrame; +class WebViewDelegate; + +// +// @class WebView +// WebView manages the interaction between WebFrameViews and WebDataSources. +// Modification of the policies and behavior of the WebKit is largely managed +// by WebViews and their delegates. +// +// Typical usage: +// +// WebView *webView; +// WebFrame *mainFrame; +// +// webView = [[WebView alloc] initWithFrame: NSMakeRect (0,0,640,480)]; +// mainFrame = [webView mainFrame]; +// [mainFrame loadRequest:request]; +// +// WebViews have a WebViewDelegate that the embedding application implements +// that are required for tasks like opening new windows and controlling the +// user interface elements in those windows, monitoring the progress of loads, +// monitoring URL changes, and making determinations about how content of +// certain types should be handled. +class WebView : public WebWidget { + public: + WebView() {} + virtual ~WebView() {} + + // This method creates a WebView that is initially sized to an empty rect. + static WebView* Create(WebViewDelegate* delegate, + const WebPreferences& prefs); + + // Returns the delegate for this WebView. This is the pointer that was + // passed to WebView::Create. The caller must check this value before using + // it, it will be NULL during closing of the view. + virtual WebViewDelegate* GetDelegate() = 0; + + // Instructs the EditorClient whether to pass editing notifications on to a + // delegate, if one is present. This allows embedders that haven't + // overridden any editor delegate methods to avoid the performance impact of + // calling them. + virtual void SetUseEditorDelegate(bool value) = 0; + + // Method that controls whether pressing Tab key cycles through page elements + // or inserts a '\t' char in text area + virtual void SetTabKeyCyclesThroughElements(bool value) = 0; + + // Returns whether the current view can be closed, after running any + // onbeforeunload event handlers. + virtual bool ShouldClose() = 0; + + // + // @method mainFrame + // @abstract Return the top level frame. + // @discussion Note that even document that are not framesets will have a + // mainFrame. + // @result The main frame. + // - (WebFrame *)mainFrame; + virtual WebFrame* GetMainFrame() = 0; + + // Returns the currently focused frame. + virtual WebFrame* GetFocusedFrame() = 0; + + // Sets focus to the frame passed in. + virtual void SetFocusedFrame(WebFrame* frame) = 0; + + // Returns the frame with the given name, or NULL if not found. + virtual WebFrame* GetFrameWithName(const std::wstring& name) = 0; + + // Returns the frame previous to the specified frame, by traversing the frame + // tree, wrapping around if necessary. + virtual WebFrame* GetPreviousFrameBefore(WebFrame* frame, bool wrap) = 0; + + // Returns the frame after to the specified frame, by traversing the frame + // tree, wrapping around if necessary. + virtual WebFrame* GetNextFrameAfter(WebFrame* frame, bool wrap) = 0; + + // ---- TODO(darin): remove from here ---- + + // + // - (IBAction)stopLoading:(id)sender; + virtual void StopLoading() = 0; + + // Sets the maximum size to allow WebCore's internal B/F list to grow to. + // If not called, the list will have the default capacity specified in + // BackForwardList.cpp. + virtual void SetBackForwardListSize(int size) = 0; + + // ---- TODO(darin): remove to here ---- + + // Restores focus to the previously focused element. + // This method is invoked when the webview is shown after being + // hidden, and focus is to be restored. When WebView loses focus, it remembers + // the frame/element that had focus, so that when this method is invoked + // focus is then restored. + virtual void RestoreFocus() = 0; + + // Focus the first (last if reverse is true) focusable node. + virtual void SetInitialFocus(bool reverse) = 0; + + // Stores the focused node and clears it if |frame| is the focused frame. + // TODO(jcampan): http://b/issue?id=1157486 this is needed to work-around + // issues caused by the fix for bug #792423 and should be removed when that + // bug is fixed. + virtual void StoreFocusForFrame(WebFrame* frame) = 0; + + // Returns whether or not the focused control needs spell-checking. + // Currently, this function just retrieves the focused node and determines + // whether or not it is a <textarea> element or an element whose + // contenteditable attribute is true. + // TODO(hbono): Bug 740540: This code just implements the default behavior + // proposed in this issue. We should also retrieve "spellcheck" attributes + // for text fields and create a flag to over-write the default behavior. + virtual bool FocusedFrameNeedsSpellchecking() = 0; + + // Requests the webview to download an image. When done, the delegate is + // notified by way of DidDownloadImage. Returns true if the request was + // successfully started, false otherwise. id is used to uniquely identify the + // request and passed back to the DidDownloadImage method. If the image has + // multiple frames, the frame whose size is image_size is returned. If the + // image doesn't have a frame at the specified size, the first is returned. + virtual bool DownloadImage(int id, const GURL& image_url, int image_size) = 0; + + // Replace the standard setting for the WebView with |preferences|. + virtual void SetPreferences(const WebPreferences& preferences) = 0; + virtual const WebPreferences& GetPreferences() = 0; + + // Set the encoding of the current main frame. The value comes from + // the encoding menu. WebKit uses the function named + // SetCustomTextEncodingName to do override encoding job. + virtual void SetPageEncoding(const std::wstring& encoding_name) = 0; + + // Return the canonical encoding name of current main webframe in webview. + virtual std::wstring GetMainFrameEncodingName() = 0; + + // Change the text zoom level. Text size is made 20% larger or smaller. + virtual void MakeTextLarger() = 0; + virtual void MakeTextSmaller() = 0; + virtual void MakeTextStandardSize() = 0; + + // Copy to the clipboard the image located at a particular point in the + // WebView (if there is such an image) + virtual void CopyImageAt(int x, int y) = 0; + + // Inspect a particular point in the WebView. (x = -1 || y = -1) is a special + // case which means inspect the current page and not a specific point. + virtual void InspectElement(int x, int y) = 0; + + // Show the JavaScript console. + virtual void ShowJavaScriptConsole() = 0; + + // Notifies the webview that a drag has terminated. + virtual void DragSourceEndedAt( + int client_x, int client_y, int screen_x, int screen_y) = 0; + + // Notifies the webview that a drag and drop operation is in progress, with + // dropable items over the view. + virtual void DragSourceMovedTo( + int client_x, int client_y, int screen_x, int screen_y) = 0; + + // Notfies the webview that the system drag and drop operation has ended. + virtual void DragSourceSystemDragEnded() = 0; + + // Callback methods when a drag and drop operation is trying to drop + // something on the renderer. + virtual bool DragTargetDragEnter(const WebDropData& drop_data, + int client_x, int client_y, int screen_x, int screen_y) = 0; + virtual bool DragTargetDragOver( + int client_x, int client_y, int screen_x, int screen_y) = 0; + virtual void DragTargetDragLeave() = 0; + virtual void DragTargetDrop( + int client_x, int client_y, int screen_x, int screen_y) = 0; + + private: + DISALLOW_EVIL_CONSTRUCTORS(WebView); +}; + +#endif // WEBKIT_GLUE_WEBVIEW_H__ |