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

Side by Side Diff: content/browser/webui/web_ui_message_handler.cc

Issue 10824033: Coverity: Fix several pass-by-values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win build fix. Created 8 years, 4 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
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/public/browser/web_ui_message_handler.h" 5 #include "content/public/browser/web_ui_message_handler.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 void WebUIMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, 16 void WebUIMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
17 string16 title, 17 const string16& title,
18 const GURL& gurl) { 18 const GURL& gurl) {
19 dictionary->SetString("url", gurl.spec()); 19 dictionary->SetString("url", gurl.spec());
20 20
21 bool using_url_as_the_title = false; 21 bool using_url_as_the_title = false;
22 string16 title_to_set(title);
22 if (title.empty()) { 23 if (title.empty()) {
23 using_url_as_the_title = true; 24 using_url_as_the_title = true;
24 title = UTF8ToUTF16(gurl.spec()); 25 title_to_set = UTF8ToUTF16(gurl.spec());
25 } 26 }
26 27
27 // Since the title can contain BiDi text, we need to mark the text as either 28 // Since the title can contain BiDi text, we need to mark the text as either
28 // RTL or LTR, depending on the characters in the string. If we use the URL 29 // RTL or LTR, depending on the characters in the string. If we use the URL
29 // as the title, we mark the title as LTR since URLs are always treated as 30 // as the title, we mark the title as LTR since URLs are always treated as
30 // left to right strings. 31 // left to right strings.
31 string16 title_to_set(title);
32 if (base::i18n::IsRTL()) { 32 if (base::i18n::IsRTL()) {
33 if (using_url_as_the_title) { 33 if (using_url_as_the_title) {
34 base::i18n::WrapStringWithLTRFormatting(&title_to_set); 34 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
35 } else { 35 } else {
36 base::i18n::AdjustStringForLocaleDirection(&title_to_set); 36 base::i18n::AdjustStringForLocaleDirection(&title_to_set);
37 } 37 }
38 } 38 }
39 dictionary->SetString("title", title_to_set); 39 dictionary->SetString("title", title_to_set);
40 } 40 }
41 41
(...skipping 24 matching lines...) Expand all
66 66
67 string16 WebUIMessageHandler::ExtractStringValue(const ListValue* value) { 67 string16 WebUIMessageHandler::ExtractStringValue(const ListValue* value) {
68 string16 string16_value; 68 string16 string16_value;
69 if (value->GetString(0, &string16_value)) 69 if (value->GetString(0, &string16_value))
70 return string16_value; 70 return string16_value;
71 NOTREACHED(); 71 NOTREACHED();
72 return string16(); 72 return string16();
73 } 73 }
74 74
75 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_process_util.cc ('k') | content/public/browser/web_ui_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698