| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bug_report_ui.h" | 5 #include "chrome/browser/ui/webui/bug_report_ui.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { | 416 void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { |
| 417 // Will delete itself when bug_report_data_->SendReport() is called. | 417 // Will delete itself when bug_report_data_->SendReport() is called. |
| 418 bug_report_data_ = new BugReportData(); | 418 bug_report_data_ = new BugReportData(); |
| 419 | 419 |
| 420 // send back values which the dialog js needs initially | 420 // send back values which the dialog js needs initially |
| 421 ListValue dialog_defaults; | 421 ListValue dialog_defaults; |
| 422 | 422 |
| 423 // 0: current url | 423 // 0: current url |
| 424 if (target_tab_url_.length()) | 424 if (target_tab_url_.length()) |
| 425 dialog_defaults.Append(new StringValue(target_tab_url_)); | 425 dialog_defaults.Append(base::StringValue::New(target_tab_url_)); |
| 426 else | 426 else |
| 427 dialog_defaults.Append(new StringValue("")); | 427 dialog_defaults.Append(base::StringValue::New("")); |
| 428 | 428 |
| 429 #if defined(OS_CHROMEOS) | 429 #if defined(OS_CHROMEOS) |
| 430 // 1: about:system | 430 // 1: about:system |
| 431 dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL)); | 431 dialog_defaults.Append( |
| 432 base::StringValue::New(chrome::kChromeUISystemInfoURL)); |
| 432 // Trigger the request for system information here. | 433 // Trigger the request for system information here. |
| 433 chromeos::system::SyslogsProvider* provider = | 434 chromeos::system::SyslogsProvider* provider = |
| 434 chromeos::system::SyslogsProvider::GetInstance(); | 435 chromeos::system::SyslogsProvider::GetInstance(); |
| 435 if (provider) { | 436 if (provider) { |
| 436 syslogs_handle_ = provider->RequestSyslogs( | 437 syslogs_handle_ = provider->RequestSyslogs( |
| 437 true, // don't compress. | 438 true, // don't compress. |
| 438 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, | 439 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, |
| 439 &syslogs_consumer_, | 440 &syslogs_consumer_, |
| 440 NewCallback(bug_report_data_, &BugReportData::SyslogsComplete)); | 441 NewCallback(bug_report_data_, &BugReportData::SyslogsComplete)); |
| 441 } | 442 } |
| 442 // 2: user e-mail | 443 // 2: user e-mail |
| 443 dialog_defaults.Append(new StringValue(GetUserEmail())); | 444 dialog_defaults.Append(base::StringValue::New(GetUserEmail())); |
| 444 #endif | 445 #endif |
| 445 | 446 |
| 446 web_ui_->CallJavascriptFunction("setupDialogDefaults", dialog_defaults); | 447 web_ui_->CallJavascriptFunction("setupDialogDefaults", dialog_defaults); |
| 447 } | 448 } |
| 448 | 449 |
| 449 void BugReportHandler::HandleRefreshCurrentScreenshot(const ListValue*) { | 450 void BugReportHandler::HandleRefreshCurrentScreenshot(const ListValue*) { |
| 450 std::string current_screenshot(kCurrentScreenshotUrl); | 451 std::string current_screenshot(kCurrentScreenshotUrl); |
| 451 StringValue screenshot(current_screenshot); | 452 StringValue screenshot(current_screenshot); |
| 452 web_ui_->CallJavascriptFunction("setupCurrentScreenshot", screenshot); | 453 web_ui_->CallJavascriptFunction("setupCurrentScreenshot", screenshot); |
| 453 } | 454 } |
| 454 | 455 |
| 455 | 456 |
| 456 #if defined(OS_CHROMEOS) | 457 #if defined(OS_CHROMEOS) |
| 457 void BugReportHandler::HandleRefreshSavedScreenshots(const ListValue*) { | 458 void BugReportHandler::HandleRefreshSavedScreenshots(const ListValue*) { |
| 458 std::vector<std::string> saved_screenshots; | 459 std::vector<std::string> saved_screenshots; |
| 459 GetScreenshotUrls(&saved_screenshots); | 460 GetScreenshotUrls(&saved_screenshots); |
| 460 | 461 |
| 461 ListValue screenshots_list; | 462 ListValue screenshots_list; |
| 462 for (size_t i = 0; i < saved_screenshots.size(); ++i) | 463 for (size_t i = 0; i < saved_screenshots.size(); ++i) |
| 463 screenshots_list.Append(new StringValue(saved_screenshots[i])); | 464 screenshots_list.Append(base::StringValue::New(saved_screenshots[i])); |
| 464 web_ui_->CallJavascriptFunction("setupSavedScreenshots", screenshots_list); | 465 web_ui_->CallJavascriptFunction("setupSavedScreenshots", screenshots_list); |
| 465 } | 466 } |
| 466 #endif | 467 #endif |
| 467 | 468 |
| 468 | 469 |
| 469 void BugReportHandler::HandleSendReport(const ListValue* list_value) { | 470 void BugReportHandler::HandleSendReport(const ListValue* list_value) { |
| 470 if (!bug_report_data_) { | 471 if (!bug_report_data_) { |
| 471 LOG(ERROR) << "Bug report hasn't been intialized yet."; | 472 LOG(ERROR) << "Bug report hasn't been intialized yet."; |
| 472 return; | 473 return; |
| 473 } | 474 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 AddMessageHandler((handler)->Attach(this)); | 619 AddMessageHandler((handler)->Attach(this)); |
| 619 | 620 |
| 620 // The handler's init will determine whether we show the error html page. | 621 // The handler's init will determine whether we show the error html page. |
| 621 ChromeWebUIDataSource* html_source = | 622 ChromeWebUIDataSource* html_source = |
| 622 CreateBugReportUIHTMLSource(handler->Init()); | 623 CreateBugReportUIHTMLSource(handler->Init()); |
| 623 | 624 |
| 624 // Set up the chrome://bugreport/ source. | 625 // Set up the chrome://bugreport/ source. |
| 625 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); | 626 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
| 626 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 627 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
| 627 } | 628 } |
| OLD | NEW |