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

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

Issue 391923006: Extra parameter to pass sub-message direction for validation message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new function setValidationMessageDirection, to avoid replicate code in web_test_proxy Created 6 years, 3 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
OLDNEW
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 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 ipc_params.accept_types.reserve(params.acceptTypes.size()); 1804 ipc_params.accept_types.reserve(params.acceptTypes.size());
1805 for (size_t i = 0; i < params.acceptTypes.size(); ++i) 1805 for (size_t i = 0; i < params.acceptTypes.size(); ++i)
1806 ipc_params.accept_types.push_back(params.acceptTypes[i]); 1806 ipc_params.accept_types.push_back(params.acceptTypes[i]);
1807 #if defined(OS_ANDROID) 1807 #if defined(OS_ANDROID)
1808 ipc_params.capture = params.useMediaCapture; 1808 ipc_params.capture = params.useMediaCapture;
1809 #endif 1809 #endif
1810 1810
1811 return ScheduleFileChooser(ipc_params, chooser_completion); 1811 return ScheduleFileChooser(ipc_params, chooser_completion);
1812 } 1812 }
1813 1813
1814 void RenderViewImpl::setValidationMessageDirection(
1815 base::string16& wrapped_main_text,
1816 blink::WebTextDirection main_text_hint,
1817 base::string16& wrapped_sub_text,
1818 blink::WebTextDirection sub_text_hint) {
1819 if (main_text_hint == blink::WebTextDirectionLeftToRight) {
1820 wrapped_main_text =
1821 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text);
1822 } else if (main_text_hint == blink::WebTextDirectionRightToLeft &&
1823 !base::i18n::IsRTL()) {
1824 base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
1825 }
1826
1827 if (!wrapped_sub_text.empty()) {
1828 if (sub_text_hint == blink::WebTextDirectionLeftToRight) {
1829 wrapped_sub_text =
1830 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
1831 } else if (sub_text_hint == blink::WebTextDirectionRightToLeft) {
1832 base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
1833 }
1834 }
1835 }
1836
1814 void RenderViewImpl::showValidationMessage( 1837 void RenderViewImpl::showValidationMessage(
1815 const blink::WebRect& anchor_in_root_view, 1838 const blink::WebRect& anchor_in_root_view,
1816 const blink::WebString& main_text, 1839 const blink::WebString& main_text,
1840 blink::WebTextDirection main_text_hint,
1817 const blink::WebString& sub_text, 1841 const blink::WebString& sub_text,
1818 blink::WebTextDirection hint) { 1842 blink::WebTextDirection sub_text_hint) {
1819 base::string16 wrapped_main_text = main_text; 1843 base::string16 wrapped_main_text = main_text;
1820 base::string16 wrapped_sub_text = sub_text; 1844 base::string16 wrapped_sub_text = sub_text;
1821 if (hint == blink::WebTextDirectionLeftToRight) { 1845
1822 wrapped_main_text = 1846 setValidationMessageDirection(
1823 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text); 1847 wrapped_main_text, main_text_hint, wrapped_sub_text, sub_text_hint);
1824 if (!wrapped_sub_text.empty()) { 1848
1825 wrapped_sub_text =
1826 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
1827 }
1828 } else if (hint == blink::WebTextDirectionRightToLeft
1829 && !base::i18n::IsRTL()) {
1830 base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
1831 if (!wrapped_sub_text.empty()) {
1832 base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
1833 }
1834 }
1835 Send(new ViewHostMsg_ShowValidationMessage( 1849 Send(new ViewHostMsg_ShowValidationMessage(
1836 routing_id(), AdjustValidationMessageAnchor(anchor_in_root_view), 1850 routing_id(), AdjustValidationMessageAnchor(anchor_in_root_view),
1837 wrapped_main_text, wrapped_sub_text)); 1851 wrapped_main_text, wrapped_sub_text));
1838 } 1852 }
1839 1853
1840 void RenderViewImpl::hideValidationMessage() { 1854 void RenderViewImpl::hideValidationMessage() {
1841 Send(new ViewHostMsg_HideValidationMessage(routing_id())); 1855 Send(new ViewHostMsg_HideValidationMessage(routing_id()));
1842 } 1856 }
1843 1857
1844 void RenderViewImpl::moveValidationMessage( 1858 void RenderViewImpl::moveValidationMessage(
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 std::vector<gfx::Size> sizes; 4217 std::vector<gfx::Size> sizes;
4204 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4218 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4205 if (!url.isEmpty()) 4219 if (!url.isEmpty())
4206 urls.push_back( 4220 urls.push_back(
4207 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4221 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4208 } 4222 }
4209 SendUpdateFaviconURL(urls); 4223 SendUpdateFaviconURL(urls);
4210 } 4224 }
4211 4225
4212 } // namespace content 4226 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698