| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | |
| 12 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/i18n/rtl.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/stats_counters.h" | 14 #include "base/stats_counters.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/waitable_event.h" | 17 #include "base/waitable_event.h" |
| 18 #include "chrome/browser/child_process_security_policy.h" | 18 #include "chrome/browser/child_process_security_policy.h" |
| 19 #include "chrome/browser/cross_site_request_manager.h" | 19 #include "chrome/browser/cross_site_request_manager.h" |
| 20 #include "chrome/browser/debugger/devtools_manager.h" | 20 #include "chrome/browser/debugger/devtools_manager.h" |
| 21 #include "chrome/browser/dom_operation_notification_details.h" | 21 #include "chrome/browser/dom_operation_notification_details.h" |
| 22 #include "chrome/browser/extensions/extension_message_service.h" | 22 #include "chrome/browser/extensions/extension_message_service.h" |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 // when the locale direction is different than the tooltip direction hint. | 1290 // when the locale direction is different than the tooltip direction hint. |
| 1291 // | 1291 // |
| 1292 // Currently, we use element's directionality as the tooltip direction hint. | 1292 // Currently, we use element's directionality as the tooltip direction hint. |
| 1293 // An alternate solution would be to set the overall directionality based on | 1293 // An alternate solution would be to set the overall directionality based on |
| 1294 // trying to detect the directionality from the tooltip text rather than the | 1294 // trying to detect the directionality from the tooltip text rather than the |
| 1295 // element direction. One could argue that would be a preferable solution | 1295 // element direction. One could argue that would be a preferable solution |
| 1296 // but we use the current approach to match Fx & IE's behavior. | 1296 // but we use the current approach to match Fx & IE's behavior. |
| 1297 std::wstring wrapped_tooltip_text = tooltip_text; | 1297 std::wstring wrapped_tooltip_text = tooltip_text; |
| 1298 if (!tooltip_text.empty()) { | 1298 if (!tooltip_text.empty()) { |
| 1299 if (text_direction_hint == WebKit::WebTextDirectionLeftToRight && | 1299 if (text_direction_hint == WebKit::WebTextDirectionLeftToRight && |
| 1300 l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 1300 base::i18n::IsRTL()) { |
| 1301 // Force the tooltip to have LTR directionality. | 1301 // Force the tooltip to have LTR directionality. |
| 1302 l10n_util::WrapStringWithLTRFormatting(&wrapped_tooltip_text); | 1302 base::i18n::WrapStringWithLTRFormatting(&wrapped_tooltip_text); |
| 1303 } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && | 1303 } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && |
| 1304 l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) { | 1304 !base::i18n::IsRTL()) { |
| 1305 // Force the tooltip to have RTL directionality. | 1305 // Force the tooltip to have RTL directionality. |
| 1306 l10n_util::WrapStringWithRTLFormatting(&wrapped_tooltip_text); | 1306 base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 if (view()) | 1309 if (view()) |
| 1310 view()->SetTooltipText(wrapped_tooltip_text); | 1310 view()->SetTooltipText(wrapped_tooltip_text); |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 void RenderViewHost::OnMsgSelectionChanged(const std::string& text) { | 1313 void RenderViewHost::OnMsgSelectionChanged(const std::string& text) { |
| 1314 if (view()) | 1314 if (view()) |
| 1315 view()->SelectionChanged(text); | 1315 view()->SelectionChanged(text); |
| 1316 } | 1316 } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 integration_delegate->OnPageTranslated(page_id, | 1857 integration_delegate->OnPageTranslated(page_id, |
| 1858 original_lang, translated_lang); | 1858 original_lang, translated_lang); |
| 1859 } | 1859 } |
| 1860 | 1860 |
| 1861 void RenderViewHost::OnContentBlocked(ContentSettingsType type) { | 1861 void RenderViewHost::OnContentBlocked(ContentSettingsType type) { |
| 1862 RenderViewHostDelegate::Resource* resource_delegate = | 1862 RenderViewHostDelegate::Resource* resource_delegate = |
| 1863 delegate_->GetResourceDelegate(); | 1863 delegate_->GetResourceDelegate(); |
| 1864 if (resource_delegate) | 1864 if (resource_delegate) |
| 1865 resource_delegate->OnContentBlocked(type); | 1865 resource_delegate->OnContentBlocked(type); |
| 1866 } | 1866 } |
| OLD | NEW |