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

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

Issue 7635017: Fix saved screenshots for feedback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac fix 4 Created 9 years, 3 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "chrome/browser/chromeos/login/user_manager.h" 46 #include "chrome/browser/chromeos/login/user_manager.h"
47 #include "chrome/browser/chromeos/system/syslogs_provider.h" 47 #include "chrome/browser/chromeos/system/syslogs_provider.h"
48 #endif 48 #endif
49 49
50 namespace { 50 namespace {
51 51
52 const char kScreenshotBaseUrl[] = "chrome://screenshots/"; 52 const char kScreenshotBaseUrl[] = "chrome://screenshots/";
53 const char kCurrentScreenshotUrl[] = "chrome://screenshots/current"; 53 const char kCurrentScreenshotUrl[] = "chrome://screenshots/current";
54 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
55 const char kSavedScreenshotsUrl[] = "chrome://screenshots/saved/"; 55 const char kSavedScreenshotsUrl[] = "chrome://screenshots/saved/";
56 56 const char kScreenshotPattern[] = "screenshot-*.png";
57 const char kScreenshotPattern[] = "*.png";
58 const char kScreenshotsRelativePath[] = "/Screenshots";
59 57
60 const size_t kMaxSavedScreenshots = 2; 58 const size_t kMaxSavedScreenshots = 2;
61 #endif 59 #endif
62 60
63 #if defined(OS_CHROMEOS) 61 #if defined(OS_CHROMEOS)
64 62
65 void GetSavedScreenshots(std::vector<std::string>* saved_screenshots, 63 void GetSavedScreenshots(std::vector<std::string>* saved_screenshots,
66 base::WaitableEvent* done) { 64 base::WaitableEvent* done) {
67 saved_screenshots->clear(); 65 saved_screenshots->clear();
68 66
69 FilePath fileshelf_path; 67 FilePath fileshelf_path;
70 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, 68 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS,
71 &fileshelf_path)) { 69 &fileshelf_path)) {
72 done->Signal(); 70 done->Signal();
73 return; 71 return;
74 } 72 }
75 73
76 // TODO(rkc): Change this to use FilePath.Append() once the cros 74 file_util::FileEnumerator screenshots(fileshelf_path, false,
77 // issue with it is fixed
78 FilePath screenshots_path(fileshelf_path.value() +
79 std::string(kScreenshotsRelativePath));
80 file_util::FileEnumerator screenshots(screenshots_path, false,
81 file_util::FileEnumerator::FILES, 75 file_util::FileEnumerator::FILES,
82 std::string(kScreenshotPattern)); 76 std::string(kScreenshotPattern));
83 FilePath screenshot = screenshots.Next(); 77 FilePath screenshot = screenshots.Next();
84 while (!screenshot.empty()) { 78 while (!screenshot.empty()) {
85 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + 79 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) +
86 screenshot.BaseName().value()); 80 screenshot.BaseName().value());
87 if (saved_screenshots->size() >= kMaxSavedScreenshots) 81 if (saved_screenshots->size() >= kMaxSavedScreenshots)
88 break; 82 break;
89 83
90 screenshot = screenshots.Next(); 84 screenshot = screenshots.Next();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 LOG(ERROR) << "Incorrect data passed to sendReport."; 500 LOG(ERROR) << "Incorrect data passed to sendReport.";
507 return; 501 return;
508 } 502 }
509 503
510 // #3 - Screenshot to send. 504 // #3 - Screenshot to send.
511 std::string screenshot_path; 505 std::string screenshot_path;
512 (*i)->GetAsString(&screenshot_path); 506 (*i)->GetAsString(&screenshot_path);
513 screenshot_path.erase(0, strlen(kScreenshotBaseUrl)); 507 screenshot_path.erase(0, strlen(kScreenshotBaseUrl));
514 508
515 // Get the image to send in the report. 509 // Get the image to send in the report.
516 std::vector<unsigned char> image; 510 ScreenshotDataPtr image_ptr;
517 if (!screenshot_path.empty()) 511 if (!screenshot_path.empty())
518 image = screenshot_source_->GetScreenshot(screenshot_path); 512 image_ptr = screenshot_source_->GetCachedScreenshot(screenshot_path);
519 513
520 #if defined(OS_CHROMEOS) 514 #if defined(OS_CHROMEOS)
521 if (++i == list_value->end()) { 515 if (++i == list_value->end()) {
522 LOG(ERROR) << "Incorrect data passed to sendReport."; 516 LOG(ERROR) << "Incorrect data passed to sendReport.";
523 return; 517 return;
524 } 518 }
525 519
526 // #4 - User e-mail 520 // #4 - User e-mail
527 std::string user_email; 521 std::string user_email;
528 (*i)->GetAsString(&user_email); 522 (*i)->GetAsString(&user_email);
(...skipping 11 matching lines...) Expand all
540 if (!send_sys_info) 534 if (!send_sys_info)
541 CancelFeedbackCollection(); 535 CancelFeedbackCollection();
542 #endif 536 #endif
543 537
544 // Update the data in bug_report_data_ so it can be sent 538 // Update the data in bug_report_data_ so it can be sent
545 bug_report_data_->UpdateData(Profile::FromWebUI(web_ui_) 539 bug_report_data_->UpdateData(Profile::FromWebUI(web_ui_)
546 , target_tab_url_ 540 , target_tab_url_
547 , problem_type 541 , problem_type
548 , page_url 542 , page_url
549 , description 543 , description
550 , image 544 , image_ptr
551 #if defined(OS_CHROMEOS) 545 #if defined(OS_CHROMEOS)
552 , user_email 546 , user_email
553 , send_sys_info 547 , send_sys_info
554 , false // sent_report 548 , false // sent_report
555 #endif 549 #endif
556 ); 550 );
557 551
558 #if defined(OS_CHROMEOS) 552 #if defined(OS_CHROMEOS)
559 // If we don't require sys_info, or we have it, or we never requested it 553 // If we don't require sys_info, or we have it, or we never requested it
560 // (because libcros failed to load), then send the report now. 554 // (because libcros failed to load), then send the report now.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 AddMessageHandler((handler)->Attach(this)); 612 AddMessageHandler((handler)->Attach(this));
619 613
620 // The handler's init will determine whether we show the error html page. 614 // The handler's init will determine whether we show the error html page.
621 ChromeWebUIDataSource* html_source = 615 ChromeWebUIDataSource* html_source =
622 CreateBugReportUIHTMLSource(handler->Init()); 616 CreateBugReportUIHTMLSource(handler->Init());
623 617
624 // Set up the chrome://bugreport/ source. 618 // Set up the chrome://bugreport/ source.
625 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); 619 Profile* profile = Profile::FromBrowserContext(tab->browser_context());
626 profile->GetChromeURLDataManager()->AddDataSource(html_source); 620 profile->GetChromeURLDataManager()->AddDataSource(html_source);
627 } 621 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bug_report_window_controller_unittest.mm ('k') | chrome/browser/ui/webui/screenshot_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698