OLD | NEW |
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/feedback_ui.h" | 5 #include "chrome/browser/ui/webui/feedback_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/download/download_prefs.h" | 24 #include "chrome/browser/download/download_prefs.h" |
25 #include "chrome/browser/feedback/feedback_data.h" | 25 #include "chrome/browser/feedback/feedback_data.h" |
26 #include "chrome/browser/feedback/feedback_util.h" | 26 #include "chrome/browser/feedback/feedback_util.h" |
| 27 #include "chrome/browser/feedback/tracing_manager.h" |
27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/browser/signin/signin_manager.h" | 30 #include "chrome/browser/signin/signin_manager.h" |
30 #include "chrome/browser/signin/signin_manager_factory.h" | 31 #include "chrome/browser/signin/signin_manager_factory.h" |
31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_finder.h" | 33 #include "chrome/browser/ui/browser_finder.h" |
33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/chrome_pages.h" | 35 #include "chrome/browser/ui/chrome_pages.h" |
35 #include "chrome/browser/ui/singleton_tabs.h" | 36 #include "chrome/browser/ui/singleton_tabs.h" |
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 80 |
80 const char kCategoryTagParameter[] = "categoryTag="; | 81 const char kCategoryTagParameter[] = "categoryTag="; |
81 const char kDescriptionParameter[] = "description="; | 82 const char kDescriptionParameter[] = "description="; |
82 const char kSessionIDParameter[] = "session_id="; | 83 const char kSessionIDParameter[] = "session_id="; |
83 const char kTabIndexParameter[] = "tab_index="; | 84 const char kTabIndexParameter[] = "tab_index="; |
84 const char kCustomPageUrlParameter[] = "customPageUrl="; | 85 const char kCustomPageUrlParameter[] = "customPageUrl="; |
85 | 86 |
86 #if defined(OS_CHROMEOS) | 87 #if defined(OS_CHROMEOS) |
87 | 88 |
88 const char kTimestampParameter[] = "timestamp="; | 89 const char kTimestampParameter[] = "timestamp="; |
| 90 const char kTraceIdParameter[] = "traceId="; |
89 | 91 |
90 const size_t kMaxSavedScreenshots = 2; | 92 const size_t kMaxSavedScreenshots = 2; |
91 size_t kMaxNumScanFiles = 1000; | 93 size_t kMaxNumScanFiles = 1000; |
92 | 94 |
93 // Compare two screenshot filepaths, which include the screenshot timestamp | 95 // Compare two screenshot filepaths, which include the screenshot timestamp |
94 // in the format of screenshot-yyyymmdd-hhmmss.png. Return true if |filepath1| | 96 // in the format of screenshot-yyyymmdd-hhmmss.png. Return true if |filepath1| |
95 // is more recent |filepath2|. | 97 // is more recent |filepath2|. |
96 bool ScreenshotTimestampComp(const std::string& filepath1, | 98 bool ScreenshotTimestampComp(const std::string& filepath1, |
97 const std::string& filepath2) { | 99 const std::string& filepath2) { |
98 return filepath1 > filepath2; | 100 return filepath1 > filepath2; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 kSessionIDParameter + base::IntToString(browser->session_id().id()) + | 231 kSessionIDParameter + base::IntToString(browser->session_id().id()) + |
230 "&" + kTabIndexParameter + | 232 "&" + kTabIndexParameter + |
231 base::IntToString(browser->tab_strip_model()->active_index()) + | 233 base::IntToString(browser->tab_strip_model()->active_index()) + |
232 "&" + kDescriptionParameter + | 234 "&" + kDescriptionParameter + |
233 net::EscapeUrlEncodedData(description_template, false) + "&" + | 235 net::EscapeUrlEncodedData(description_template, false) + "&" + |
234 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false); | 236 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false); |
235 | 237 |
236 #if defined(OS_CHROMEOS) | 238 #if defined(OS_CHROMEOS) |
237 feedback_url = feedback_url + "&" + kTimestampParameter + | 239 feedback_url = feedback_url + "&" + kTimestampParameter + |
238 net::EscapeUrlEncodedData(timestamp, false); | 240 net::EscapeUrlEncodedData(timestamp, false); |
| 241 |
| 242 // The manager is only available if tracing is enabled. |
| 243 if (TracingManager* manager = TracingManager::Get()) { |
| 244 int trace_id = manager->RequestTrace(); |
| 245 feedback_url = feedback_url + "&" + kTraceIdParameter + |
| 246 base::IntToString(trace_id); |
| 247 } |
239 #endif | 248 #endif |
240 chrome::ShowSingletonTab(browser, GURL(feedback_url)); | 249 chrome::ShowSingletonTab(browser, GURL(feedback_url)); |
241 } | 250 } |
242 | 251 |
243 } // namespace chrome | 252 } // namespace chrome |
244 | 253 |
245 // The handler for Javascript messages related to the "bug report" dialog | 254 // The handler for Javascript messages related to the "bug report" dialog |
246 class FeedbackHandler : public WebUIMessageHandler, | 255 class FeedbackHandler : public WebUIMessageHandler, |
247 public base::SupportsWeakPtr<FeedbackHandler> { | 256 public base::SupportsWeakPtr<FeedbackHandler> { |
248 public: | 257 public: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 source->AddLocalizedString("page-title", IDS_FEEDBACK_REPORT_PAGE_TITLE); | 309 source->AddLocalizedString("page-title", IDS_FEEDBACK_REPORT_PAGE_TITLE); |
301 source->AddLocalizedString("page-url", IDS_FEEDBACK_REPORT_URL_LABEL); | 310 source->AddLocalizedString("page-url", IDS_FEEDBACK_REPORT_URL_LABEL); |
302 source->AddLocalizedString("description", IDS_FEEDBACK_DESCRIPTION_LABEL); | 311 source->AddLocalizedString("description", IDS_FEEDBACK_DESCRIPTION_LABEL); |
303 source->AddLocalizedString("current-screenshot", | 312 source->AddLocalizedString("current-screenshot", |
304 IDS_FEEDBACK_SCREENSHOT_LABEL); | 313 IDS_FEEDBACK_SCREENSHOT_LABEL); |
305 source->AddLocalizedString("saved-screenshot", | 314 source->AddLocalizedString("saved-screenshot", |
306 IDS_FEEDBACK_SAVED_SCREENSHOT_LABEL); | 315 IDS_FEEDBACK_SAVED_SCREENSHOT_LABEL); |
307 source->AddLocalizedString("user-email", IDS_FEEDBACK_USER_EMAIL_LABEL); | 316 source->AddLocalizedString("user-email", IDS_FEEDBACK_USER_EMAIL_LABEL); |
308 | 317 |
309 #if defined(OS_CHROMEOS) | 318 #if defined(OS_CHROMEOS) |
| 319 source->AddLocalizedString("performance-trace", |
| 320 IDS_FEEDBACK_INCLUDE_PERFORMANCE_TRACE_CHECKBOX); |
310 source->AddLocalizedString("sysinfo", | 321 source->AddLocalizedString("sysinfo", |
311 IDS_FEEDBACK_INCLUDE_SYSTEM_INFORMATION_CHKBOX); | 322 IDS_FEEDBACK_INCLUDE_SYSTEM_INFORMATION_CHKBOX); |
312 source->AddLocalizedString("currentscreenshots", | 323 source->AddLocalizedString("currentscreenshots", |
313 IDS_FEEDBACK_CURRENT_SCREENSHOTS); | 324 IDS_FEEDBACK_CURRENT_SCREENSHOTS); |
314 source->AddLocalizedString("savedscreenshots", | 325 source->AddLocalizedString("savedscreenshots", |
315 IDS_FEEDBACK_SAVED_SCREENSHOTS); | 326 IDS_FEEDBACK_SAVED_SCREENSHOTS); |
316 source->AddLocalizedString("choose-different-screenshot", | 327 source->AddLocalizedString("choose-different-screenshot", |
317 IDS_FEEDBACK_CHOOSE_DIFFERENT_SCREENSHOT); | 328 IDS_FEEDBACK_CHOOSE_DIFFERENT_SCREENSHOT); |
318 source->AddLocalizedString("choose-original-screenshot", | 329 source->AddLocalizedString("choose-original-screenshot", |
319 IDS_FEEDBACK_CHOOSE_ORIGINAL_SCREENSHOT); | 330 IDS_FEEDBACK_CHOOSE_ORIGINAL_SCREENSHOT); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // Get the image to send in the report. | 612 // Get the image to send in the report. |
602 ScreenshotDataPtr image_ptr; | 613 ScreenshotDataPtr image_ptr; |
603 if (!screenshot_path.empty() && screenshot_source_) | 614 if (!screenshot_path.empty() && screenshot_source_) |
604 image_ptr = screenshot_source_->GetCachedScreenshot(screenshot_path); | 615 image_ptr = screenshot_source_->GetCachedScreenshot(screenshot_path); |
605 | 616 |
606 #if defined(OS_CHROMEOS) | 617 #if defined(OS_CHROMEOS) |
607 std::string sys_info_checkbox; | 618 std::string sys_info_checkbox; |
608 (*i++)->GetAsString(&sys_info_checkbox); | 619 (*i++)->GetAsString(&sys_info_checkbox); |
609 bool send_sys_info = (sys_info_checkbox == "true"); | 620 bool send_sys_info = (sys_info_checkbox == "true"); |
610 | 621 |
| 622 std::string trace_id_str; |
| 623 (*i++)->GetAsString(&trace_id_str); |
| 624 int trace_id = 0; |
| 625 base::StringToInt(trace_id_str, &trace_id); |
| 626 |
611 std::string attached_filename; | 627 std::string attached_filename; |
612 scoped_ptr<std::string> attached_filedata; | 628 scoped_ptr<std::string> attached_filedata; |
613 // If we have an attached file, we'll still have more data in the list. | 629 // If we have an attached file, we'll still have more data in the list. |
614 if (i != list_value->end()) { | 630 if (i != list_value->end()) { |
615 (*i++)->GetAsString(&attached_filename); | 631 (*i++)->GetAsString(&attached_filename); |
616 if (base::FilePath::IsSeparator(attached_filename[0])) { | 632 if (base::FilePath::IsSeparator(attached_filename[0])) { |
617 // We have an attached filepath, not filename, hence we need read this | 633 // We have an attached filepath, not filename, hence we need read this |
618 // this file in chrome. We won't have any file data, skip over it. | 634 // this file in chrome. We won't have any file data, skip over it. |
619 i++; | 635 i++; |
620 } else { | 636 } else { |
(...skipping 17 matching lines...) Expand all Loading... |
638 feedback_data_->set_description(description); | 654 feedback_data_->set_description(description); |
639 feedback_data_->set_image(image_ptr); | 655 feedback_data_->set_image(image_ptr); |
640 feedback_data_->set_page_url(page_url); | 656 feedback_data_->set_page_url(page_url); |
641 feedback_data_->set_profile(Profile::FromWebUI(web_ui())); | 657 feedback_data_->set_profile(Profile::FromWebUI(web_ui())); |
642 feedback_data_->set_user_email(user_email); | 658 feedback_data_->set_user_email(user_email); |
643 #if defined(OS_CHROMEOS) | 659 #if defined(OS_CHROMEOS) |
644 feedback_data_->set_attached_filedata(attached_filedata.Pass()); | 660 feedback_data_->set_attached_filedata(attached_filedata.Pass()); |
645 feedback_data_->set_attached_filename(attached_filename); | 661 feedback_data_->set_attached_filename(attached_filename); |
646 feedback_data_->set_send_sys_info(send_sys_info); | 662 feedback_data_->set_send_sys_info(send_sys_info); |
647 feedback_data_->set_timestamp(timestamp_); | 663 feedback_data_->set_timestamp(timestamp_); |
| 664 feedback_data_->set_trace_id(trace_id); |
648 #endif | 665 #endif |
649 | 666 |
650 // Signal the feedback object that the data from the feedback page has been | 667 // Signal the feedback object that the data from the feedback page has been |
651 // filled - the object will manage sending of the actual report. | 668 // filled - the object will manage sending of the actual report. |
652 feedback_data_->FeedbackPageDataComplete(); | 669 feedback_data_->FeedbackPageDataComplete(); |
653 | 670 |
654 CloseFeedbackTab(); | 671 CloseFeedbackTab(); |
655 } | 672 } |
656 | 673 |
657 void FeedbackHandler::HandleCancel(const ListValue*) { | 674 void FeedbackHandler::HandleCancel(const ListValue*) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 screenshot_filepaths.begin() + sort_size, | 735 screenshot_filepaths.begin() + sort_size, |
719 screenshot_filepaths.end(), | 736 screenshot_filepaths.end(), |
720 ScreenshotTimestampComp); | 737 ScreenshotTimestampComp); |
721 for (size_t i = 0; i < sort_size; ++i) | 738 for (size_t i = 0; i < sort_size; ++i) |
722 saved_screenshots->push_back( | 739 saved_screenshots->push_back( |
723 std::string(ScreenshotSource::kScreenshotUrlRoot) + | 740 std::string(ScreenshotSource::kScreenshotUrlRoot) + |
724 std::string(ScreenshotSource::kScreenshotSaved) + | 741 std::string(ScreenshotSource::kScreenshotSaved) + |
725 screenshot_filepaths[i]); | 742 screenshot_filepaths[i]); |
726 } | 743 } |
727 #endif | 744 #endif |
OLD | NEW |