| 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/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/bug_report_data.h" | 17 #include "chrome/browser/bug_report_data.h" |
| 17 #include "chrome/browser/bug_report_util.h" | 18 #include "chrome/browser/bug_report_util.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 381 } |
| 381 | 382 |
| 382 // Setup the screenshot source after we've verified input is legit. | 383 // Setup the screenshot source after we've verified input is legit. |
| 383 SetupScreenshotsSource(); | 384 SetupScreenshotsSource(); |
| 384 | 385 |
| 385 return true; | 386 return true; |
| 386 } | 387 } |
| 387 | 388 |
| 388 void BugReportHandler::RegisterMessages() { | 389 void BugReportHandler::RegisterMessages() { |
| 389 web_ui_->RegisterMessageCallback("getDialogDefaults", | 390 web_ui_->RegisterMessageCallback("getDialogDefaults", |
| 390 NewCallback(this, &BugReportHandler::HandleGetDialogDefaults)); | 391 base::Bind(&BugReportHandler::HandleGetDialogDefaults, |
| 392 base::Unretained(this))); |
| 391 web_ui_->RegisterMessageCallback("refreshCurrentScreenshot", | 393 web_ui_->RegisterMessageCallback("refreshCurrentScreenshot", |
| 392 NewCallback(this, &BugReportHandler::HandleRefreshCurrentScreenshot)); | 394 base::Bind(&BugReportHandler::HandleRefreshCurrentScreenshot, |
| 395 base::Unretained(this))); |
| 393 #if defined(OS_CHROMEOS) | 396 #if defined(OS_CHROMEOS) |
| 394 web_ui_->RegisterMessageCallback("refreshSavedScreenshots", | 397 web_ui_->RegisterMessageCallback("refreshSavedScreenshots", |
| 395 NewCallback(this, &BugReportHandler::HandleRefreshSavedScreenshots)); | 398 base::Bind(&BugReportHandler::HandleRefreshSavedScreenshots, |
| 399 base::Unretained(this))); |
| 396 #endif | 400 #endif |
| 397 web_ui_->RegisterMessageCallback("sendReport", | 401 web_ui_->RegisterMessageCallback("sendReport", |
| 398 NewCallback(this, &BugReportHandler::HandleSendReport)); | 402 base::Bind(&BugReportHandler::HandleSendReport, |
| 403 base::Unretained(this))); |
| 399 web_ui_->RegisterMessageCallback("cancel", | 404 web_ui_->RegisterMessageCallback("cancel", |
| 400 NewCallback(this, &BugReportHandler::HandleCancel)); | 405 base::Bind(&BugReportHandler::HandleCancel, |
| 406 base::Unretained(this))); |
| 401 web_ui_->RegisterMessageCallback("openSystemTab", | 407 web_ui_->RegisterMessageCallback("openSystemTab", |
| 402 NewCallback(this, &BugReportHandler::HandleOpenSystemTab)); | 408 base::Bind(&BugReportHandler::HandleOpenSystemTab, |
| 409 base::Unretained(this))); |
| 403 } | 410 } |
| 404 | 411 |
| 405 void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { | 412 void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { |
| 406 // Will delete itself when bug_report_data_->SendReport() is called. | 413 // Will delete itself when bug_report_data_->SendReport() is called. |
| 407 bug_report_data_ = new BugReportData(); | 414 bug_report_data_ = new BugReportData(); |
| 408 | 415 |
| 409 // send back values which the dialog js needs initially | 416 // send back values which the dialog js needs initially |
| 410 ListValue dialog_defaults; | 417 ListValue dialog_defaults; |
| 411 | 418 |
| 412 // 0: current url | 419 // 0: current url |
| 413 if (target_tab_url_.length()) | 420 if (target_tab_url_.length()) |
| 414 dialog_defaults.Append(new StringValue(target_tab_url_)); | 421 dialog_defaults.Append(new StringValue(target_tab_url_)); |
| 415 else | 422 else |
| 416 dialog_defaults.Append(new StringValue("")); | 423 dialog_defaults.Append(new StringValue("")); |
| 417 | 424 |
| 418 #if defined(OS_CHROMEOS) | 425 #if defined(OS_CHROMEOS) |
| 419 // 1: about:system | 426 // 1: about:system |
| 420 dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL)); | 427 dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL)); |
| 421 // Trigger the request for system information here. | 428 // Trigger the request for system information here. |
| 422 chromeos::system::SyslogsProvider* provider = | 429 chromeos::system::SyslogsProvider* provider = |
| 423 chromeos::system::SyslogsProvider::GetInstance(); | 430 chromeos::system::SyslogsProvider::GetInstance(); |
| 424 if (provider) { | 431 if (provider) { |
| 425 syslogs_handle_ = provider->RequestSyslogs( | 432 syslogs_handle_ = provider->RequestSyslogs( |
| 426 true, // don't compress. | 433 true, // don't compress. |
| 427 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, | 434 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, |
| 428 &syslogs_consumer_, | 435 &syslogs_consumer_, |
| 429 NewCallback(bug_report_data_, &BugReportData::SyslogsComplete)); | 436 base::Bind(&BugReportData::SyslogsComplete, |
| 437 base::Unretained(bug_report_data_))); |
| 430 } | 438 } |
| 431 // 2: user e-mail | 439 // 2: user e-mail |
| 432 dialog_defaults.Append(new StringValue(GetUserEmail())); | 440 dialog_defaults.Append(new StringValue(GetUserEmail())); |
| 433 #endif | 441 #endif |
| 434 | 442 |
| 435 web_ui_->CallJavascriptFunction("setupDialogDefaults", dialog_defaults); | 443 web_ui_->CallJavascriptFunction("setupDialogDefaults", dialog_defaults); |
| 436 } | 444 } |
| 437 | 445 |
| 438 void BugReportHandler::HandleRefreshCurrentScreenshot(const ListValue*) { | 446 void BugReportHandler::HandleRefreshCurrentScreenshot(const ListValue*) { |
| 439 std::string current_screenshot(kCurrentScreenshotUrl); | 447 std::string current_screenshot(kCurrentScreenshotUrl); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 AddMessageHandler((handler)->Attach(this)); | 615 AddMessageHandler((handler)->Attach(this)); |
| 608 | 616 |
| 609 // The handler's init will determine whether we show the error html page. | 617 // The handler's init will determine whether we show the error html page. |
| 610 ChromeWebUIDataSource* html_source = | 618 ChromeWebUIDataSource* html_source = |
| 611 CreateBugReportUIHTMLSource(handler->Init()); | 619 CreateBugReportUIHTMLSource(handler->Init()); |
| 612 | 620 |
| 613 // Set up the chrome://bugreport/ source. | 621 // Set up the chrome://bugreport/ source. |
| 614 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); | 622 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
| 615 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 623 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
| 616 } | 624 } |
| OLD | NEW |