diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:11:05 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:11:05 +0000 |
commit | 05158051ea881677c03a22ddf38a3e6779cebb9e (patch) | |
tree | 95c6756227e0bbea55da3c4b19abdf99d7eb3ebe /webkit/glue/webframeloaderclient_impl.cc | |
parent | 6c14b76fede6abc592d9d65965fbdf4626e83efe (diff) | |
download | chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.zip chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.tar.gz chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.tar.bz2 |
Use WebWidget from the WebKit API. This change also makes
use of WebKitClient (replacing WebWidgetDelegate from glue).
The ripple effects of this change are rather large, but most
of the impact is mechanical.
The more interesting changes include:
1- Removing the WebWidget parameter from WebWidgetClient methods. This didn't
matter at all to RenderWidget or RenderView, but it did cause some changes to
be made to TestWebViewDelegate. Now, it is not possible to share a delegate
implementation for both the WebView and a popup menu, so I have a second
instance of the delegate owned by TestShell for use with popup menus.
2- Plumbing WebNavigationPolicy in place of WindowOpenDisposition was getting
to be a pretty large change, so I stopped short of deleting WindowOpenDisposition.
That way the Chrome side can remain mostly unmodified. I then added a mapping
function to convert from WebNavigationPolicy to WindowOpenDisposition.
3- The IME methods on WebWidget were renamed (reviewed separately by hbono), and
there is now an enum to specify the composition command (WebCompositionCommand).
4- I added IPC serialization for WebCompositionCommand and WebTextDirection,
which cleaned up some code that was just using ints in IPC messages.
R=jam
BUG=16234
TEST=none
Review URL: http://codereview.chromium.org/149620
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframeloaderclient_impl.cc')
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 19f1096..ffafec3 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -73,6 +73,7 @@ using base::TimeDelta; using WebKit::WebData; using WebKit::WebNavigationType; +using WebKit::WebNavigationPolicy; using WebKit::WebString; using WebKit::WebURL; using WebKit::WebVector; @@ -95,7 +96,7 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrameImpl* frame) : postpone_loading_data_(false), has_representation_(false), sent_initial_response_to_plugin_(false), - next_window_open_disposition_(IGNORE_ACTION) { + next_navigation_policy_(WebKit::WebNavigationPolicyIgnore) { } WebFrameLoaderClient::~WebFrameLoaderClient() { @@ -810,15 +811,15 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() { // Make sure that we have a valid disposition. This should have been set in // the preceeding call to dispatchDecidePolicyForNewWindowAction. - DCHECK(next_window_open_disposition_ != IGNORE_ACTION); - WindowOpenDisposition disp = next_window_open_disposition_; - next_window_open_disposition_ = IGNORE_ACTION; + DCHECK(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore); + WebNavigationPolicy policy = next_navigation_policy_; + next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore; // createWindow can return NULL (e.g., popup blocker denies the window). if (!new_page) return NULL; - WebViewImpl::FromPage(new_page)->set_window_open_disposition(disp); + WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy); return new_page->mainFrame(); } @@ -826,7 +827,7 @@ void WebFrameLoaderClient::dispatchShow() { WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); if (d) - d->Show(webview, webview->window_open_disposition()); + d->show(webview->initial_navigation_policy()); } static bool TreatAsAttachment(const ResourceResponse& response) { @@ -896,12 +897,12 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state, const WebCore::String& frame_name) { - WindowOpenDisposition disposition; - if (!ActionSpecifiesDisposition(action, &disposition)) - disposition = NEW_FOREGROUND_TAB; + WebNavigationPolicy navigation_policy; + if (!ActionSpecifiesNavigationPolicy(action, &navigation_policy)) + navigation_policy = WebKit::WebNavigationPolicyNewForegroundTab; PolicyAction policy_action; - if (disposition == SAVE_TO_DISK) { + if (navigation_policy == WebKit::WebNavigationPolicyDownload) { policy_action = PolicyDownload; } else { policy_action = PolicyUse; @@ -910,7 +911,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( // unfortunate that WebCore does not provide us with any context when // creating or showing the new window that would allow us to avoid having // to keep this state. - next_window_open_disposition_ = disposition; + next_navigation_policy_ = navigation_policy; } (webframe_->frame()->loader()->*function)(policy_action); } @@ -929,40 +930,42 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( // The NULL check here is to fix a crash that seems strange // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). if (d && !request.url().isNull()) { - WindowOpenDisposition disposition = CURRENT_TAB; - ActionSpecifiesDisposition(action, &disposition); + WebNavigationPolicy navigation_policy = + WebKit::WebNavigationPolicyCurrentTab; + ActionSpecifiesNavigationPolicy(action, &navigation_policy); - // Give the delegate a chance to change the disposition. + // Give the delegate a chance to change the navigation policy. const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); if (ds) { GURL url = ds->request().url(); if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { HandleBackForwardNavigation(url); - disposition = IGNORE_ACTION; + navigation_policy = WebKit::WebNavigationPolicyIgnore; } else { bool is_redirect = ds->HasRedirectChain(); WebNavigationType webnav_type = WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type()); - disposition = d->DispositionForNavigationAction( - wv, webframe_, ds->request(), webnav_type, disposition, is_redirect); + navigation_policy = d->PolicyForNavigationAction( + wv, webframe_, ds->request(), webnav_type, navigation_policy, + is_redirect); } } - if (disposition == CURRENT_TAB) { + if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) { policy_action = PolicyUse; - } else if (disposition == SAVE_TO_DISK) { + } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) { policy_action = PolicyDownload; } else { - if (disposition != IGNORE_ACTION) { + if (navigation_policy != WebKit::WebNavigationPolicyIgnore) { GURL referrer = webkit_glue::StringToGURL( request.httpHeaderField("Referer")); d->OpenURL(webframe_->GetWebViewImpl(), webkit_glue::KURLToGURL(request.url()), referrer, - disposition); + navigation_policy); } policy_action = PolicyIgnore; } @@ -1475,9 +1478,9 @@ String WebFrameLoaderClient::overrideMediaType() const { return rv; } -bool WebFrameLoaderClient::ActionSpecifiesDisposition( +bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy( const WebCore::NavigationAction& action, - WindowOpenDisposition* disposition) { + WebNavigationPolicy* policy) { if ((action.type() != NavigationTypeLinkClicked) || !action.event()->isMouseEvent()) return false; @@ -1493,11 +1496,20 @@ bool WebFrameLoaderClient::ActionSpecifiesDisposition( if (!new_tab_modifier && !shift && !alt) return false; - DCHECK(disposition); - if (new_tab_modifier) - *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; - else - *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; + DCHECK(policy); + if (new_tab_modifier) { + if (shift) { + *policy = WebKit::WebNavigationPolicyNewForegroundTab; + } else { + *policy = WebKit::WebNavigationPolicyNewBackgroundTab; + } + } else { + if (shift) { + *policy = WebKit::WebNavigationPolicyNewWindow; + } else { + *policy = WebKit::WebNavigationPolicyDownload; + } + } return true; } |