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

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

Issue 9006003: Refactor and fix feedback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2011 -> 2012 Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/bug_report_ui.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h"
16 #include "base/values.h"
17 #include "chrome/browser/bug_report_data.h"
18 #include "chrome/browser/bug_report_util.h"
19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_list.h"
22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
24 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
25 #include "chrome/browser/ui/webui/screenshot_source.h"
26 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
27 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/url_constants.h"
29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/navigation_entry.h"
32 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_ui_message_handler.h"
34 #include "grit/browser_resources.h"
35 #include "grit/chromium_strings.h"
36 #include "grit/generated_resources.h"
37 #include "grit/locale_settings.h"
38 #include "net/base/escape.h"
39 #include "ui/base/resource/resource_bundle.h"
40
41 #if defined(OS_CHROMEOS)
42 #include "base/file_util.h"
43 #include "base/path_service.h"
44 #include "base/synchronization/waitable_event.h"
45 #include "chrome/browser/chromeos/cros/cros_library.h"
46 #include "chrome/browser/chromeos/login/user_manager.h"
47 #include "chrome/browser/chromeos/system/syslogs_provider.h"
48 #endif
49
50 using content::BrowserThread;
51 using content::WebContents;
52 using content::WebUIMessageHandler;
53
54 namespace {
55
56 const char kScreenshotBaseUrl[] = "chrome://screenshots/";
57 const char kCurrentScreenshotUrl[] = "chrome://screenshots/current";
58 #if defined(OS_CHROMEOS)
59 const char kSavedScreenshotsUrl[] = "chrome://screenshots/saved/";
60 const char kScreenshotPattern[] = "screenshot-*.png";
61
62 const size_t kMaxSavedScreenshots = 2;
63 #endif
64
65 #if defined(OS_CHROMEOS)
66
67 void GetSavedScreenshots(std::vector<std::string>* saved_screenshots,
68 base::WaitableEvent* done) {
69 saved_screenshots->clear();
70
71 FilePath fileshelf_path;
72 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS,
73 &fileshelf_path)) {
74 done->Signal();
75 return;
76 }
77
78 file_util::FileEnumerator screenshots(fileshelf_path, false,
79 file_util::FileEnumerator::FILES,
80 std::string(kScreenshotPattern));
81 FilePath screenshot = screenshots.Next();
82 while (!screenshot.empty()) {
83 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) +
84 screenshot.BaseName().value());
85 if (saved_screenshots->size() >= kMaxSavedScreenshots)
86 break;
87
88 screenshot = screenshots.Next();
89 }
90 done->Signal();
91 }
92
93 // This fuction posts a task to the file thread to create/list all the current
94 // and saved screenshots.
95 void GetScreenshotUrls(std::vector<std::string>* saved_screenshots) {
96 base::WaitableEvent done(true, false);
97 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
98 base::Bind(&GetSavedScreenshots,
99 saved_screenshots, &done));
100 done.Wait();
101 }
102
103 std::string GetUserEmail() {
104 chromeos::UserManager* manager = chromeos::UserManager::Get();
105 if (!manager)
106 return std::string();
107 else
108 return manager->logged_in_user().display_email();
109 }
110 #endif
111
112 // Returns the index of the feedback tab if already open, -1 otherwise
113 int GetIndexOfFeedbackTab(Browser* browser) {
114 GURL bug_report_url(chrome::kChromeUIBugReportURL);
115 for (int i = 0; i < browser->tab_count(); ++i) {
116 WebContents* tab = browser->GetTabContentsWrapperAt(i)->web_contents();
117 if (tab && tab->GetURL().GetWithEmptyPath() == bug_report_url)
118 return i;
119 }
120
121 return -1;
122 }
123
124 } // namespace
125
126
127 namespace browser {
128
129 void ShowHtmlBugReportView(Browser* browser,
130 const std::string& description_template,
131 size_t issue_type) {
132 // First check if we're already open (we cannot depend on ShowSingletonTab
133 // for this functionality since we need to make *sure* we never get
134 // instantiated again while we are open - with singleton tabs, that can
135 // happen)
136 int feedback_tab_index = GetIndexOfFeedbackTab(browser);
137 if (feedback_tab_index >= 0) {
138 // Do not refresh screenshot, do not create a new tab
139 browser->ActivateTabAt(feedback_tab_index, true);
140 return;
141 }
142
143 std::vector<unsigned char>* last_screenshot_png =
144 BugReportUtil::GetScreenshotPng();
145 last_screenshot_png->clear();
146
147 gfx::NativeWindow native_window = browser->window()->GetNativeHandle();
148 gfx::Rect snapshot_bounds = gfx::Rect(browser->window()->GetBounds().size());
149 bool success = browser::GrabWindowSnapshot(native_window,
150 last_screenshot_png,
151 snapshot_bounds);
152 BugReportUtil::SetScreenshotSize(success ? snapshot_bounds : gfx::Rect());
153
154 std::string bug_report_url = std::string(chrome::kChromeUIBugReportURL) +
155 "#" + base::IntToString(browser->active_index()) +
156 "?description=" + net::EscapeUrlEncodedData(description_template, false) +
157 "&issueType=" + base::IntToString(issue_type);
158 browser->ShowSingletonTab(GURL(bug_report_url));
159 }
160
161 } // namespace browser
162
163 // The handler for Javascript messages related to the "bug report" dialog
164 class BugReportHandler : public WebUIMessageHandler,
165 public base::SupportsWeakPtr<BugReportHandler> {
166 public:
167 explicit BugReportHandler(content::WebContents* tab);
168 virtual ~BugReportHandler();
169
170 // Init work after Attach. Returns true on success.
171 bool Init();
172
173 // WebUIMessageHandler implementation.
174 virtual void RegisterMessages() OVERRIDE;
175
176 private:
177 void HandleGetDialogDefaults(const ListValue* args);
178 void HandleRefreshCurrentScreenshot(const ListValue* args);
179 #if defined(OS_CHROMEOS)
180 void HandleRefreshSavedScreenshots(const ListValue* args);
181 #endif
182 void HandleSendReport(const ListValue* args);
183 void HandleCancel(const ListValue* args);
184 void HandleOpenSystemTab(const ListValue* args);
185
186 void SetupScreenshotsSource();
187 void ClobberScreenshotsSource();
188
189 void CancelFeedbackCollection();
190 void CloseFeedbackTab();
191
192 WebContents* tab_;
193 ScreenshotSource* screenshot_source_;
194
195 BugReportData* bug_report_data_;
196 std::string target_tab_url_;
197 #if defined(OS_CHROMEOS)
198 // Variables to track SyslogsProvider::RequestSyslogs callback.
199 chromeos::system::SyslogsProvider::Handle syslogs_handle_;
200 CancelableRequestConsumer syslogs_consumer_;
201 #endif
202
203 DISALLOW_COPY_AND_ASSIGN(BugReportHandler);
204 };
205
206 ChromeWebUIDataSource* CreateBugReportUIHTMLSource(bool successful_init) {
207 ChromeWebUIDataSource* source =
208 new ChromeWebUIDataSource(chrome::kChromeUIBugReportHost);
209
210 source->AddLocalizedString("title", IDS_BUGREPORT_TITLE);
211 source->AddLocalizedString("page-title", IDS_BUGREPORT_REPORT_PAGE_TITLE);
212 source->AddLocalizedString("issue-with", IDS_BUGREPORT_ISSUE_WITH);
213 source->AddLocalizedString("page-url", IDS_BUGREPORT_REPORT_URL_LABEL);
214 source->AddLocalizedString("description", IDS_BUGREPORT_DESCRIPTION_LABEL);
215 source->AddLocalizedString("current-screenshot",
216 IDS_BUGREPORT_SCREENSHOT_LABEL);
217 source->AddLocalizedString("saved-screenshot",
218 IDS_BUGREPORT_SAVED_SCREENSHOT_LABEL);
219 #if defined(OS_CHROMEOS)
220 source->AddLocalizedString("user-email", IDS_BUGREPORT_USER_EMAIL_LABEL);
221 source->AddLocalizedString("sysinfo",
222 IDS_BUGREPORT_INCLUDE_SYSTEM_INFORMATION_CHKBOX);
223 source->AddLocalizedString("currentscreenshots",
224 IDS_BUGREPORT_CURRENT_SCREENSHOTS);
225 source->AddLocalizedString("savedscreenshots",
226 IDS_BUGREPORT_SAVED_SCREENSHOTS);
227 source->AddLocalizedString("choose-different-screenshot",
228 IDS_BUGREPORT_CHOOSE_DIFFERENT_SCREENSHOT);
229 source->AddLocalizedString("choose-original-screenshot",
230 IDS_BUGREPORT_CHOOSE_ORIGINAL_SCREENSHOT);
231 #else
232 source->AddLocalizedString("currentscreenshots",
233 IDS_BUGREPORT_INCLUDE_NEW_SCREEN_IMAGE);
234 #endif
235 source->AddLocalizedString("noscreenshot",
236 IDS_BUGREPORT_INCLUDE_NO_SCREENSHOT);
237
238 source->AddLocalizedString("send-report", IDS_BUGREPORT_SEND_REPORT);
239 source->AddLocalizedString("cancel", IDS_CANCEL);
240
241 // Option strings for the "issue with" drop-down.
242 source->AddLocalizedString("issue-choose", IDS_BUGREPORT_CHOOSE_ISSUE);
243 source->AddLocalizedString("no-issue-selected",
244 IDS_BUGREPORT_NO_ISSUE_SELECTED);
245 source->AddLocalizedString("no-description", IDS_BUGREPORT_NO_DESCRIPTION);
246 source->AddLocalizedString("no-saved-screenshots",
247 IDS_BUGREPORT_NO_SAVED_SCREENSHOTS_HELP);
248 source->AddLocalizedString("privacy-note", IDS_BUGREPORT_PRIVACY_NOTE);
249
250 // TODO(rkc): Find some way to ensure this order of dropdowns is in sync
251 // with the order in the userfeedback ChromeData proto buffer
252 #if defined(OS_CHROMEOS)
253 // Dropdown for ChromeOS:
254 //
255 // Connectivity
256 // Sync
257 // Crash
258 // Page Formatting
259 // Extensions or Apps
260 // Standby or Resume
261 // Phishing Page
262 // General Feedback/Other
263 // Autofill (hidden by default)
264
265 source->AddLocalizedString("issue-connectivity", IDS_BUGREPORT_CONNECTIVITY);
266 source->AddLocalizedString("issue-sync", IDS_BUGREPORT_SYNC);
267 source->AddLocalizedString("issue-crashes", IDS_BUGREPORT_CRASHES);
268 source->AddLocalizedString("issue-page-formatting",
269 IDS_BUGREPORT_PAGE_FORMATTING);
270 source->AddLocalizedString("issue-extensions", IDS_BUGREPORT_EXTENSIONS);
271 source->AddLocalizedString("issue-standby", IDS_BUGREPORT_STANDBY_RESUME);
272 source->AddLocalizedString("issue-phishing", IDS_BUGREPORT_PHISHING_PAGE);
273 source->AddLocalizedString("issue-other", IDS_BUGREPORT_GENERAL);
274 source->AddLocalizedString("issue-autofill", IDS_BUGREPORT_AUTOFILL);
275 #else
276 // Dropdown for Chrome:
277 //
278 // Page formatting or layout
279 // Pages not loading
280 // Plug-ins (e.g. Adobe Flash Player, Quicktime, etc)
281 // Tabs or windows
282 // Synced preferences
283 // Crashes
284 // Extensions or apps
285 // Phishing
286 // Other
287 // Autofill (hidden by default)
288
289 source->AddLocalizedString("issue-page-formatting",
290 IDS_BUGREPORT_PAGE_FORMATTING);
291 source->AddLocalizedString("issue-page-load", IDS_BUGREPORT_PAGE_LOAD);
292 source->AddLocalizedString("issue-plugins", IDS_BUGREPORT_PLUGINS);
293 source->AddLocalizedString("issue-tabs", IDS_BUGREPORT_TABS);
294 source->AddLocalizedString("issue-sync", IDS_BUGREPORT_SYNC);
295 source->AddLocalizedString("issue-crashes", IDS_BUGREPORT_CRASHES);
296 source->AddLocalizedString("issue-extensions", IDS_BUGREPORT_EXTENSIONS);
297 source->AddLocalizedString("issue-phishing", IDS_BUGREPORT_PHISHING_PAGE);
298 source->AddLocalizedString("issue-other", IDS_BUGREPORT_OTHER);
299 source->AddLocalizedString("issue-autofill", IDS_BUGREPORT_AUTOFILL);
300 #endif
301
302 source->set_json_path("strings.js");
303 source->add_resource_path("bug_report.js", IDR_BUGREPORT_JS);
304 source->set_default_resource(
305 successful_init ? IDR_BUGREPORT_HTML : IDR_BUGREPORT_HTML_INVALID);
306
307 return source;
308 }
309
310 ////////////////////////////////////////////////////////////////////////////////
311 //
312 // BugReportHandler
313 //
314 ////////////////////////////////////////////////////////////////////////////////
315 BugReportHandler::BugReportHandler(WebContents* tab)
316 : tab_(tab),
317 screenshot_source_(NULL),
318 bug_report_data_(NULL)
319 #if defined(OS_CHROMEOS)
320 , syslogs_handle_(0)
321 #endif
322 {
323 }
324
325 BugReportHandler::~BugReportHandler() {
326 // Just in case we didn't send off bug_report_data_ to SendReport
327 if (bug_report_data_) {
328 // If we're deleting the report object, cancel feedback collection first
329 CancelFeedbackCollection();
330 delete bug_report_data_;
331 }
332 // Make sure we don't leave any screenshot data around.
333 BugReportUtil::ClearScreenshotPng();
334 }
335
336 void BugReportHandler::ClobberScreenshotsSource() {
337 // Re-create our screenshots data source (this clobbers the last source)
338 // setting the screenshot to NULL, effectively disabling the source
339 // TODO(rkc): Once there is a method to 'remove' a source, change this code
340 Profile* profile = Profile::FromBrowserContext(tab_->GetBrowserContext());
341 profile->GetChromeURLDataManager()->AddDataSource(new ScreenshotSource(NULL));
342
343 BugReportUtil::ClearScreenshotPng();
344 }
345
346 void BugReportHandler::SetupScreenshotsSource() {
347 // If we don't already have a screenshot source object created, create one.
348 if (!screenshot_source_) {
349 screenshot_source_ =
350 new ScreenshotSource(BugReportUtil::GetScreenshotPng());
351 }
352 // Add the source to the data manager.
353 Profile* profile = Profile::FromBrowserContext(tab_->GetBrowserContext());
354 profile->GetChromeURLDataManager()->AddDataSource(screenshot_source_);
355 }
356
357 bool BugReportHandler::Init() {
358 std::string page_url;
359 if (tab_->GetController().GetActiveEntry()) {
360 page_url = tab_->GetController().GetActiveEntry()->GetURL().spec();
361 }
362
363 std::string params = page_url.substr(strlen(chrome::kChromeUIBugReportURL));
364 // Erase the # - the first character.
365 if (params.length())
366 params.erase(params.begin(), params.begin() + 1);
367
368 size_t additional_params_pos = params.find('?');
369 if (additional_params_pos != std::string::npos)
370 params.erase(params.begin() + additional_params_pos, params.end());
371
372 int index = 0;
373 if (!base::StringToInt(params, &index))
374 return false;
375
376 Browser* browser = BrowserList::GetLastActive();
377 // Sanity checks.
378 if (((index == 0) && (params != "0")) || !browser ||
379 index >= browser->tab_count()) {
380 return false;
381 }
382
383 WebContents* target_tab =
384 browser->GetTabContentsWrapperAt(index)->web_contents();
385 if (target_tab) {
386 target_tab_url_ = target_tab->GetURL().spec();
387 }
388
389 // Setup the screenshot source after we've verified input is legit.
390 SetupScreenshotsSource();
391
392 return true;
393 }
394
395 void BugReportHandler::RegisterMessages() {
396 SetupScreenshotsSource();
397
398 web_ui()->RegisterMessageCallback("getDialogDefaults",
399 base::Bind(&BugReportHandler::HandleGetDialogDefaults,
400 base::Unretained(this)));
401 web_ui()->RegisterMessageCallback("refreshCurrentScreenshot",
402 base::Bind(&BugReportHandler::HandleRefreshCurrentScreenshot,
403 base::Unretained(this)));
404 #if defined(OS_CHROMEOS)
405 web_ui()->RegisterMessageCallback("refreshSavedScreenshots",
406 base::Bind(&BugReportHandler::HandleRefreshSavedScreenshots,
407 base::Unretained(this)));
408 #endif
409 web_ui()->RegisterMessageCallback("sendReport",
410 base::Bind(&BugReportHandler::HandleSendReport,
411 base::Unretained(this)));
412 web_ui()->RegisterMessageCallback("cancel",
413 base::Bind(&BugReportHandler::HandleCancel,
414 base::Unretained(this)));
415 web_ui()->RegisterMessageCallback("openSystemTab",
416 base::Bind(&BugReportHandler::HandleOpenSystemTab,
417 base::Unretained(this)));
418 }
419
420 void BugReportHandler::HandleGetDialogDefaults(const ListValue*) {
421 // Will delete itself when bug_report_data_->SendReport() is called.
422 bug_report_data_ = new BugReportData();
423
424 // send back values which the dialog js needs initially
425 ListValue dialog_defaults;
426
427 // 0: current url
428 if (target_tab_url_.length())
429 dialog_defaults.Append(new StringValue(target_tab_url_));
430 else
431 dialog_defaults.Append(new StringValue(""));
432
433 #if defined(OS_CHROMEOS)
434 // 1: about:system
435 dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL));
436 // Trigger the request for system information here.
437 chromeos::system::SyslogsProvider* provider =
438 chromeos::system::SyslogsProvider::GetInstance();
439 if (provider) {
440 syslogs_handle_ = provider->RequestSyslogs(
441 true, // don't compress.
442 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK,
443 &syslogs_consumer_,
444 base::Bind(&BugReportData::SyslogsComplete,
445 base::Unretained(bug_report_data_)));
446 }
447 // 2: user e-mail
448 dialog_defaults.Append(new StringValue(GetUserEmail()));
449 #endif
450
451 web_ui()->CallJavascriptFunction("setupDialogDefaults", dialog_defaults);
452 }
453
454 void BugReportHandler::HandleRefreshCurrentScreenshot(const ListValue*) {
455 std::string current_screenshot(kCurrentScreenshotUrl);
456 StringValue screenshot(current_screenshot);
457 web_ui()->CallJavascriptFunction("setupCurrentScreenshot", screenshot);
458 }
459
460
461 #if defined(OS_CHROMEOS)
462 void BugReportHandler::HandleRefreshSavedScreenshots(const ListValue*) {
463 std::vector<std::string> saved_screenshots;
464 GetScreenshotUrls(&saved_screenshots);
465
466 ListValue screenshots_list;
467 for (size_t i = 0; i < saved_screenshots.size(); ++i)
468 screenshots_list.Append(new StringValue(saved_screenshots[i]));
469 web_ui()->CallJavascriptFunction("setupSavedScreenshots", screenshots_list);
470 }
471 #endif
472
473
474 void BugReportHandler::HandleSendReport(const ListValue* list_value) {
475 if (!bug_report_data_) {
476 LOG(ERROR) << "Bug report hasn't been intialized yet.";
477 return;
478 }
479
480 ListValue::const_iterator i = list_value->begin();
481 if (i == list_value->end()) {
482 LOG(ERROR) << "Incorrect data passed to sendReport.";
483 return;
484 }
485
486 // #0 - Problem type.
487 int problem_type;
488 std::string problem_type_str;
489 (*i)->GetAsString(&problem_type_str);
490 if (!base::StringToInt(problem_type_str, &problem_type)) {
491 LOG(ERROR) << "Incorrect data passed to sendReport.";
492 return;
493 }
494 if (++i == list_value->end()) {
495 LOG(ERROR) << "Incorrect data passed to sendReport.";
496 return;
497 }
498
499 // #1 - Page url.
500 std::string page_url;
501 (*i)->GetAsString(&page_url);
502 if (++i == list_value->end()) {
503 LOG(ERROR) << "Incorrect data passed to sendReport.";
504 return;
505 }
506
507 // #2 - Description.
508 std::string description;
509 (*i)->GetAsString(&description);
510 if (++i == list_value->end()) {
511 LOG(ERROR) << "Incorrect data passed to sendReport.";
512 return;
513 }
514
515 // #3 - Screenshot to send.
516 std::string screenshot_path;
517 (*i)->GetAsString(&screenshot_path);
518 screenshot_path.erase(0, strlen(kScreenshotBaseUrl));
519
520 // Get the image to send in the report.
521 ScreenshotDataPtr image_ptr;
522 if (!screenshot_path.empty())
523 image_ptr = screenshot_source_->GetCachedScreenshot(screenshot_path);
524
525 #if defined(OS_CHROMEOS)
526 if (++i == list_value->end()) {
527 LOG(ERROR) << "Incorrect data passed to sendReport.";
528 return;
529 }
530
531 // #4 - User e-mail
532 std::string user_email;
533 (*i)->GetAsString(&user_email);
534 if (++i == list_value->end()) {
535 LOG(ERROR) << "Incorrect data passed to sendReport.";
536 return;
537 }
538
539 // #5 - System info checkbox.
540 std::string sys_info_checkbox;
541 (*i)->GetAsString(&sys_info_checkbox);
542 bool send_sys_info = (sys_info_checkbox == "true");
543
544 // If we aren't sending the sys_info, cancel the gathering of the syslogs.
545 if (!send_sys_info)
546 CancelFeedbackCollection();
547 #endif
548
549 // Update the data in bug_report_data_ so it can be sent
550 bug_report_data_->UpdateData(Profile::FromWebUI(web_ui())
551 , target_tab_url_
552 , problem_type
553 , page_url
554 , description
555 , image_ptr
556 #if defined(OS_CHROMEOS)
557 , user_email
558 , send_sys_info
559 , false // sent_report
560 #endif
561 );
562
563 #if defined(OS_CHROMEOS)
564 // If we don't require sys_info, or we have it, or we never requested it
565 // (because libcros failed to load), then send the report now.
566 // Otherwise, the report will get sent when we receive sys_info.
567 if (!send_sys_info || bug_report_data_->sys_info() != NULL ||
568 syslogs_handle_ == 0) {
569 bug_report_data_->SendReport();
570 }
571 #else
572 bug_report_data_->SendReport();
573 #endif
574 // Lose the pointer to the BugReportData object; the object will delete itself
575 // from SendReport, whether we called it, or will be called by the log
576 // completion routine.
577 bug_report_data_ = NULL;
578
579 // Whether we sent the report, or if it will be sent by the Syslogs complete
580 // function, close our feedback tab anyway, we have no more use for it.
581 CloseFeedbackTab();
582 }
583
584 void BugReportHandler::HandleCancel(const ListValue*) {
585 CloseFeedbackTab();
586 }
587
588 void BugReportHandler::HandleOpenSystemTab(const ListValue* args) {
589 #if defined(OS_CHROMEOS)
590 BrowserList::GetLastActive()->OpenSystemTabAndActivate();
591 #endif
592 }
593
594 void BugReportHandler::CancelFeedbackCollection() {
595 #if defined(OS_CHROMEOS)
596 if (syslogs_handle_ != 0) {
597 chromeos::system::SyslogsProvider* provider =
598 chromeos::system::SyslogsProvider::GetInstance();
599 if (provider)
600 provider->CancelRequest(syslogs_handle_);
601 }
602 #endif
603 }
604
605 void BugReportHandler::CloseFeedbackTab() {
606 ClobberScreenshotsSource();
607
608 Browser* browser = BrowserList::GetLastActive();
609 if (browser) {
610 browser->CloseTabContents(tab_);
611 } else {
612 LOG(FATAL) << "Failed to get last active browser.";
613 }
614 }
615
616 ////////////////////////////////////////////////////////////////////////////////
617 //
618 // BugReportUI
619 //
620 ////////////////////////////////////////////////////////////////////////////////
621 BugReportUI::BugReportUI(WebContents* tab) : HtmlDialogUI(tab) {
622 BugReportHandler* handler = new BugReportHandler(tab);
623 AddMessageHandler(handler);
624
625 // The handler's init will determine whether we show the error html page.
626 ChromeWebUIDataSource* html_source =
627 CreateBugReportUIHTMLSource(handler->Init());
628
629 // Set up the chrome://bugreport/ source.
630 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
631 profile->GetChromeURLDataManager()->AddDataSource(html_source);
632 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bug_report_ui.h ('k') | chrome/browser/ui/webui/chrome_web_ui_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698