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

Side by Side Diff: chrome/browser/ui/webui/version_handler.cc

Issue 23686018: Fix a memory leak in chrome://version handler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "chrome/browser/ui/webui/version_handler.h" 5 #include "chrome/browser/ui/webui/version_handler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 content::BrowserThread::FILE, FROM_HERE, 78 content::BrowserThread::FILE, FROM_HERE,
79 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(), 79 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(),
80 base::Unretained(exec_path_buffer), 80 base::Unretained(exec_path_buffer),
81 base::Unretained(profile_path_buffer)), 81 base::Unretained(profile_path_buffer)),
82 base::Bind(&VersionHandler::OnGotFilePaths, 82 base::Bind(&VersionHandler::OnGotFilePaths,
83 weak_ptr_factory_.GetWeakPtr(), 83 weak_ptr_factory_.GetWeakPtr(),
84 base::Owned(exec_path_buffer), 84 base::Owned(exec_path_buffer),
85 base::Owned(profile_path_buffer))); 85 base::Owned(profile_path_buffer)));
86 86
87 // Respond with the variations info immediately. 87 // Respond with the variations info immediately.
88 scoped_ptr<ListValue> variations_list(new ListValue());
89 std::vector<std::string> variations; 88 std::vector<std::string> variations;
90 #if !defined(NDEBUG) 89 #if !defined(NDEBUG)
91 base::FieldTrial::ActiveGroups active_groups; 90 base::FieldTrial::ActiveGroups active_groups;
92 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); 91 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups);
93 92
94 const unsigned char kNonBreakingHyphenUTF8[] = { 0xE2, 0x80, 0x91, '\0' }; 93 const unsigned char kNonBreakingHyphenUTF8[] = { 0xE2, 0x80, 0x91, '\0' };
95 const std::string kNonBreakingHyphenUTF8String( 94 const std::string kNonBreakingHyphenUTF8String(
96 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8)); 95 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8));
97 for (size_t i = 0; i < active_groups.size(); ++i) { 96 for (size_t i = 0; i < active_groups.size(); ++i) {
98 std::string line = active_groups[i].trial_name + ":" + 97 std::string line = active_groups[i].trial_name + ":" +
99 active_groups[i].group_name; 98 active_groups[i].group_name;
100 ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line); 99 ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line);
101 variations.push_back(line); 100 variations.push_back(line);
102 } 101 }
103 #else 102 #else
104 // In release mode, display the hashes only. 103 // In release mode, display the hashes only.
105 std::vector<string16> active_groups; 104 std::vector<string16> active_groups;
106 chrome_variations::GetFieldTrialActiveGroupIdsAsStrings(&active_groups); 105 chrome_variations::GetFieldTrialActiveGroupIdsAsStrings(&active_groups);
107 for (size_t i = 0; i < active_groups.size(); ++i) 106 for (size_t i = 0; i < active_groups.size(); ++i)
108 variations.push_back(UTF16ToASCII(active_groups[i])); 107 variations.push_back(UTF16ToASCII(active_groups[i]));
109 #endif 108 #endif
110 109
110 ListValue variations_list;
111 for (std::vector<std::string>::const_iterator it = variations.begin(); 111 for (std::vector<std::string>::const_iterator it = variations.begin();
112 it != variations.end(); ++it) { 112 it != variations.end(); ++it) {
113 variations_list->Append(Value::CreateStringValue(*it)); 113 variations_list.Append(Value::CreateStringValue(*it));
114 } 114 }
115 115
116 // In release mode, this will return an empty list to clear the section. 116 // In release mode, this will return an empty list to clear the section.
117 web_ui()->CallJavascriptFunction("returnVariationInfo", 117 web_ui()->CallJavascriptFunction("returnVariationInfo", variations_list);
118 *variations_list.release());
119 } 118 }
120 119
121 void VersionHandler::OnGotFilePaths(string16* executable_path_data, 120 void VersionHandler::OnGotFilePaths(string16* executable_path_data,
122 string16* profile_path_data) { 121 string16* profile_path_data) {
123 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
124 123
125 StringValue exec_path(*executable_path_data); 124 StringValue exec_path(*executable_path_data);
126 StringValue profile_path(*profile_path_data); 125 StringValue profile_path(*profile_path_data);
127 web_ui()->CallJavascriptFunction("returnFilePaths", exec_path, profile_path); 126 web_ui()->CallJavascriptFunction("returnFilePaths", exec_path, profile_path);
128 } 127 }
(...skipping 15 matching lines...) Expand all
144 flash_version = info_array[i].version; 143 flash_version = info_array[i].version;
145 break; 144 break;
146 } 145 }
147 } 146 }
148 } 147 }
149 148
150 StringValue arg(flash_version); 149 StringValue arg(flash_version);
151 web_ui()->CallJavascriptFunction("returnFlashVersion", arg); 150 web_ui()->CallJavascriptFunction("returnFlashVersion", arg);
152 } 151 }
153 #endif // defined(ENABLE_PLUGINS) 152 #endif // defined(ENABLE_PLUGINS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698