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

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

Issue 2820823005: Revert of Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/flags_ui.cc ('k') | chrome/browser/ui/webui/foreign_session_handler.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 "chrome/browser/ui/webui/flash_ui.h" 5 #include "chrome/browser/ui/webui/flash_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 !has_plugin_info_) { 235 !has_plugin_info_) {
236 return; 236 return;
237 } 237 }
238 238
239 timeout_.Stop(); 239 timeout_.Stop();
240 240
241 // This is code that runs only when the user types in about:flash. We don't 241 // This is code that runs only when the user types in about:flash. We don't
242 // need to jump through hoops to offload this to the IO thread. 242 // need to jump through hoops to offload this to the IO thread.
243 base::ThreadRestrictions::ScopedAllowIO allow_io; 243 base::ThreadRestrictions::ScopedAllowIO allow_io;
244 244
245 auto list = base::MakeUnique<base::ListValue>(); 245 base::ListValue* list = new base::ListValue();
246 246
247 // Chrome version information. 247 // Chrome version information.
248 AddPair(list.get(), l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 248 AddPair(list,
249 version_info::GetVersionNumber() + " (" + chrome::GetChannelString() + 249 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
250 ")"); 250 version_info::GetVersionNumber() + " (" +
251 chrome::GetChannelString() + ")");
251 252
252 // OS version information. 253 // OS version information.
253 std::string os_label = version_info::GetOSType(); 254 std::string os_label = version_info::GetOSType();
254 #if defined(OS_WIN) 255 #if defined(OS_WIN)
255 base::win::OSInfo* os = base::win::OSInfo::GetInstance(); 256 base::win::OSInfo* os = base::win::OSInfo::GetInstance();
256 switch (os->version()) { 257 switch (os->version()) {
257 case base::win::VERSION_XP: os_label += " XP"; break; 258 case base::win::VERSION_XP: os_label += " XP"; break;
258 case base::win::VERSION_SERVER_2003: 259 case base::win::VERSION_SERVER_2003:
259 os_label += " Server 2003 or XP Pro 64 bit"; 260 os_label += " Server 2003 or XP Pro 64 bit";
260 break; 261 break;
261 case base::win::VERSION_VISTA: os_label += " Vista or Server 2008"; break; 262 case base::win::VERSION_VISTA: os_label += " Vista or Server 2008"; break;
262 case base::win::VERSION_WIN7: os_label += " 7 or Server 2008 R2"; break; 263 case base::win::VERSION_WIN7: os_label += " 7 or Server 2008 R2"; break;
263 case base::win::VERSION_WIN8: os_label += " 8 or Server 2012"; break; 264 case base::win::VERSION_WIN8: os_label += " 8 or Server 2012"; break;
264 default: os_label += " UNKNOWN"; break; 265 default: os_label += " UNKNOWN"; break;
265 } 266 }
266 os_label += " SP" + base::IntToString(os->service_pack().major); 267 os_label += " SP" + base::IntToString(os->service_pack().major);
267 if (os->service_pack().minor > 0) 268 if (os->service_pack().minor > 0)
268 os_label += "." + base::IntToString(os->service_pack().minor); 269 os_label += "." + base::IntToString(os->service_pack().minor);
269 if (os->architecture() == base::win::OSInfo::X64_ARCHITECTURE) 270 if (os->architecture() == base::win::OSInfo::X64_ARCHITECTURE)
270 os_label += " 64 bit"; 271 os_label += " 64 bit";
271 #endif 272 #endif
272 AddPair(list.get(), l10n_util::GetStringUTF16(IDS_VERSION_UI_OS), os_label); 273 AddPair(list, l10n_util::GetStringUTF16(IDS_VERSION_UI_OS), os_label);
273 274
274 // Obtain the version of the Flash plugins. 275 // Obtain the version of the Flash plugins.
275 std::vector<content::WebPluginInfo> info_array; 276 std::vector<content::WebPluginInfo> info_array;
276 PluginService::GetInstance()->GetPluginInfoArray( 277 PluginService::GetInstance()->GetPluginInfoArray(
277 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); 278 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL);
278 if (info_array.empty()) { 279 if (info_array.empty()) {
279 AddPair(list.get(), ASCIIToUTF16(kFlashPlugin), "Not installed"); 280 AddPair(list, ASCIIToUTF16(kFlashPlugin), "Not installed");
280 } else { 281 } else {
281 PluginPrefs* plugin_prefs = 282 PluginPrefs* plugin_prefs =
282 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); 283 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get();
283 bool found_enabled = false; 284 bool found_enabled = false;
284 for (size_t i = 0; i < info_array.size(); ++i) { 285 for (size_t i = 0; i < info_array.size(); ++i) {
285 base::string16 flash_version = info_array[i].version + ASCIIToUTF16(" ") + 286 base::string16 flash_version = info_array[i].version + ASCIIToUTF16(" ") +
286 info_array[i].path.LossyDisplayName(); 287 info_array[i].path.LossyDisplayName();
287 if (plugin_prefs->IsPluginEnabled(info_array[i])) { 288 if (plugin_prefs->IsPluginEnabled(info_array[i])) {
288 // If we have already found an enabled Flash version, this one 289 // If we have already found an enabled Flash version, this one
289 // is not used. 290 // is not used.
290 if (found_enabled) 291 if (found_enabled)
291 flash_version += ASCIIToUTF16(" (not used)"); 292 flash_version += ASCIIToUTF16(" (not used)");
292 293
293 found_enabled = true; 294 found_enabled = true;
294 } else { 295 } else {
295 flash_version += ASCIIToUTF16(" (disabled)"); 296 flash_version += ASCIIToUTF16(" (disabled)");
296 } 297 }
297 AddPair(list.get(), ASCIIToUTF16(kFlashPlugin), flash_version); 298 AddPair(list, ASCIIToUTF16(kFlashPlugin), flash_version);
298 } 299 }
299 } 300 }
300 301
301 // Crash information. 302 // Crash information.
302 AddPair(list.get(), base::string16(), "--- Crash data ---"); 303 AddPair(list, base::string16(), "--- Crash data ---");
303 bool crash_reporting_enabled = 304 bool crash_reporting_enabled =
304 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); 305 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
305 if (crash_reporting_enabled) { 306 if (crash_reporting_enabled) {
306 std::vector<CrashUploadList::UploadInfo> crashes; 307 std::vector<CrashUploadList::UploadInfo> crashes;
307 upload_list_->GetUploads(10, &crashes); 308 upload_list_->GetUploads(10, &crashes);
308 309
309 for (std::vector<CrashUploadList::UploadInfo>::iterator i = crashes.begin(); 310 for (std::vector<CrashUploadList::UploadInfo>::iterator i = crashes.begin();
310 i != crashes.end(); ++i) { 311 i != crashes.end(); ++i) {
311 base::string16 crash_string(ASCIIToUTF16(i->upload_id)); 312 base::string16 crash_string(ASCIIToUTF16(i->upload_id));
312 crash_string += ASCIIToUTF16(" "); 313 crash_string += ASCIIToUTF16(" ");
313 crash_string += base::TimeFormatFriendlyDateAndTime(i->upload_time); 314 crash_string += base::TimeFormatFriendlyDateAndTime(i->upload_time);
314 AddPair(list.get(), ASCIIToUTF16("crash id"), crash_string); 315 AddPair(list, ASCIIToUTF16("crash id"), crash_string);
315 } 316 }
316 } else { 317 } else {
317 AddPair(list.get(), ASCIIToUTF16("Crash Reporting"), 318 AddPair(list, ASCIIToUTF16("Crash Reporting"),
318 "Enable crash reporting to see crash IDs"); 319 "Enable crash reporting to see crash IDs");
319 AddPair(list.get(), ASCIIToUTF16("For more details"), 320 AddPair(list, ASCIIToUTF16("For more details"),
320 chrome::kLearnMoreReportingURL); 321 chrome::kLearnMoreReportingURL);
321 } 322 }
322 323
323 // GPU information. 324 // GPU information.
324 AddPair(list.get(), base::string16(), "--- GPU information ---"); 325 AddPair(list, base::string16(), "--- GPU information ---");
325 gpu::GPUInfo gpu_info = GpuDataManager::GetInstance()->GetGPUInfo(); 326 gpu::GPUInfo gpu_info = GpuDataManager::GetInstance()->GetGPUInfo();
326 327
327 std::string reason; 328 std::string reason;
328 if (!GpuDataManager::GetInstance()->GpuAccessAllowed(&reason)) { 329 if (!GpuDataManager::GetInstance()->GpuAccessAllowed(&reason)) {
329 AddPair(list.get(), ASCIIToUTF16("WARNING:"), 330 AddPair(list, ASCIIToUTF16("WARNING:"),
330 "GPU access is not allowed: " + reason); 331 "GPU access is not allowed: " + reason);
331 } 332 }
332 #if defined(OS_WIN) 333 #if defined(OS_WIN)
333 const gpu::DxDiagNode& node = gpu_info.dx_diagnostics; 334 const gpu::DxDiagNode& node = gpu_info.dx_diagnostics;
334 for (std::map<std::string, gpu::DxDiagNode>::const_iterator it = 335 for (std::map<std::string, gpu::DxDiagNode>::const_iterator it =
335 node.children.begin(); 336 node.children.begin();
336 it != node.children.end(); 337 it != node.children.end();
337 ++it) { 338 ++it) {
338 for (std::map<std::string, std::string>::const_iterator it2 = 339 for (std::map<std::string, std::string>::const_iterator it2 =
339 it->second.values.begin(); 340 it->second.values.begin();
340 it2 != it->second.values.end(); 341 it2 != it->second.values.end();
341 ++it2) { 342 ++it2) {
342 if (!it2->second.empty()) { 343 if (!it2->second.empty()) {
343 if (it2->first == "szDescription") { 344 if (it2->first == "szDescription") {
344 AddPair(list.get(), ASCIIToUTF16("Graphics card"), it2->second); 345 AddPair(list, ASCIIToUTF16("Graphics card"), it2->second);
345 } else if (it2->first == "szDriverNodeStrongName") { 346 } else if (it2->first == "szDriverNodeStrongName") {
346 AddPair(list.get(), ASCIIToUTF16("Driver name (strong)"), 347 AddPair(list, ASCIIToUTF16("Driver name (strong)"), it2->second);
347 it2->second);
348 } else if (it2->first == "szDriverName") { 348 } else if (it2->first == "szDriverName") {
349 AddPair(list.get(), ASCIIToUTF16("Driver display name"), it2->second); 349 AddPair(list, ASCIIToUTF16("Driver display name"), it2->second);
350 } 350 }
351 } 351 }
352 } 352 }
353 } 353 }
354 #endif 354 #endif
355 355
356 AddPair(list.get(), base::string16(), "--- GPU driver, more information ---"); 356 AddPair(list, base::string16(), "--- GPU driver, more information ---");
357 AddPair(list.get(), ASCIIToUTF16("Vendor Id"), 357 AddPair(list,
358 ASCIIToUTF16("Vendor Id"),
358 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); 359 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id));
359 AddPair(list.get(), ASCIIToUTF16("Device Id"), 360 AddPair(list,
361 ASCIIToUTF16("Device Id"),
360 base::StringPrintf("0x%04x", gpu_info.gpu.device_id)); 362 base::StringPrintf("0x%04x", gpu_info.gpu.device_id));
361 AddPair(list.get(), ASCIIToUTF16("Driver vendor"), gpu_info.driver_vendor); 363 AddPair(list, ASCIIToUTF16("Driver vendor"), gpu_info.driver_vendor);
362 AddPair(list.get(), ASCIIToUTF16("Driver version"), gpu_info.driver_version); 364 AddPair(list, ASCIIToUTF16("Driver version"), gpu_info.driver_version);
363 AddPair(list.get(), ASCIIToUTF16("Driver date"), gpu_info.driver_date); 365 AddPair(list, ASCIIToUTF16("Driver date"), gpu_info.driver_date);
364 AddPair(list.get(), ASCIIToUTF16("Pixel shader version"), 366 AddPair(list,
367 ASCIIToUTF16("Pixel shader version"),
365 gpu_info.pixel_shader_version); 368 gpu_info.pixel_shader_version);
366 AddPair(list.get(), ASCIIToUTF16("Vertex shader version"), 369 AddPair(list,
370 ASCIIToUTF16("Vertex shader version"),
367 gpu_info.vertex_shader_version); 371 gpu_info.vertex_shader_version);
368 AddPair(list.get(), ASCIIToUTF16("GL_VENDOR"), gpu_info.gl_vendor); 372 AddPair(list, ASCIIToUTF16("GL_VENDOR"), gpu_info.gl_vendor);
369 AddPair(list.get(), ASCIIToUTF16("GL_RENDERER"), gpu_info.gl_renderer); 373 AddPair(list, ASCIIToUTF16("GL_RENDERER"), gpu_info.gl_renderer);
370 AddPair(list.get(), ASCIIToUTF16("GL_VERSION"), gpu_info.gl_version); 374 AddPair(list, ASCIIToUTF16("GL_VERSION"), gpu_info.gl_version);
371 AddPair(list.get(), ASCIIToUTF16("GL_EXTENSIONS"), gpu_info.gl_extensions); 375 AddPair(list, ASCIIToUTF16("GL_EXTENSIONS"), gpu_info.gl_extensions);
372 376
373 base::DictionaryValue flashInfo; 377 base::DictionaryValue flashInfo;
374 flashInfo.Set("flashInfo", std::move(list)); 378 flashInfo.Set("flashInfo", list);
375 web_ui()->CallJavascriptFunctionUnsafe("returnFlashInfo", flashInfo); 379 web_ui()->CallJavascriptFunctionUnsafe("returnFlashInfo", flashInfo);
376 } 380 }
377 381
378 } // namespace 382 } // namespace
379 383
380 /////////////////////////////////////////////////////////////////////////////// 384 ///////////////////////////////////////////////////////////////////////////////
381 // 385 //
382 // FlashUI 386 // FlashUI
383 // 387 //
384 /////////////////////////////////////////////////////////////////////////////// 388 ///////////////////////////////////////////////////////////////////////////////
385 389
386 FlashUI::FlashUI(content::WebUI* web_ui) : WebUIController(web_ui) { 390 FlashUI::FlashUI(content::WebUI* web_ui) : WebUIController(web_ui) {
387 base::RecordAction(UserMetricsAction("ViewAboutFlash")); 391 base::RecordAction(UserMetricsAction("ViewAboutFlash"));
388 392
389 web_ui->AddMessageHandler(base::MakeUnique<FlashDOMHandler>()); 393 web_ui->AddMessageHandler(base::MakeUnique<FlashDOMHandler>());
390 394
391 // Set up the about:flash source. 395 // Set up the about:flash source.
392 Profile* profile = Profile::FromWebUI(web_ui); 396 Profile* profile = Profile::FromWebUI(web_ui);
393 content::WebUIDataSource::Add(profile, CreateFlashUIHTMLSource()); 397 content::WebUIDataSource::Add(profile, CreateFlashUIHTMLSource());
394 } 398 }
395 399
396 // static 400 // static
397 base::RefCountedMemory* FlashUI::GetFaviconResourceBytes( 401 base::RefCountedMemory* FlashUI::GetFaviconResourceBytes(
398 ui::ScaleFactor scale_factor) { 402 ui::ScaleFactor scale_factor) {
399 // Use the default icon for now. 403 // Use the default icon for now.
400 return NULL; 404 return NULL;
401 } 405 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/flags_ui.cc ('k') | chrome/browser/ui/webui/foreign_session_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698