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

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

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

Powered by Google App Engine
This is Rietveld 408576698