| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/dom_ui/bug_report_ui.h" | 5 #include "chrome/browser/dom_ui/bug_report_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 &width, &height); | 158 &width, &height); |
| 159 #else | 159 #else |
| 160 screen_size = parent->GetBounds(); | 160 screen_size = parent->GetBounds(); |
| 161 win_util::GrabWindowSnapshot(parent->GetNativeWindow(), last_screenshot_png); | 161 win_util::GrabWindowSnapshot(parent->GetNativeWindow(), last_screenshot_png); |
| 162 #endif | 162 #endif |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Global "display this dialog" function declared in browser_dialogs.h. | 165 // Global "display this dialog" function declared in browser_dialogs.h. |
| 166 void ShowHtmlBugReportView(views::Window* parent, Browser* browser) { | 166 void ShowHtmlBugReportView(views::Window* parent, Browser* browser) { |
| 167 std::string bug_report_url = std::string(chrome::kChromeUIBugReportURL) + | 167 std::string bug_report_url = std::string(chrome::kChromeUIBugReportURL) + |
| 168 base::IntToString(browser->selected_index()); | 168 "#" + base::IntToString(browser->selected_index()); |
| 169 | 169 |
| 170 RefreshLastScreenshot(parent); | 170 RefreshLastScreenshot(parent); |
| 171 browser->ShowSingletonTab(GURL(bug_report_url)); | 171 browser->ShowSingletonTab(GURL(bug_report_url)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace browser | 174 } // namespace browser |
| 175 | 175 |
| 176 | 176 |
| 177 class BugReportUIHTMLSource : public ChromeURLDataManager::DataSource { | 177 class BugReportUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 178 public: | 178 public: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return DOMMessageHandler::Attach(dom_ui); | 417 return DOMMessageHandler::Attach(dom_ui); |
| 418 } | 418 } |
| 419 | 419 |
| 420 base::StringPiece BugReportHandler::Init() { | 420 base::StringPiece BugReportHandler::Init() { |
| 421 std::string page_url; | 421 std::string page_url; |
| 422 if (tab_->controller().GetActiveEntry()) { | 422 if (tab_->controller().GetActiveEntry()) { |
| 423 page_url = tab_->controller().GetActiveEntry()->url().spec(); | 423 page_url = tab_->controller().GetActiveEntry()->url().spec(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 std::string params = page_url.substr(strlen(chrome::kChromeUIBugReportURL)); | 426 std::string params = page_url.substr(strlen(chrome::kChromeUIBugReportURL)); |
| 427 // Erase the # - the first character. |
| 428 params.erase(params.begin(),params.begin() + 1); |
| 427 | 429 |
| 428 int index = 0; | 430 int index = 0; |
| 429 if (!base::StringToInt(params, &index)) { | 431 if (!base::StringToInt(params, &index)) { |
| 430 ClobberScreenshotsSource(); | |
| 431 return base::StringPiece( | 432 return base::StringPiece( |
| 432 ResourceBundle::GetSharedInstance().GetRawDataResource( | 433 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 433 IDR_BUGREPORT_HTML_INVALID)); | 434 IDR_BUGREPORT_HTML_INVALID)); |
| 434 } | 435 } |
| 435 | 436 |
| 436 // Sanity checks. | 437 // Sanity checks. |
| 437 if (((index == 0) && (params != "0")) || (index >= browser_->tab_count())) { | 438 if (((index == 0) && (params != "0")) || (index >= browser_->tab_count())) { |
| 438 ClobberScreenshotsSource(); | |
| 439 return base::StringPiece( | 439 return base::StringPiece( |
| 440 ResourceBundle::GetSharedInstance().GetRawDataResource( | 440 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 441 IDR_BUGREPORT_HTML_INVALID)); | 441 IDR_BUGREPORT_HTML_INVALID)); |
| 442 } | 442 } |
| 443 | 443 |
| 444 if (browser_) | 444 if (browser_) |
| 445 target_tab_ = browser_->GetTabContentsAt(index); | 445 target_tab_ = browser_->GetTabContentsAt(index); |
| 446 else | 446 else |
| 447 LOG(FATAL) << "Failed to get last active browser."; | 447 LOG(FATAL) << "Failed to get last active browser."; |
| 448 | 448 |
| 449 // Setup the screenshot source after we've verified input is legit. |
| 450 SetupScreenshotsSource(); |
| 451 |
| 449 return base::StringPiece( | 452 return base::StringPiece( |
| 450 ResourceBundle::GetSharedInstance().GetRawDataResource( | 453 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 451 #if defined(OS_CHROMEOS) | 454 #if defined(OS_CHROMEOS) |
| 452 IDR_BUGREPORT_HTML_CHROMEOS)); | 455 IDR_BUGREPORT_HTML_CHROMEOS)); |
| 453 #else | 456 #else |
| 454 IDR_BUGREPORT_HTML)); | 457 IDR_BUGREPORT_HTML)); |
| 455 #endif | 458 #endif |
| 456 } | 459 } |
| 457 | 460 |
| 458 void BugReportHandler::RegisterMessages() { | 461 void BugReportHandler::RegisterMessages() { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 BugReportUIHTMLSource* html_source = | 620 BugReportUIHTMLSource* html_source = |
| 618 new BugReportUIHTMLSource(handler->Init()); | 621 new BugReportUIHTMLSource(handler->Init()); |
| 619 // Set up the chrome://bugreport/ source. | 622 // Set up the chrome://bugreport/ source. |
| 620 ChromeThread::PostTask( | 623 ChromeThread::PostTask( |
| 621 ChromeThread::IO, FROM_HERE, | 624 ChromeThread::IO, FROM_HERE, |
| 622 NewRunnableMethod( | 625 NewRunnableMethod( |
| 623 Singleton<ChromeURLDataManager>::get(), | 626 Singleton<ChromeURLDataManager>::get(), |
| 624 &ChromeURLDataManager::AddDataSource, | 627 &ChromeURLDataManager::AddDataSource, |
| 625 make_scoped_refptr(html_source))); | 628 make_scoped_refptr(html_source))); |
| 626 } | 629 } |
| OLD | NEW |