| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // WebCore provides hooks for several kinds of functionality, allowing separate | 5 // WebCore provides hooks for several kinds of functionality, allowing separate |
| 6 // classes termed "delegates" to receive notifications (in the form of direct | 6 // classes termed "delegates" to receive notifications (in the form of direct |
| 7 // function calls) when certain events are about to occur or have just occurred. | 7 // function calls) when certain events are about to occur or have just occurred. |
| 8 // In some cases, the delegate implements the needed functionality; in others, | 8 // In some cases, the delegate implements the needed functionality; in others, |
| 9 // the delegate has some control over the behavior but doesn't actually | 9 // the delegate has some control over the behavior but doesn't actually |
| 10 // implement it. For example, the UI delegate is responsible for showing a | 10 // implement it. For example, the UI delegate is responsible for showing a |
| 11 // dialog box or otherwise handling a JavaScript window.alert() call, via the | 11 // dialog box or otherwise handling a JavaScript window.alert() call, via the |
| 12 // RunJavaScriptAlert() method. On the other hand, the editor delegate doesn't | 12 // RunJavaScriptAlert() method. On the other hand, the editor delegate doesn't |
| 13 // actually handle editing functionality, although it could (for example) | 13 // actually handle editing functionality, although it could (for example) |
| 14 // override whether a content-editable node accepts editing focus by returning | 14 // override whether a content-editable node accepts editing focus by returning |
| 15 // false from ShouldBeginEditing(). (It would also possible for a more | 15 // false from ShouldBeginEditing(). (It would also possible for a more |
| 16 // special-purpose editing delegate to act on the edited node in some way, e.g. | 16 // special-purpose editing delegate to act on the edited node in some way, e.g. |
| 17 // to highlight modified text in the DidChangeContents() method.) | 17 // to highlight modified text in the DidChangeContents() method.) |
| 18 | 18 |
| 19 // WebKit divides the delegated tasks into several different classes, but we | 19 // WebKit divides the delegated tasks into several different classes, but we |
| 20 // combine them into a single WebViewDelegate. This single delegate encompasses | 20 // combine them into a single WebViewDelegate. This single delegate encompasses |
| 21 // the needed functionality of the WebKit UIDelegate, ContextMenuDelegate, | 21 // the needed functionality of the WebKit UIDelegate, ContextMenuDelegate, |
| 22 // PolicyDelegate, FrameLoadDelegate, and EditorDelegate; additional portions | 22 // PolicyDelegate, FrameLoadDelegate, and EditorDelegate; additional portions |
| 23 // of ChromeClient and FrameLoaderClient not delegated in the WebKit | 23 // of ChromeClient and FrameLoaderClient not delegated in the WebKit |
| 24 // implementation; and some WebView additions. | 24 // implementation; and some WebView additions. |
| 25 | 25 |
| 26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| 27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| 28 | 28 |
| 29 #include <string> | |
| 30 #include <vector> | 29 #include <vector> |
| 31 | 30 |
| 32 #include "base/basictypes.h" | |
| 33 #include "base/logging.h" | |
| 34 #include "googleurl/src/gurl.h" | |
| 35 #include "webkit/glue/context_menu.h" | 31 #include "webkit/glue/context_menu.h" |
| 36 #include "webkit/glue/webwidget_delegate.h" | 32 #include "webkit/glue/webwidget_delegate.h" |
| 37 #include "webkit/glue/window_open_disposition.h" | |
| 38 | 33 |
| 39 namespace gfx { | 34 namespace gfx { |
| 40 class Point; | 35 class Point; |
| 41 class Rect; | 36 class Rect; |
| 42 } | 37 } |
| 43 | 38 |
| 44 namespace webkit_glue { | 39 namespace webkit_glue { |
| 45 class WebMediaPlayerDelegate; | 40 class WebMediaPlayerDelegate; |
| 46 } | 41 } |
| 47 | 42 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 virtual bool ShouldApplyStyle(WebView* webview, | 645 virtual bool ShouldApplyStyle(WebView* webview, |
| 651 std::wstring style, | 646 std::wstring style, |
| 652 std::wstring range) { | 647 std::wstring range) { |
| 653 return true; | 648 return true; |
| 654 } | 649 } |
| 655 | 650 |
| 656 virtual bool SmartInsertDeleteEnabled() { | 651 virtual bool SmartInsertDeleteEnabled() { |
| 657 return true; | 652 return true; |
| 658 } | 653 } |
| 659 | 654 |
| 660 virtual void SetSmartInsertDeleteEnabled(bool enabled) { | 655 virtual void SetSmartInsertDeleteEnabled(bool enabled); |
| 661 // This method is only used in test shell, which overrides this | |
| 662 // method. | |
| 663 NOTREACHED(); | |
| 664 } | |
| 665 | 656 |
| 666 virtual bool IsSelectTrailingWhitespaceEnabled() { | 657 virtual bool IsSelectTrailingWhitespaceEnabled() { |
| 667 #if defined(OS_WIN) | 658 #if defined(OS_WIN) |
| 668 return true; | 659 return true; |
| 669 #else | 660 #else |
| 670 return false; | 661 return false; |
| 671 #endif | 662 #endif |
| 672 } | 663 } |
| 673 | 664 |
| 674 virtual void SetSelectTrailingWhitespaceEnabled(bool enabled) { | 665 virtual void SetSelectTrailingWhitespaceEnabled(bool enabled); |
| 675 // This method is only used in test shell, which overrides this | |
| 676 // method. | |
| 677 NOTREACHED(); | |
| 678 } | |
| 679 | 666 |
| 680 virtual void DidBeginEditing() { } | 667 virtual void DidBeginEditing() { } |
| 681 virtual void DidChangeSelection(bool is_empty_selection) { } | 668 virtual void DidChangeSelection(bool is_empty_selection) { } |
| 682 virtual void DidChangeContents() { } | 669 virtual void DidChangeContents() { } |
| 683 virtual void DidEndEditing() { } | 670 virtual void DidEndEditing() { } |
| 684 | 671 |
| 685 // Notification that a user metric has occurred. | 672 // Notification that a user metric has occurred. |
| 686 virtual void UserMetricsRecordAction(const std::wstring& action) { } | 673 virtual void UserMetricsRecordAction(const std::wstring& action) { } |
| 687 virtual void UserMetricsRecordComputedAction(const std::wstring& action) { | 674 virtual void UserMetricsRecordComputedAction(const std::wstring& action) { |
| 688 UserMetricsRecordAction(action); | 675 UserMetricsRecordAction(action); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 704 enum ErrorPageType { | 691 enum ErrorPageType { |
| 705 DNS_ERROR, | 692 DNS_ERROR, |
| 706 HTTP_404, | 693 HTTP_404, |
| 707 CONNECTION_ERROR, | 694 CONNECTION_ERROR, |
| 708 }; | 695 }; |
| 709 // If providing an alternate error page (like link doctor), returns the URL | 696 // If providing an alternate error page (like link doctor), returns the URL |
| 710 // to fetch instead. If an invalid url is returned, just fall back on local | 697 // to fetch instead. If an invalid url is returned, just fall back on local |
| 711 // error pages. |error_name| tells the delegate what type of error page we | 698 // error pages. |error_name| tells the delegate what type of error page we |
| 712 // want (e.g., 404 vs dns errors). | 699 // want (e.g., 404 vs dns errors). |
| 713 virtual GURL GetAlternateErrorPageURL(const GURL& failedURL, | 700 virtual GURL GetAlternateErrorPageURL(const GURL& failedURL, |
| 714 ErrorPageType error_type) { | 701 ErrorPageType error_type); |
| 715 return GURL(); | |
| 716 } | |
| 717 | 702 |
| 718 // History Related --------------------------------------------------------- | 703 // History Related --------------------------------------------------------- |
| 719 | 704 |
| 720 // Returns the session history entry at a distance |offset| relative to the | 705 // Returns the session history entry at a distance |offset| relative to the |
| 721 // current entry. Returns NULL on failure. | 706 // current entry. Returns NULL on failure. |
| 722 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset) { | 707 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset) { |
| 723 return NULL; | 708 return NULL; |
| 724 } | 709 } |
| 725 | 710 |
| 726 // Returns how many entries are in the back and forward lists, respectively. | 711 // Returns how many entries are in the back and forward lists, respectively. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 virtual void DidAddHistoryItem() { } | 764 virtual void DidAddHistoryItem() { } |
| 780 | 765 |
| 781 WebViewDelegate() { } | 766 WebViewDelegate() { } |
| 782 virtual ~WebViewDelegate() { } | 767 virtual ~WebViewDelegate() { } |
| 783 | 768 |
| 784 private: | 769 private: |
| 785 DISALLOW_COPY_AND_ASSIGN(WebViewDelegate); | 770 DISALLOW_COPY_AND_ASSIGN(WebViewDelegate); |
| 786 }; | 771 }; |
| 787 | 772 |
| 788 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 773 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| OLD | NEW |