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

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

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years 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
« no previous file with comments | « content/renderer/render_frame_proxy.cc ('k') | content/renderer/render_widget.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) 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 #include <memory> 9 #include <memory>
10 10
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 namespace { 378 namespace {
379 379
380 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, 380 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*,
381 const base::string16&, 381 const base::string16&,
382 UScriptCode); 382 UScriptCode);
383 383
384 void SetStandardFontFamilyWrapper(WebSettings* settings, 384 void SetStandardFontFamilyWrapper(WebSettings* settings,
385 const base::string16& font, 385 const base::string16& font,
386 UScriptCode script) { 386 UScriptCode script) {
387 settings->setStandardFontFamily(font, script); 387 settings->setStandardFontFamily(WebString::fromUTF16(font), script);
388 } 388 }
389 389
390 void SetFixedFontFamilyWrapper(WebSettings* settings, 390 void SetFixedFontFamilyWrapper(WebSettings* settings,
391 const base::string16& font, 391 const base::string16& font,
392 UScriptCode script) { 392 UScriptCode script) {
393 settings->setFixedFontFamily(font, script); 393 settings->setFixedFontFamily(WebString::fromUTF16(font), script);
394 } 394 }
395 395
396 void SetSerifFontFamilyWrapper(WebSettings* settings, 396 void SetSerifFontFamilyWrapper(WebSettings* settings,
397 const base::string16& font, 397 const base::string16& font,
398 UScriptCode script) { 398 UScriptCode script) {
399 settings->setSerifFontFamily(font, script); 399 settings->setSerifFontFamily(WebString::fromUTF16(font), script);
400 } 400 }
401 401
402 void SetSansSerifFontFamilyWrapper(WebSettings* settings, 402 void SetSansSerifFontFamilyWrapper(WebSettings* settings,
403 const base::string16& font, 403 const base::string16& font,
404 UScriptCode script) { 404 UScriptCode script) {
405 settings->setSansSerifFontFamily(font, script); 405 settings->setSansSerifFontFamily(WebString::fromUTF16(font), script);
406 } 406 }
407 407
408 void SetCursiveFontFamilyWrapper(WebSettings* settings, 408 void SetCursiveFontFamilyWrapper(WebSettings* settings,
409 const base::string16& font, 409 const base::string16& font,
410 UScriptCode script) { 410 UScriptCode script) {
411 settings->setCursiveFontFamily(font, script); 411 settings->setCursiveFontFamily(WebString::fromUTF16(font), script);
412 } 412 }
413 413
414 void SetFantasyFontFamilyWrapper(WebSettings* settings, 414 void SetFantasyFontFamilyWrapper(WebSettings* settings,
415 const base::string16& font, 415 const base::string16& font,
416 UScriptCode script) { 416 UScriptCode script) {
417 settings->setFantasyFontFamily(font, script); 417 settings->setFantasyFontFamily(WebString::fromUTF16(font), script);
418 } 418 }
419 419
420 void SetPictographFontFamilyWrapper(WebSettings* settings, 420 void SetPictographFontFamilyWrapper(WebSettings* settings,
421 const base::string16& font, 421 const base::string16& font,
422 UScriptCode script) { 422 UScriptCode script) {
423 settings->setPictographFontFamily(font, script); 423 settings->setPictographFontFamily(WebString::fromUTF16(font), script);
424 } 424 }
425 425
426 // If |scriptCode| is a member of a family of "similar" script codes, returns 426 // If |scriptCode| is a member of a family of "similar" script codes, returns
427 // the script code in that family that is used by WebKit for font selection 427 // the script code in that family that is used by WebKit for font selection
428 // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are 428 // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are
429 // considered equivalent for the purposes of font selection. WebKit uses the 429 // considered equivalent for the purposes of font selection. WebKit uses the
430 // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is 430 // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is
431 // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit 431 // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit
432 // uses different scripts than the ones in Chrome pref names because the version 432 // uses different scripts than the ones in Chrome pref names because the version
433 // of ICU included on certain ports does not have some of the newer scripts. If 433 // of ICU included on certain ports does not have some of the newer scripts. If
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 WebNavigationPolicy policy, 1413 WebNavigationPolicy policy,
1414 bool suppress_opener) { 1414 bool suppress_opener) {
1415 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); 1415 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New();
1416 params->opener_id = GetRoutingID(); 1416 params->opener_id = GetRoutingID();
1417 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 1417 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
1418 if (GetContentClient()->renderer()->AllowPopup()) 1418 if (GetContentClient()->renderer()->AllowPopup())
1419 params->user_gesture = true; 1419 params->user_gesture = true;
1420 params->window_container_type = WindowFeaturesToContainerType(features); 1420 params->window_container_type = WindowFeaturesToContainerType(features);
1421 params->session_storage_namespace_id = session_storage_namespace_id_; 1421 params->session_storage_namespace_id = session_storage_namespace_id_;
1422 if (frame_name != "_blank") 1422 if (frame_name != "_blank")
1423 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); 1423 params->frame_name = frame_name.utf8();
1424 params->opener_render_frame_id = 1424 params->opener_render_frame_id =
1425 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); 1425 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID();
1426 params->opener_url = creator->document().url(); 1426 params->opener_url = creator->document().url();
1427 1427
1428 // The browser process uses the top frame's URL for a content settings check 1428 // The browser process uses the top frame's URL for a content settings check
1429 // to determine whether the popup is allowed. If the top frame is remote, 1429 // to determine whether the popup is allowed. If the top frame is remote,
1430 // its URL is not available, so use its replicated origin instead. 1430 // its URL is not available, so use its replicated origin instead.
1431 // 1431 //
1432 // TODO(alexmos): This works fine for regular origins but may break path 1432 // TODO(alexmos): This works fine for regular origins but may break path
1433 // matching for file URLs with OOP subframes that open popups. This should 1433 // matching for file URLs with OOP subframes that open popups. This should
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 } 1622 }
1623 } 1623 }
1624 } 1624 }
1625 1625
1626 void RenderViewImpl::showValidationMessage( 1626 void RenderViewImpl::showValidationMessage(
1627 const blink::WebRect& anchor_in_viewport, 1627 const blink::WebRect& anchor_in_viewport,
1628 const blink::WebString& main_text, 1628 const blink::WebString& main_text,
1629 blink::WebTextDirection main_text_hint, 1629 blink::WebTextDirection main_text_hint,
1630 const blink::WebString& sub_text, 1630 const blink::WebString& sub_text,
1631 blink::WebTextDirection sub_text_hint) { 1631 blink::WebTextDirection sub_text_hint) {
1632 base::string16 wrapped_main_text = main_text; 1632 base::string16 wrapped_main_text = main_text.utf16();
1633 base::string16 wrapped_sub_text = sub_text; 1633 base::string16 wrapped_sub_text = sub_text.utf16();
1634 1634
1635 SetValidationMessageDirection( 1635 SetValidationMessageDirection(
1636 &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint); 1636 &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint);
1637 1637
1638 Send(new ViewHostMsg_ShowValidationMessage( 1638 Send(new ViewHostMsg_ShowValidationMessage(
1639 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport), 1639 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport),
1640 wrapped_main_text, wrapped_sub_text)); 1640 wrapped_main_text, wrapped_sub_text));
1641 } 1641 }
1642 1642
1643 void RenderViewImpl::hideValidationMessage() { 1643 void RenderViewImpl::hideValidationMessage() {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 } 2156 }
2157 2157
2158 void RenderViewImpl::OnEnumerateDirectoryResponse( 2158 void RenderViewImpl::OnEnumerateDirectoryResponse(
2159 int id, 2159 int id,
2160 const std::vector<base::FilePath>& paths) { 2160 const std::vector<base::FilePath>& paths) {
2161 if (!enumeration_completions_[id]) 2161 if (!enumeration_completions_[id])
2162 return; 2162 return;
2163 2163
2164 WebVector<WebString> ws_file_names(paths.size()); 2164 WebVector<WebString> ws_file_names(paths.size());
2165 for (size_t i = 0; i < paths.size(); ++i) 2165 for (size_t i = 0; i < paths.size(); ++i)
2166 ws_file_names[i] = paths[i].AsUTF16Unsafe(); 2166 ws_file_names[i] = blink::FilePathToWebString(paths[i]);
2167 2167
2168 enumeration_completions_[id]->didChooseFile(ws_file_names); 2168 enumeration_completions_[id]->didChooseFile(ws_file_names);
2169 enumeration_completions_.erase(id); 2169 enumeration_completions_.erase(id);
2170 } 2170 }
2171 2171
2172 void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, 2172 void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size,
2173 const gfx::Size& max_size) { 2173 const gfx::Size& max_size) {
2174 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); 2174 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2175 if (!webview()) 2175 if (!webview())
2176 return; 2176 return;
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2812 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2813 } 2813 }
2814 2814
2815 std::unique_ptr<InputEventAck> ack( 2815 std::unique_ptr<InputEventAck> ack(
2816 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, 2816 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type,
2817 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2817 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2818 OnInputEventAck(std::move(ack)); 2818 OnInputEventAck(std::move(ack));
2819 } 2819 }
2820 2820
2821 } // namespace content 2821 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_proxy.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698