Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/renderer/render_view.cc

Issue 7242014: Update src/content/renderer to reflect WEBKIT_FRAME_TO_DOCUMENT_API_MOVE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_thread.cc ('k') | content/renderer/web_ui_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/renderer/render_view.h" 5 #include "content/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 void RenderView::PluginCrashed(const FilePath& plugin_path) { 536 void RenderView::PluginCrashed(const FilePath& plugin_path) {
537 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); 537 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path));
538 } 538 }
539 539
540 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, 540 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
541 const WebPluginParams& params) { 541 const WebPluginParams& params) {
542 webkit::npapi::WebPluginInfo info; 542 webkit::npapi::WebPluginInfo info;
543 bool found; 543 bool found;
544 std::string mime_type; 544 std::string mime_type;
545 Send(new ViewHostMsg_GetPluginInfo( 545 Send(new ViewHostMsg_GetPluginInfo(
546 routing_id_, params.url, frame->top()->url(), params.mimeType.utf8(), 546 routing_id_, params.url, frame->top()->document().url(),
547 &found, &info, &mime_type)); 547 params.mimeType.utf8(), &found, &info, &mime_type));
548 if (!found || !webkit::npapi::IsPluginEnabled(info)) 548 if (!found || !webkit::npapi::IsPluginEnabled(info))
549 return NULL; 549 return NULL;
550 550
551 bool pepper_plugin_was_registered = false; 551 bool pepper_plugin_was_registered = false;
552 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( 552 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
553 pepper_delegate_.CreatePepperPlugin(info.path, 553 pepper_delegate_.CreatePepperPlugin(info.path,
554 &pepper_plugin_was_registered)); 554 &pepper_plugin_was_registered));
555 if (pepper_plugin_was_registered) { 555 if (pepper_plugin_was_registered) {
556 if (pepper_module) 556 if (pepper_module)
557 return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); 557 return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
(...skipping 18 matching lines...) Expand all
576 delegate->SetContentAreaFocus(has_focus()); 576 delegate->SetContentAreaFocus(has_focus());
577 } 577 }
578 578
579 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { 579 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) {
580 plugin_delegates_.erase(delegate); 580 plugin_delegates_.erase(delegate);
581 } 581 }
582 582
583 bool RenderView::OnMessageReceived(const IPC::Message& message) { 583 bool RenderView::OnMessageReceived(const IPC::Message& message) {
584 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; 584 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
585 if (main_frame) 585 if (main_frame)
586 content::GetContentClient()->SetActiveURL(main_frame->url()); 586 content::GetContentClient()->SetActiveURL(main_frame->document().url());
587 587
588 ObserverListBase<RenderViewObserver>::Iterator it(observers_); 588 ObserverListBase<RenderViewObserver>::Iterator it(observers_);
589 RenderViewObserver* observer; 589 RenderViewObserver* observer;
590 while ((observer = it.GetNext()) != NULL) 590 while ((observer = it.GetNext()) != NULL)
591 if (observer->OnMessageReceived(message)) 591 if (observer->OnMessageReceived(message))
592 return true; 592 return true;
593 593
594 bool handled = true; 594 bool handled = true;
595 IPC_BEGIN_MESSAGE_MAP(RenderView, message) 595 IPC_BEGIN_MESSAGE_MAP(RenderView, message)
596 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 596 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) 1256 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)
1257 return NULL; 1257 return NULL;
1258 1258
1259 ViewHostMsg_CreateWindow_Params params; 1259 ViewHostMsg_CreateWindow_Params params;
1260 params.opener_id = routing_id_; 1260 params.opener_id = routing_id_;
1261 params.user_gesture = creator->isProcessingUserGesture(); 1261 params.user_gesture = creator->isProcessingUserGesture();
1262 params.window_container_type = WindowFeaturesToContainerType(features); 1262 params.window_container_type = WindowFeaturesToContainerType(features);
1263 params.session_storage_namespace_id = session_storage_namespace_id_; 1263 params.session_storage_namespace_id = session_storage_namespace_id_;
1264 params.frame_name = frame_name; 1264 params.frame_name = frame_name;
1265 params.opener_frame_id = creator->identifier(); 1265 params.opener_frame_id = creator->identifier();
1266 params.opener_url = creator->url(); 1266 params.opener_url = creator->document().url();
1267 params.opener_security_origin = creator->securityOrigin().toString().utf8(); 1267 params.opener_security_origin =
1268 creator->document().securityOrigin().toString().utf8();
1268 if (!request.isNull()) 1269 if (!request.isNull())
1269 params.target_url = request.url(); 1270 params.target_url = request.url();
1270 1271
1271 int32 routing_id = MSG_ROUTING_NONE; 1272 int32 routing_id = MSG_ROUTING_NONE;
1272 int64 cloned_session_storage_namespace_id; 1273 int64 cloned_session_storage_namespace_id;
1273 bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); 1274 bool opener_suppressed = creator->willSuppressOpenerInNewFrame();
1274 1275
1275 render_thread_->Send( 1276 render_thread_->Send(
1276 new ViewHostMsg_CreateWindow(params, 1277 new ViewHostMsg_CreateWindow(params,
1277 &routing_id, 1278 &routing_id,
(...skipping 10 matching lines...) Expand all
1288 shared_popup_counter_, 1289 shared_popup_counter_,
1289 routing_id, 1290 routing_id,
1290 cloned_session_storage_namespace_id, 1291 cloned_session_storage_namespace_id,
1291 frame_name); 1292 frame_name);
1292 view->opened_by_user_gesture_ = params.user_gesture; 1293 view->opened_by_user_gesture_ = params.user_gesture;
1293 1294
1294 // Record whether the creator frame is trying to suppress the opener field. 1295 // Record whether the creator frame is trying to suppress the opener field.
1295 view->opener_suppressed_ = opener_suppressed; 1296 view->opener_suppressed_ = opener_suppressed;
1296 1297
1297 // Record the security origin of the creator. 1298 // Record the security origin of the creator.
1298 GURL creator_url(creator->securityOrigin().toString().utf8()); 1299 GURL creator_url(creator->document().securityOrigin().toString().utf8());
1299 if (!creator_url.is_valid() || !creator_url.IsStandard()) 1300 if (!creator_url.is_valid() || !creator_url.IsStandard())
1300 creator_url = GURL(); 1301 creator_url = GURL();
1301 view->creator_url_ = creator_url; 1302 view->creator_url_ = creator_url;
1302 1303
1303 // Copy over the alternate error page URL so we can have alt error pages in 1304 // Copy over the alternate error page URL so we can have alt error pages in
1304 // the new render view (we don't need the browser to send the URL back down). 1305 // the new render view (we don't need the browser to send the URL back down).
1305 view->alternate_error_page_url_ = alternate_error_page_url_; 1306 view->alternate_error_page_url_ = alternate_error_page_url_;
1306 1307
1307 return view->webview(); 1308 return view->webview();
1308 } 1309 }
(...skipping 19 matching lines...) Expand all
1328 DCHECK(!external_popup_menu_.get()); 1329 DCHECK(!external_popup_menu_.get());
1329 external_popup_menu_.reset( 1330 external_popup_menu_.reset(
1330 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); 1331 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client));
1331 return external_popup_menu_.get(); 1332 return external_popup_menu_.get();
1332 } 1333 }
1333 1334
1334 RenderWidgetFullscreenPepper* RenderView::CreatePepperFullscreenContainer( 1335 RenderWidgetFullscreenPepper* RenderView::CreatePepperFullscreenContainer(
1335 webkit::ppapi::PluginInstance* plugin) { 1336 webkit::ppapi::PluginInstance* plugin) {
1336 GURL active_url; 1337 GURL active_url;
1337 if (webview() && webview()->mainFrame()) 1338 if (webview() && webview()->mainFrame())
1338 active_url = GURL(webview()->mainFrame()->url()); 1339 active_url = GURL(webview()->mainFrame()->document().url());
1339 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( 1340 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create(
1340 routing_id_, render_thread_, plugin, active_url); 1341 routing_id_, render_thread_, plugin, active_url);
1341 widget->show(WebKit::WebNavigationPolicyIgnore); 1342 widget->show(WebKit::WebNavigationPolicyIgnore);
1342 return widget; 1343 return widget;
1343 } 1344 }
1344 1345
1345 WebStorageNamespace* RenderView::createSessionStorageNamespace(unsigned quota) { 1346 WebStorageNamespace* RenderView::createSessionStorageNamespace(unsigned quota) {
1346 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) 1347 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
1347 return WebStorageNamespace::createSessionStorageNamespace(quota); 1348 return WebStorageNamespace::createSessionStorageNamespace(quota);
1348 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); 1349 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 ipc_params.accept_types = params.acceptTypes; 1566 ipc_params.accept_types = params.acceptTypes;
1566 1567
1567 return ScheduleFileChooser(ipc_params, chooser_completion); 1568 return ScheduleFileChooser(ipc_params, chooser_completion);
1568 } 1569 }
1569 1570
1570 void RenderView::runModalAlertDialog( 1571 void RenderView::runModalAlertDialog(
1571 WebFrame* frame, const WebString& message) { 1572 WebFrame* frame, const WebString& message) {
1572 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert, 1573 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert,
1573 message, 1574 message,
1574 string16(), 1575 string16(),
1575 frame->url(), 1576 frame->document().url(),
1576 NULL); 1577 NULL);
1577 } 1578 }
1578 1579
1579 bool RenderView::runModalConfirmDialog( 1580 bool RenderView::runModalConfirmDialog(
1580 WebFrame* frame, const WebString& message) { 1581 WebFrame* frame, const WebString& message) {
1581 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm, 1582 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm,
1582 message, 1583 message,
1583 string16(), 1584 string16(),
1584 frame->url(), 1585 frame->document().url(),
1585 NULL); 1586 NULL);
1586 } 1587 }
1587 1588
1588 bool RenderView::runModalPromptDialog( 1589 bool RenderView::runModalPromptDialog(
1589 WebFrame* frame, const WebString& message, const WebString& default_value, 1590 WebFrame* frame, const WebString& message, const WebString& default_value,
1590 WebString* actual_value) { 1591 WebString* actual_value) {
1591 string16 result; 1592 string16 result;
1592 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt, 1593 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt,
1593 message, 1594 message,
1594 default_value, 1595 default_value,
1595 frame->url(), 1596 frame->document().url(),
1596 &result); 1597 &result);
1597 if (ok) 1598 if (ok)
1598 actual_value->assign(result); 1599 actual_value->assign(result);
1599 return ok; 1600 return ok;
1600 } 1601 }
1601 1602
1602 bool RenderView::runModalBeforeUnloadDialog( 1603 bool RenderView::runModalBeforeUnloadDialog(
1603 WebFrame* frame, const WebString& message) { 1604 WebFrame* frame, const WebString& message) {
1604 // If we are swapping out, we have already run the beforeunload handler. 1605 // If we are swapping out, we have already run the beforeunload handler.
1605 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload 1606 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload
1606 // at all, to avoid running it twice. 1607 // at all, to avoid running it twice.
1607 if (is_swapped_out_) 1608 if (is_swapped_out_)
1608 return true; 1609 return true;
1609 1610
1610 bool success = false; 1611 bool success = false;
1611 // This is an ignored return value, but is included so we can accept the same 1612 // This is an ignored return value, but is included so we can accept the same
1612 // response as RunJavaScriptMessage. 1613 // response as RunJavaScriptMessage.
1613 string16 ignored_result; 1614 string16 ignored_result;
1614 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( 1615 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm(
1615 routing_id_, frame->url(), message, &success, &ignored_result)); 1616 routing_id_, frame->document().url(), message,
1617 &success, &ignored_result));
1616 return success; 1618 return success;
1617 } 1619 }
1618 1620
1619 void RenderView::showContextMenu( 1621 void RenderView::showContextMenu(
1620 WebFrame* frame, const WebContextMenuData& data) { 1622 WebFrame* frame, const WebContextMenuData& data) {
1621 ContextMenuParams params = ContextMenuParams(data); 1623 ContextMenuParams params = ContextMenuParams(data);
1622 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do 1624 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do
1623 // it. We replace it with an empty GURL so the appropriate items are disabled 1625 // it. We replace it with an empty GURL so the appropriate items are disabled
1624 // in the context menu. 1626 // in the context menu.
1625 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large 1627 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 IsNonLocalTopLevelNavigation(url, frame, type)) { 1972 IsNonLocalTopLevelNavigation(url, frame, type)) {
1971 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); 1973 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer")));
1972 // Reset these counters as the RenderView could be reused for the next 1974 // Reset these counters as the RenderView could be reused for the next
1973 // navigation. 1975 // navigation.
1974 page_id_ = -1; 1976 page_id_ = -1;
1975 last_page_id_sent_to_browser_ = -1; 1977 last_page_id_sent_to_browser_ = -1;
1976 OpenURL(url, referrer, default_policy); 1978 OpenURL(url, referrer, default_policy);
1977 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 1979 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
1978 } 1980 }
1979 1981
1980 GURL old_url(frame->url()); 1982 GURL old_url(frame->document().url());
1981 1983
1982 // Detect when we're crossing a permission-based boundary (e.g. into or out of 1984 // Detect when we're crossing a permission-based boundary (e.g. into or out of
1983 // an extension or app origin, leaving a WebUI page, etc). We only care about 1985 // an extension or app origin, leaving a WebUI page, etc). We only care about
1984 // top-level navigations within the current tab (as opposed to, for example, 1986 // top-level navigations within the current tab (as opposed to, for example,
1985 // opening a new window). But we sometimes navigate to about:blank to clear a 1987 // opening a new window). But we sometimes navigate to about:blank to clear a
1986 // tab, and we want to still allow that. 1988 // tab, and we want to still allow that.
1987 // 1989 //
1988 // Note: we do this only for GET requests because our mechanism for switching 1990 // Note: we do this only for GET requests because our mechanism for switching
1989 // processes only issues GET requests. In particular, POST requests don't 1991 // processes only issues GET requests. In particular, POST requests don't
1990 // work, because this mechanism does not preserve form POST data. If it 1992 // work, because this mechanism does not preserve form POST data. If it
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 // Must be a JavaScript navigation, which appears as "other". 2056 // Must be a JavaScript navigation, which appears as "other".
2055 type == WebKit::WebNavigationTypeOther; 2057 type == WebKit::WebNavigationTypeOther;
2056 2058
2057 // Recognize if this navigation is from a link with rel=noreferrer and 2059 // Recognize if this navigation is from a link with rel=noreferrer and
2058 // target=_blank attributes, in which case the opener will be suppressed. If 2060 // target=_blank attributes, in which case the opener will be suppressed. If
2059 // so, it is safe to load cross-site pages in a separate process, so we 2061 // so, it is safe to load cross-site pages in a separate process, so we
2060 // should let the browser handle it. 2062 // should let the browser handle it.
2061 bool is_noreferrer_and_blank_target = 2063 bool is_noreferrer_and_blank_target =
2062 // Frame should be top level and not yet navigated. 2064 // Frame should be top level and not yet navigated.
2063 frame->parent() == NULL && 2065 frame->parent() == NULL &&
2064 frame->url().isEmpty() && 2066 frame->document().url().isEmpty() &&
2065 historyBackListCount() < 1 && 2067 historyBackListCount() < 1 &&
2066 historyForwardListCount() < 1 && 2068 historyForwardListCount() < 1 &&
2067 // Links with rel=noreferrer will have no Referer field, and their 2069 // Links with rel=noreferrer will have no Referer field, and their
2068 // resulting frame will have its window.opener suppressed. 2070 // resulting frame will have its window.opener suppressed.
2069 // TODO(creis): should add a request.httpReferrer() method to help avoid 2071 // TODO(creis): should add a request.httpReferrer() method to help avoid
2070 // typos on the unusual spelling of Referer. 2072 // typos on the unusual spelling of Referer.
2071 request.httpHeaderField(WebString::fromUTF8("Referer")).isNull() && 2073 request.httpHeaderField(WebString::fromUTF8("Referer")).isNull() &&
2072 opener_suppressed_ && 2074 opener_suppressed_ &&
2073 frame->opener() == NULL && 2075 frame->opener() == NULL &&
2074 // Links with target=_blank will have no name. 2076 // Links with target=_blank will have no name.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 completed_client_redirect_src_ = GURL(); 2429 completed_client_redirect_src_ = GURL();
2428 2430
2429 // Check whether we have new encoding name. 2431 // Check whether we have new encoding name.
2430 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 2432 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
2431 } 2433 }
2432 2434
2433 void RenderView::didClearWindowObject(WebFrame* frame) { 2435 void RenderView::didClearWindowObject(WebFrame* frame) {
2434 FOR_EACH_OBSERVER(RenderViewObserver, observers_, 2436 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
2435 DidClearWindowObject(frame)); 2437 DidClearWindowObject(frame));
2436 2438
2437 GURL frame_url = frame->url(); 2439 GURL frame_url = frame->document().url();
2438 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && 2440 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) &&
2439 (frame_url.SchemeIs(chrome::kChromeUIScheme) || 2441 (frame_url.SchemeIs(chrome::kChromeUIScheme) ||
2440 frame_url.SchemeIs(chrome::kDataScheme))) { 2442 frame_url.SchemeIs(chrome::kDataScheme))) {
2441 GetWebUIBindings()->set_message_sender(this); 2443 GetWebUIBindings()->set_message_sender(this);
2442 GetWebUIBindings()->set_routing_id(routing_id_); 2444 GetWebUIBindings()->set_routing_id(routing_id_);
2443 GetWebUIBindings()->BindToJavascript(frame, "chrome"); 2445 GetWebUIBindings()->BindToJavascript(frame, "chrome");
2444 } 2446 }
2445 } 2447 }
2446 2448
2447 void RenderView::didCreateDocumentElement(WebFrame* frame) { 2449 void RenderView::didCreateDocumentElement(WebFrame* frame) {
2448 // Notify the browser about non-blank documents loading in the top frame. 2450 // Notify the browser about non-blank documents loading in the top frame.
2449 GURL url = frame->url(); 2451 GURL url = frame->document().url();
2450 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { 2452 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) {
2451 if (frame == webview()->mainFrame()) 2453 if (frame == webview()->mainFrame())
2452 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); 2454 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_));
2453 } 2455 }
2454 2456
2455 FOR_EACH_OBSERVER(RenderViewObserver, observers_, 2457 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
2456 DidCreateDocumentElement(frame)); 2458 DidCreateDocumentElement(frame));
2457 } 2459 }
2458 2460
2459 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, 2461 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 WebFrame* frame, unsigned identifier) { 2625 WebFrame* frame, unsigned identifier) {
2624 NavigationState* navigation_state = 2626 NavigationState* navigation_state =
2625 NavigationState::FromDataSource(frame->dataSource()); 2627 NavigationState::FromDataSource(frame->dataSource());
2626 if (!navigation_state->use_error_page()) 2628 if (!navigation_state->use_error_page())
2627 return; 2629 return;
2628 2630
2629 // Display error page, if appropriate. 2631 // Display error page, if appropriate.
2630 int http_status_code = navigation_state->http_status_code(); 2632 int http_status_code = navigation_state->http_status_code();
2631 if (http_status_code == 404) { 2633 if (http_status_code == 404) {
2632 // On 404s, try a remote search page as a fallback. 2634 // On 404s, try a remote search page as a fallback.
2633 const GURL& frame_url = frame->url(); 2635 const GURL& document_url = frame->document().url();
2634 2636
2635 const GURL& error_page_url = GetAlternateErrorPageURL(frame_url, HTTP_404); 2637 const GURL& error_page_url =
2638 GetAlternateErrorPageURL(document_url, HTTP_404);
2636 if (error_page_url.is_valid()) { 2639 if (error_page_url.is_valid()) {
2637 WebURLError original_error; 2640 WebURLError original_error;
2638 original_error.domain = "http"; 2641 original_error.domain = "http";
2639 original_error.reason = 404; 2642 original_error.reason = 404;
2640 original_error.unreachableURL = frame_url; 2643 original_error.unreachableURL = document_url;
2641 2644
2642 navigation_state->set_alt_error_page_fetcher( 2645 navigation_state->set_alt_error_page_fetcher(
2643 new AltErrorPageResourceFetcher( 2646 new AltErrorPageResourceFetcher(
2644 error_page_url, frame, original_error, 2647 error_page_url, frame, original_error,
2645 NewCallback(this, &RenderView::AltErrorPageFinished))); 2648 NewCallback(this, &RenderView::AltErrorPageFinished)));
2646 return; 2649 return;
2647 } 2650 }
2648 } 2651 }
2649 2652
2650 content::GetContentClient()->renderer()->ShowErrorPage( 2653 content::GetContentClient()->renderer()->ShowErrorPage(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 } 2790 }
2788 2791
2789 void RenderView::openFileSystem( 2792 void RenderView::openFileSystem(
2790 WebFrame* frame, 2793 WebFrame* frame,
2791 WebFileSystem::Type type, 2794 WebFileSystem::Type type,
2792 long long size, 2795 long long size,
2793 bool create, 2796 bool create,
2794 WebFileSystemCallbacks* callbacks) { 2797 WebFileSystemCallbacks* callbacks) {
2795 DCHECK(callbacks); 2798 DCHECK(callbacks);
2796 2799
2797 WebSecurityOrigin origin = frame->securityOrigin(); 2800 WebSecurityOrigin origin = frame->document().securityOrigin();
2798 if (origin.isEmpty()) { 2801 if (origin.isEmpty()) {
2799 // Uninitialized document? 2802 // Uninitialized document?
2800 callbacks->didFail(WebKit::WebFileErrorAbort); 2803 callbacks->didFail(WebKit::WebFileErrorAbort);
2801 return; 2804 return;
2802 } 2805 }
2803 2806
2804 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( 2807 ChildThread::current()->file_system_dispatcher()->OpenFileSystem(
2805 GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), 2808 GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type),
2806 size, create, new WebFileSystemCallbackDispatcher(callbacks)); 2809 size, create, new WebFileSystemCallbackDispatcher(callbacks));
2807 } 2810 }
2808 2811
2809 void RenderView::queryStorageUsageAndQuota( 2812 void RenderView::queryStorageUsageAndQuota(
2810 WebFrame* frame, 2813 WebFrame* frame,
2811 WebStorageQuotaType type, 2814 WebStorageQuotaType type,
2812 WebStorageQuotaCallbacks* callbacks) { 2815 WebStorageQuotaCallbacks* callbacks) {
2813 DCHECK(frame); 2816 DCHECK(frame);
2814 WebSecurityOrigin origin = frame->securityOrigin(); 2817 WebSecurityOrigin origin = frame->document().securityOrigin();
2815 if (origin.isEmpty()) { 2818 if (origin.isEmpty()) {
2816 // Uninitialized document? 2819 // Uninitialized document?
2817 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); 2820 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort);
2818 return; 2821 return;
2819 } 2822 }
2820 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( 2823 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota(
2821 GURL(origin.toString()), type, callbacks); 2824 GURL(origin.toString()), type, callbacks);
2822 } 2825 }
2823 2826
2824 void RenderView::requestStorageQuota( 2827 void RenderView::requestStorageQuota(
2825 WebFrame* frame, 2828 WebFrame* frame,
2826 WebStorageQuotaType type, 2829 WebStorageQuotaType type,
2827 unsigned long long requested_size, 2830 unsigned long long requested_size,
2828 WebStorageQuotaCallbacks* callbacks) { 2831 WebStorageQuotaCallbacks* callbacks) {
2829 DCHECK(frame); 2832 DCHECK(frame);
2830 WebSecurityOrigin origin = frame->securityOrigin(); 2833 WebSecurityOrigin origin = frame->document().securityOrigin();
2831 if (origin.isEmpty()) { 2834 if (origin.isEmpty()) {
2832 // Uninitialized document? 2835 // Uninitialized document?
2833 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); 2836 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort);
2834 return; 2837 return;
2835 } 2838 }
2836 ChildThread::current()->quota_dispatcher()->RequestStorageQuota( 2839 ChildThread::current()->quota_dispatcher()->RequestStorageQuota(
2837 routing_id(), GURL(origin.toString()), type, requested_size, callbacks); 2840 routing_id(), GURL(origin.toString()), type, requested_size, callbacks);
2838 } 2841 }
2839 2842
2840 // webkit_glue::WebPluginPageDelegate ----------------------------------------- 2843 // webkit_glue::WebPluginPageDelegate -----------------------------------------
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 void RenderView::OnScriptEvalRequest(const string16& frame_xpath, 3302 void RenderView::OnScriptEvalRequest(const string16& frame_xpath,
3300 const string16& jscript, 3303 const string16& jscript,
3301 int id, 3304 int id,
3302 bool notify_result) { 3305 bool notify_result) {
3303 EvaluateScript(frame_xpath, jscript, id, notify_result); 3306 EvaluateScript(frame_xpath, jscript, id, notify_result);
3304 } 3307 }
3305 3308
3306 void RenderView::OnCSSInsertRequest(const std::wstring& frame_xpath, 3309 void RenderView::OnCSSInsertRequest(const std::wstring& frame_xpath,
3307 const std::string& css, 3310 const std::string& css,
3308 const std::string& id) { 3311 const std::string& id) {
3309 WebFrame* web_frame = GetChildFrame(frame_xpath); 3312 WebFrame* frame = GetChildFrame(frame_xpath);
3310 if (!web_frame) 3313 if (!frame)
3311 return; 3314 return;
3312 3315
3313 web_frame->insertStyleText(WebString::fromUTF8(css), WebString::fromUTF8(id)); 3316 frame->document().insertStyleText(WebString::fromUTF8(css),
3317 WebString::fromUTF8(id));
3314 } 3318 }
3315 3319
3316 void RenderView::OnAllowBindings(int enabled_bindings_flags) { 3320 void RenderView::OnAllowBindings(int enabled_bindings_flags) {
3317 enabled_bindings_ |= enabled_bindings_flags; 3321 enabled_bindings_ |= enabled_bindings_flags;
3318 } 3322 }
3319 3323
3320 void RenderView::OnSetWebUIProperty(const std::string& name, 3324 void RenderView::OnSetWebUIProperty(const std::string& name,
3321 const std::string& value) { 3325 const std::string& value) {
3322 DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_)); 3326 DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_));
3323 GetWebUIBindings()->SetProperty(name, value); 3327 GetWebUIBindings()->SetProperty(name, value);
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
4133 routing_id_, minimum_percent, maximum_percent, remember)); 4137 routing_id_, minimum_percent, maximum_percent, remember));
4134 } 4138 }
4135 4139
4136 void RenderView::zoomLevelChanged() { 4140 void RenderView::zoomLevelChanged() {
4137 bool remember = !webview()->mainFrame()->document().isPluginDocument(); 4141 bool remember = !webview()->mainFrame()->document().isPluginDocument();
4138 4142
4139 // Tell the browser which url got zoomed so it can update the menu and the 4143 // Tell the browser which url got zoomed so it can update the menu and the
4140 // saved values if necessary 4144 // saved values if necessary
4141 Send(new ViewHostMsg_DidZoomURL( 4145 Send(new ViewHostMsg_DidZoomURL(
4142 routing_id_, webview()->zoomLevel(), remember, 4146 routing_id_, webview()->zoomLevel(), remember,
4143 GURL(webview()->mainFrame()->url()))); 4147 GURL(webview()->mainFrame()->document().url())));
4144 } 4148 }
4145 4149
4146 void RenderView::registerProtocolHandler(const WebString& scheme, 4150 void RenderView::registerProtocolHandler(const WebString& scheme,
4147 const WebString& base_url, 4151 const WebString& base_url,
4148 const WebString& url, 4152 const WebString& url,
4149 const WebString& title) { 4153 const WebString& title) {
4150 GURL base(base_url); 4154 GURL base(base_url);
4151 GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); 4155 GURL absolute_url = base.Resolve(UTF16ToUTF8(url));
4152 if (base.GetOrigin() != absolute_url.GetOrigin()) { 4156 if (base.GetOrigin() != absolute_url.GetOrigin()) {
4153 return; 4157 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4192 type != WebKit::WebNavigationTypeFormResubmitted && 4196 type != WebKit::WebNavigationTypeFormResubmitted &&
4193 type != WebKit::WebNavigationTypeBackForward) { 4197 type != WebKit::WebNavigationTypeBackForward) {
4194 // The opener relationship between the new window and the parent allows the 4198 // The opener relationship between the new window and the parent allows the
4195 // new window to script the parent and vice versa. This is not allowed if 4199 // new window to script the parent and vice versa. This is not allowed if
4196 // the origins of the two domains are different. This can be treated as a 4200 // the origins of the two domains are different. This can be treated as a
4197 // top level navigation and routed back to the host. 4201 // top level navigation and routed back to the host.
4198 WebKit::WebFrame* opener = frame->opener(); 4202 WebKit::WebFrame* opener = frame->opener();
4199 if (!opener) { 4203 if (!opener) {
4200 return true; 4204 return true;
4201 } else { 4205 } else {
4202 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) 4206 if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin())
4203 return true; 4207 return true;
4204 } 4208 }
4205 } 4209 }
4206 return false; 4210 return false;
4207 } 4211 }
4208 4212
4209 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, 4213 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code,
4210 IPC::PlatformFileForTransit file_for_transit, 4214 IPC::PlatformFileForTransit file_for_transit,
4211 int message_id) { 4215 int message_id) {
4212 pepper_delegate_.OnAsyncFileOpened( 4216 pepper_delegate_.OnAsyncFileOpened(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 const webkit_glue::CustomContextMenuContext& custom_context) { 4261 const webkit_glue::CustomContextMenuContext& custom_context) {
4258 if (custom_context.is_pepper_menu) 4262 if (custom_context.is_pepper_menu)
4259 pepper_delegate_.OnContextMenuClosed(custom_context); 4263 pepper_delegate_.OnContextMenuClosed(custom_context);
4260 else 4264 else
4261 context_menu_node_.reset(); 4265 context_menu_node_.reset();
4262 } 4266 }
4263 4267
4264 void RenderView::OnNetworkStateChanged(bool online) { 4268 void RenderView::OnNetworkStateChanged(bool online) {
4265 WebNetworkStateNotifier::setOnLine(online); 4269 WebNetworkStateNotifier::setOnLine(online);
4266 } 4270 }
OLDNEW
« no previous file with comments | « content/renderer/render_thread.cc ('k') | content/renderer/web_ui_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698