OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 std::string error_html; | 1393 std::string error_html; |
1394 GetContentClient()->renderer()->GetNavigationErrorStrings( | 1394 GetContentClient()->renderer()->GetNavigationErrorStrings( |
1395 this, frame, failed_request, error, &error_html, NULL); | 1395 this, frame, failed_request, error, &error_html, NULL); |
1396 | 1396 |
1397 frame->loadHTMLString(error_html, | 1397 frame->loadHTMLString(error_html, |
1398 GURL(kUnreachableWebDataURL), | 1398 GURL(kUnreachableWebDataURL), |
1399 error.unreachableURL, | 1399 error.unreachableURL, |
1400 replace); | 1400 replace); |
1401 } | 1401 } |
1402 | 1402 |
1403 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, | |
1404 const base::string16& message, | |
1405 const base::string16& default_value, | |
1406 const GURL& frame_url, | |
1407 base::string16* result) { | |
1408 // Don't allow further dialogs if we are waiting to swap out, since the | |
1409 // PageGroupLoadDeferrer in our stack prevents it. | |
1410 if (suppress_dialogs_until_swap_out_) | |
1411 return false; | |
1412 | |
1413 bool success = false; | |
1414 base::string16 result_temp; | |
1415 if (!result) | |
1416 result = &result_temp; | |
1417 | |
1418 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( | |
1419 routing_id_, message, default_value, frame_url, type, &success, result)); | |
1420 return success; | |
1421 } | |
1422 | |
1423 bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { | 1403 bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
1424 // Before WebKit asks us to show an alert (etc.), it takes care of doing the | 1404 // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
1425 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog | 1405 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
1426 // it is particularly important that we do not call willEnterModalLoop as | 1406 // it is particularly important that we do not call willEnterModalLoop as |
1427 // that would defer resource loads for the dialog itself. | 1407 // that would defer resource loads for the dialog itself. |
1428 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 1408 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
1429 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); | 1409 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
1430 | 1410 |
1431 message->EnableMessagePumping(); // Runs a nested message loop. | 1411 message->EnableMessagePumping(); // Runs a nested message loop. |
1432 return Send(message); | 1412 return Send(message); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 ipc_params.accept_types.push_back(params.acceptTypes[i]); | 1708 ipc_params.accept_types.push_back(params.acceptTypes[i]); |
1729 #if defined(OS_ANDROID) | 1709 #if defined(OS_ANDROID) |
1730 ipc_params.capture = params.useMediaCapture; | 1710 ipc_params.capture = params.useMediaCapture; |
1731 #endif | 1711 #endif |
1732 | 1712 |
1733 return ScheduleFileChooser(ipc_params, chooser_completion); | 1713 return ScheduleFileChooser(ipc_params, chooser_completion); |
1734 } | 1714 } |
1735 | 1715 |
1736 void RenderViewImpl::runModalAlertDialog(WebLocalFrame* frame, | 1716 void RenderViewImpl::runModalAlertDialog(WebLocalFrame* frame, |
1737 const WebString& message) { | 1717 const WebString& message) { |
1738 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, | 1718 RenderFrameImpl::FromWebFrame(frame)->runModalAlertDialog(message); |
1739 message, | |
1740 base::string16(), | |
1741 frame->document().url(), | |
1742 NULL); | |
1743 } | 1719 } |
1744 | 1720 |
1745 bool RenderViewImpl::runModalConfirmDialog(WebLocalFrame* frame, | 1721 bool RenderViewImpl::runModalConfirmDialog(WebLocalFrame* frame, |
1746 const WebString& message) { | 1722 const WebString& message) { |
1747 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, | 1723 return RenderFrameImpl::FromWebFrame(frame)->runModalConfirmDialog(message); |
1748 message, | |
1749 base::string16(), | |
1750 frame->document().url(), | |
1751 NULL); | |
1752 } | 1724 } |
1753 | 1725 |
1754 bool RenderViewImpl::runModalPromptDialog(WebLocalFrame* frame, | 1726 bool RenderViewImpl::runModalPromptDialog(WebLocalFrame* frame, |
1755 const WebString& message, | 1727 const WebString& message, |
1756 const WebString& default_value, | 1728 const WebString& default_value, |
1757 WebString* actual_value) { | 1729 WebString* actual_value) { |
1758 base::string16 result; | 1730 return RenderFrameImpl::FromWebFrame(frame)-> |
1759 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT, | 1731 runModalPromptDialog(message, default_value, actual_value); |
1760 message, | |
1761 default_value, | |
1762 frame->document().url(), | |
1763 &result); | |
1764 if (ok) | |
1765 actual_value->assign(result); | |
1766 return ok; | |
1767 } | 1732 } |
1768 | 1733 |
1769 bool RenderViewImpl::runModalBeforeUnloadDialog(WebLocalFrame* frame, | 1734 bool RenderViewImpl::runModalBeforeUnloadDialog(WebLocalFrame* frame, |
1770 const WebString& message) { | 1735 const WebString& message) { |
1771 bool is_reload = false; | 1736 bool is_reload = false; |
1772 WebDataSource* ds = frame->provisionalDataSource(); | 1737 WebDataSource* ds = frame->provisionalDataSource(); |
1773 if (ds) | 1738 if (ds) |
1774 is_reload = (ds->navigationType() == blink::WebNavigationTypeReload); | 1739 is_reload = (ds->navigationType() == blink::WebNavigationTypeReload); |
1775 return runModalBeforeUnloadDialog(frame, is_reload, message); | 1740 return RenderFrameImpl::FromWebFrame(frame)-> |
| 1741 runModalBeforeUnloadDialog(is_reload, message); |
1776 } | 1742 } |
1777 | 1743 |
1778 bool RenderViewImpl::runModalBeforeUnloadDialog(WebLocalFrame* frame, | 1744 void RenderViewImpl::runModalAlertDialog(const WebString& message) { |
1779 bool is_reload, | 1745 /* bogus version of the function to avoid errors */ |
| 1746 NOTIMPLEMENTED(); |
| 1747 } |
| 1748 |
| 1749 bool RenderViewImpl::runModalConfirmDialog(const WebString& message) { |
| 1750 /* bogus version of the function to avoid errors */ |
| 1751 NOTIMPLEMENTED(); |
| 1752 return false; |
| 1753 } |
| 1754 |
| 1755 bool RenderViewImpl::runModalPromptDialog(const WebString& message, |
| 1756 const WebString& default_value, |
| 1757 WebString* actual_value) { |
| 1758 /* bogus version of the function to avoid errors */ |
| 1759 NOTIMPLEMENTED(); |
| 1760 return false; |
| 1761 } |
| 1762 |
| 1763 bool RenderViewImpl::runModalBeforeUnloadDialog(bool is_reload, |
1780 const WebString& message) { | 1764 const WebString& message) { |
1781 // If we are swapping out, we have already run the beforeunload handler. | 1765 /* bogus version of the function to avoid errors */ |
1782 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload | 1766 NOTIMPLEMENTED(); |
1783 // at all, to avoid running it twice. | 1767 return false; |
1784 if (is_swapped_out_) | |
1785 return true; | |
1786 | |
1787 // Don't allow further dialogs if we are waiting to swap out, since the | |
1788 // PageGroupLoadDeferrer in our stack prevents it. | |
1789 if (suppress_dialogs_until_swap_out_) | |
1790 return false; | |
1791 | |
1792 bool success = false; | |
1793 // This is an ignored return value, but is included so we can accept the same | |
1794 // response as RunJavaScriptMessage. | |
1795 base::string16 ignored_result; | |
1796 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( | |
1797 routing_id_, frame->document().url(), message, is_reload, | |
1798 &success, &ignored_result)); | |
1799 return success; | |
1800 } | 1768 } |
1801 | 1769 |
1802 void RenderViewImpl::showValidationMessage( | 1770 void RenderViewImpl::showValidationMessage( |
1803 const blink::WebRect& anchor_in_root_view, | 1771 const blink::WebRect& anchor_in_root_view, |
1804 const blink::WebString& main_text, | 1772 const blink::WebString& main_text, |
1805 const blink::WebString& sub_text, | 1773 const blink::WebString& sub_text, |
1806 blink::WebTextDirection hint) { | 1774 blink::WebTextDirection hint) { |
1807 base::string16 wrapped_main_text = main_text; | 1775 base::string16 wrapped_main_text = main_text; |
1808 base::string16 wrapped_sub_text = sub_text; | 1776 base::string16 wrapped_sub_text = sub_text; |
1809 if (hint == blink::WebTextDirectionLeftToRight) { | 1777 if (hint == blink::WebTextDirectionLeftToRight) { |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2973 } | 2941 } |
2974 | 2942 |
2975 float RenderViewImpl::GetFilteredTimePerFrame() const { | 2943 float RenderViewImpl::GetFilteredTimePerFrame() const { |
2976 return filtered_time_per_frame(); | 2944 return filtered_time_per_frame(); |
2977 } | 2945 } |
2978 | 2946 |
2979 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { | 2947 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
2980 return visibilityState(); | 2948 return visibilityState(); |
2981 } | 2949 } |
2982 | 2950 |
2983 void RenderViewImpl::RunModalAlertDialog(blink::WebLocalFrame* frame, | |
2984 const blink::WebString& message) { | |
2985 return runModalAlertDialog(frame, message); | |
2986 } | |
2987 | |
2988 void RenderViewImpl::DidStartLoading() { | 2951 void RenderViewImpl::DidStartLoading() { |
2989 main_render_frame_->didStartLoading(true); | 2952 main_render_frame_->didStartLoading(true); |
2990 } | 2953 } |
2991 | 2954 |
2992 void RenderViewImpl::DidStopLoading() { | 2955 void RenderViewImpl::DidStopLoading() { |
2993 main_render_frame_->didStopLoading(); | 2956 main_render_frame_->didStopLoading(); |
2994 } | 2957 } |
2995 | 2958 |
2996 void RenderViewImpl::DidPlay(blink::WebMediaPlayer* player) { | 2959 void RenderViewImpl::DidPlay(blink::WebMediaPlayer* player) { |
2997 Send(new ViewHostMsg_MediaPlayingNotification(routing_id_, | 2960 Send(new ViewHostMsg_MediaPlayingNotification(routing_id_, |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4750 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); | 4713 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); |
4751 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4714 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4752 if (!url.isEmpty()) | 4715 if (!url.isEmpty()) |
4753 urls.push_back( | 4716 urls.push_back( |
4754 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4717 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4755 } | 4718 } |
4756 SendUpdateFaviconURL(urls); | 4719 SendUpdateFaviconURL(urls); |
4757 } | 4720 } |
4758 | 4721 |
4759 } // namespace content | 4722 } // namespace content |
OLD | NEW |