diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 05:55:06 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 05:55:06 +0000 |
commit | e251662cc98ddde6f01483e8f6195ac94a98e494 (patch) | |
tree | 5a70b2f84c5cbc44398c25a243d90113ac3e426b /chrome/browser | |
parent | cb58c8cffe58b6cb0aa357998179b7b03b41a8ec (diff) | |
download | chromium_src-e251662cc98ddde6f01483e8f6195ac94a98e494.zip chromium_src-e251662cc98ddde6f01483e8f6195ac94a98e494.tar.gz chromium_src-e251662cc98ddde6f01483e8f6195ac94a98e494.tar.bz2 |
Submitting http://codereview.chromium.org/2081006/show on behalf of rkc@chromium.org:
Changes for sending user e-mail along with the feedback
Changes to implement complete userfeedback stack.
TBR=zelidrag@chromium.org
TEST=none
BUG=chromium-os:2761
Review URL: http://codereview.chromium.org/2090011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/bug_report_util.cc | 33 | ||||
-rw-r--r-- | chrome/browser/bug_report_util.h | 14 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/cros_api.gyp | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/cros_library.cc | 23 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/cros_library.h | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/syslogs_library.cc | 20 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/syslogs_library.h | 38 | ||||
-rw-r--r-- | chrome/browser/cocoa/bug_report_window_controller.mm | 1 | ||||
-rw-r--r-- | chrome/browser/views/bug_report_view.cc | 272 | ||||
-rw-r--r-- | chrome/browser/views/bug_report_view.h | 68 |
10 files changed, 402 insertions, 78 deletions
diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/bug_report_util.cc index 37aa8f8..919167b 100644 --- a/chrome/browser/bug_report_util.cc +++ b/chrome/browser/bug_report_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,7 @@ #include "chrome/common/net/url_fetcher.h" #include "googleurl/src/gurl.h" #include "grit/locale_settings.h" +#include "net/url_request/url_request_status.h" #include "unicode/locid.h" #include <string> @@ -28,7 +29,7 @@ const char kReportPhishingUrl[] = // URL to post bug reports to. const char* const kBugReportPostUrl = - "http://feedback2-dev.corp.google.com/tools/feedback/chrome/__submit"; + "https://feedback2-test.corp.google.com/tools/feedback/chrome/__submit"; const char* const kProtBufMimeType = "application/x-protobuf"; const char* const kPngMimeType = "image/png"; @@ -68,6 +69,10 @@ void BugReportUtil::PostCleanup::OnURLFetchComplete( int response_code, const ResponseCookies& cookies, const std::string& data) { + // if not 204, something went wrong + if (response_code != 204) + LOG(WARNING) << "Submission to feedback server failed. Response code: " << + response_code << std::endl; // Delete the URLFetcher. delete source; // And then delete ourselves. @@ -118,11 +123,17 @@ void BugReportUtil::SendReport(Profile* profile, const std::string& page_title_text, int problem_type, const std::string& page_url_text, + const std::string& user_email_text, const std::string& description, const char* png_data, int png_data_length, int png_width, +#if defined(OS_CHROMEOS) + int png_height, + const chromeos::LogDictionaryType* const sys_info) { +#else int png_height) { +#endif GURL post_url(kBugReportPostUrl); // Create google feedback protocol buffer objects @@ -133,7 +144,10 @@ void BugReportUtil::SendReport(Profile* profile, userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); userfeedback::WebData* web_data = feedback_data.mutable_web_data(); - // set GAIA id to 0 to indicate no username available + // Set GAIA id to 0. We're not using gaia id's for recording + // use feedback - we're using the e-mail field, allows users to + // submit feedback from incognito mode and specify any mail id + // they wish common_data->set_gaia_id(0); // Add the page title. @@ -143,6 +157,9 @@ void BugReportUtil::SendReport(Profile* profile, AddFeedbackData(&feedback_data, std::string(kProblemTypeTag), StringPrintf("%d\r\n", problem_type)); + // Add the user e-mail to the feedback object + common_data->set_user_email(user_email_text); + // Add the description to the feedback object common_data->set_description(description); @@ -172,12 +189,16 @@ void BugReportUtil::SendReport(Profile* profile, SetOSVersion(&os_version); AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); +#if defined(OS_CHROMEOS) + for (chromeos::LogDictionaryType::const_iterator i = sys_info->begin(); + i != sys_info->end(); ++i) + AddFeedbackData(&feedback_data, i->first, i->second); +#endif // Include the page image if we have one. if (png_data) { userfeedback::PostedScreenshot screenshot; screenshot.set_mime_type(kPngMimeType); - // Set the dimensions of the screenshot userfeedback::Dimensions dimensions; dimensions.set_width(static_cast<float>(png_width)); @@ -189,10 +210,6 @@ void BugReportUtil::SendReport(Profile* profile, *(feedback_data.mutable_screenshot()) = screenshot; } - // TODO(awalker): include the page source if we can get it. - // if (include_page_source_checkbox_->checked()) { - // } - // We have the body of our POST, so send it off to the server. URLFetcher* fetcher = new URLFetcher(post_url, URLFetcher::POST, new BugReportUtil::PostCleanup); diff --git a/chrome/browser/bug_report_util.h b/chrome/browser/bug_report_util.h index a56d4e1..a37f8e8 100644 --- a/chrome/browser/bug_report_util.h +++ b/chrome/browser/bug_report_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,12 +14,16 @@ #include "base/sys_info.h" #endif #include "base/scoped_ptr.h" - #include "chrome/browser/userfeedback/proto/common.pb.h" #include "chrome/browser/userfeedback/proto/extension.pb.h" #include "chrome/browser/userfeedback/proto/math.pb.h" #include "gfx/rect.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/syslogs_library.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#endif + class Profile; class TabContents; @@ -52,11 +56,17 @@ class BugReportUtil { const std::string& page_title_text, int problem_type, const std::string& page_url_text, + const std::string& user_email_text, const std::string& description, const char* png_data, int png_data_length, int png_width, +#if defined(OS_CHROMEOS) + int png_height, + const chromeos::LogDictionaryType* const sys_info); +#else int png_height); +#endif // Redirects the user to Google's phishing reporting page. static void ReportPhishing(TabContents* currentTab, diff --git a/chrome/browser/chromeos/cros/cros_api.gyp b/chrome/browser/chromeos/cros/cros_api.gyp index 98cff69..13b52ec 100644 --- a/chrome/browser/chromeos/cros/cros_api.gyp +++ b/chrome/browser/chromeos/cros/cros_api.gyp @@ -5,6 +5,7 @@ 'sources': [ '../../../../third_party/cros/chromeos_power.h', '../../../../third_party/cros/chromeos_network.h', + '../../../../third_party/cros/chromeos_syslogs.h', '../../../../third_party/cros/load.cc', ], 'include_dirs': [ diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc index e57b428..023bc01 100644 --- a/chrome/browser/chromeos/cros/cros_library.cc +++ b/chrome/browser/chromeos/cros/cros_library.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,6 +14,7 @@ #include "chrome/browser/chromeos/cros/screen_lock_library.h" #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" #include "chrome/browser/chromeos/cros/synaptics_library.h" +#include "chrome/browser/chromeos/cros/syslogs_library.h" namespace chromeos { @@ -27,6 +28,7 @@ CrosLibrary::CrosLibrary() : library_loader_(NULL), screen_lock_lib_(NULL), speech_synthesis_lib_(NULL), synaptics_lib_(NULL), + syslogs_lib_(NULL), own_library_loader_(true), own_cryptohome_lib_(true), own_language_lib_(true), @@ -37,6 +39,7 @@ CrosLibrary::CrosLibrary() : library_loader_(NULL), own_screen_lock_lib_(true), own_speech_synthesis_lib_(true), own_synaptics_lib_(true), + own_syslogs_lib_(true), loaded_(false), load_error_(false), test_api_(NULL) { @@ -64,6 +67,8 @@ CrosLibrary::~CrosLibrary() { delete speech_synthesis_lib_; if (own_synaptics_lib_) delete synaptics_lib_; + if (own_syslogs_lib_) + delete syslogs_lib_; delete test_api_; } @@ -126,6 +131,12 @@ SynapticsLibrary* CrosLibrary::GetSynapticsLibrary() { return synaptics_lib_; } +SyslogsLibrary* CrosLibrary::GetSyslogsLibrary() { + if (!syslogs_lib_) + syslogs_lib_ = new SyslogsLibraryImpl(); + return syslogs_lib_; +} + bool CrosLibrary::EnsureLoaded() { if (!loaded_ && !load_error_) { if (!library_loader_) @@ -224,4 +235,12 @@ void CrosLibrary::TestApi::SetSynapticsLibrary(SynapticsLibrary* library, library_->synaptics_lib_ = library; } -} // end namespace. +void CrosLibrary::TestApi::SetSyslogsLibrary(SyslogsLibrary* library, + bool own) { + if (library_->syslogs_lib_) + delete library_->syslogs_lib_; + library_->own_syslogs_lib_ = own; + library_->syslogs_lib_ = library; +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h index 339f64e..13ac5ed 100644 --- a/chrome/browser/chromeos/cros/cros_library.h +++ b/chrome/browser/chromeos/cros/cros_library.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,7 @@ class PowerLibrary; class ScreenLockLibrary; class SpeechSynthesisLibrary; class SynapticsLibrary; +class SyslogsLibrary; // This class handles access to sub-parts of ChromeOS library. it provides // a level of indirection so individual libraries that it exposes can @@ -55,6 +56,8 @@ class CrosLibrary { void SetSpeechSynthesisLibrary(SpeechSynthesisLibrary* library, bool own); // Setter for SynapticsLibrary. void SetSynapticsLibrary(SynapticsLibrary* library, bool own); + // Setter for SyslogsLibrary. + void SetSyslogsLibrary(SyslogsLibrary* library, bool own); private: friend class CrosLibrary; @@ -92,6 +95,9 @@ class CrosLibrary { // This gets the singleton SynapticsLibrary. SynapticsLibrary* GetSynapticsLibrary(); + // This gets the singleton SyslogsLibrary. + SyslogsLibrary* GetSyslogsLibrary(); + // Getter for Test API that gives access to internal members of this class. TestApi* GetTestApi(); @@ -121,6 +127,7 @@ class CrosLibrary { ScreenLockLibrary* screen_lock_lib_; SpeechSynthesisLibrary* speech_synthesis_lib_; SynapticsLibrary* synaptics_lib_; + SyslogsLibrary* syslogs_lib_; bool own_library_loader_; bool own_cryptohome_lib_; @@ -132,6 +139,7 @@ class CrosLibrary { bool own_screen_lock_lib_; bool own_speech_synthesis_lib_; bool own_synaptics_lib_; + bool own_syslogs_lib_; // True if libcros was successfully loaded. bool loaded_; diff --git a/chrome/browser/chromeos/cros/syslogs_library.cc b/chrome/browser/chromeos/cros/syslogs_library.cc new file mode 100644 index 0000000..365e9fe --- /dev/null +++ b/chrome/browser/chromeos/cros/syslogs_library.cc @@ -0,0 +1,20 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/cros/syslogs_library.h" + +#include "base/string_util.h" +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/chromeos/cros/cros_library.h" + +namespace chromeos { + +LogDictionaryType* SyslogsLibraryImpl::GetSyslogs(FilePath* tmpfilename) { + if (CrosLibrary::Get()->EnsureLoaded()) { + return chromeos::GetSystemLogs(tmpfilename); + } + return NULL; +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/cros/syslogs_library.h b/chrome/browser/chromeos/cros/syslogs_library.h new file mode 100644 index 0000000..1d7d9ba --- /dev/null +++ b/chrome/browser/chromeos/cros/syslogs_library.h @@ -0,0 +1,38 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_CROS_SYSLOGS_LIBRARY_H_ +#define CHROME_BROWSER_CHROMEOS_CROS_SYSLOGS_LIBRARY_H_ + +#include "base/singleton.h" +#include "third_party/cros/chromeos_syslogs.h" + +namespace chromeos { + +// This interface defines interaction with the ChromeOS syslogs APIs. +class SyslogsLibrary { + public: + SyslogsLibrary() {} + virtual ~SyslogsLibrary() {} + + // System logs gathered for userfeedback + virtual LogDictionaryType* GetSyslogs(FilePath* tmpfilename) = 0; +}; + + +// This class handles the interaction with the ChromeOS syslogs APIs. +class SyslogsLibraryImpl : public SyslogsLibrary { + public: + SyslogsLibraryImpl() {} + virtual ~SyslogsLibraryImpl() {} + + virtual LogDictionaryType* GetSyslogs(FilePath* tmpfilename); + + private: + DISALLOW_COPY_AND_ASSIGN(SyslogsLibraryImpl); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_CROS_SYSLOGS_LIBRARY_H_ diff --git a/chrome/browser/cocoa/bug_report_window_controller.mm b/chrome/browser/cocoa/bug_report_window_controller.mm index df29f99..c7e920da 100644 --- a/chrome/browser/cocoa/bug_report_window_controller.mm +++ b/chrome/browser/cocoa/bug_report_window_controller.mm @@ -113,6 +113,7 @@ base::SysNSStringToUTF8(pageTitle_), [self bugTypeFromIndex], base::SysNSStringToUTF8(pageURL_), + std::string(), base::SysNSStringToUTF8(bugDescription_), sendScreenshot_ && !pngData_.empty() ? reinterpret_cast<const char *>(&(pngData_[0])) : NULL, diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index 2ae2f67..3e7c635 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -6,17 +6,23 @@ #include "app/combobox_model.h" #include "app/l10n_util.h" +#include "base/file_path.h" +#include "base/file_util.h" #include "base/file_version_info.h" +#include "base/path_service.h" #include "base/utf_string_conversions.h" +#include "base/waitable_event.h" #include "chrome/app/chrome_version_info.h" #include "chrome/browser/bug_report_util.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/safe_browsing/safe_browsing_util.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/pref_names.h" #include "grit/chromium_strings.h" @@ -38,12 +44,19 @@ #include "app/win_util.h" #endif +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/login/user_manager.h" +#endif + using views::ColumnSet; using views::GridLayout; // Report a bug data version. static const int kBugReportVersion = 1; static const int kScreenImageRadioGroup = 2; +static const char kScreenshotsRelativePath[] = "/Screenshots"; +static const char kScreenshotPattern[] = "*.png"; +static const char kAboutBlank[] = "about:blank"; // Number of lines description field can display at one time. @@ -90,6 +103,73 @@ class BugReportComboBoxModel : public ComboboxModel { DISALLOW_COPY_AND_ASSIGN(BugReportComboBoxModel); }; +namespace { + +#if defined(OS_CHROMEOS) +class LastScreenshotTask : public Task { + public: + LastScreenshotTask(std::string* image_str, + base::WaitableEvent* task_waitable) + : image_str_(image_str), + task_waitable_(task_waitable) { + } + + private: + void Run() { + FilePath fileshelf_path; + // TODO(rkc): Change this to use FilePath.Append() once the cros + // issue with with it is fixed + if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, + &fileshelf_path)) { + *image_str_ = ""; + task_waitable_->Signal(); + } + + FilePath screenshots_path(fileshelf_path.value() + + std::string(kScreenshotsRelativePath)); + file_util::FileEnumerator screenshots(screenshots_path, false, + file_util::FileEnumerator::FILES, + std::string(kScreenshotPattern)); + FilePath screenshot = screenshots.Next(); + FilePath latest(""); + time_t last_mtime = 0; + while (!screenshot.empty()) { + file_util::FileEnumerator::FindInfo info; + screenshots.GetFindInfo(&info); + if (info.stat.st_mtime > last_mtime) { + last_mtime = info.stat.st_mtime; + latest = screenshot; + } + screenshot = screenshots.Next(); + } + + if (!file_util::ReadFileToString(latest, image_str_)) + *image_str_ = ""; + task_waitable_->Signal(); + } + private: + std::string* image_str_; + base::WaitableEvent* task_waitable_; +}; +#endif + +bool GetLastScreenshot(std::string* image_str) { +#if defined(OS_CHROMEOS) + base::WaitableEvent task_waitable(true, false); + ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, + new LastScreenshotTask(image_str, &task_waitable)); + task_waitable.Wait(); + if (*image_str == "") + return false; + else + return true; +#else + return false; +#endif +} + +} // namespace + namespace browser { // Global "display this dialog" function declared in browser_dialogs.h. @@ -98,6 +178,10 @@ void ShowBugReportView(views::Window* parent, TabContents* tab) { BugReportView* view = new BugReportView(profile, tab); + // Get the size of the parent window to capture screenshot dimensions + gfx::Rect screen_size = parent->GetBounds(); + view->set_screen_size(screen_size); + // Grab an exact snapshot of the window that the user is seeing (i.e. as // rendered--do not re-render, and include windowed plugins). std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>; @@ -108,25 +192,38 @@ void ShowBugReportView(views::Window* parent, win_util::GrabWindowSnapshot(parent->GetNativeWindow(), screenshot_png); #endif - // Get the size of the parent window to capture screenshot dimensions - gfx::Rect screenshot_size = parent->GetBounds(); - + // The BugReportView takes ownership of the image data, and will dispose of + // it in its destructor + view->set_captured_image(screenshot_png); - // The BugReportView takes ownership of the png data, and will dispose of - // it in its destructor. - view->set_png_data(screenshot_png); - view->set_screenshot_size(screenshot_size); +#if defined(OS_CHROMEOS) + // Get last screenshot taken + std::string image_str; + bool have_last_image = false; + if (GetLastScreenshot(&image_str)) { + // reuse screenshot_png; previous pointer now owned by BugReportView + screenshot_png = new std::vector<unsigned char>(image_str.begin(), + image_str.end()); + have_last_image = true; + } else { + // else set it to be an empty vector + screenshot_png = new std::vector<unsigned char>; + } + view->set_last_image(screenshot_png); - // Create and show the dialog. + // Create and show the dialog views::Window::CreateChromeWindow(parent->GetNativeWindow(), gfx::Rect(), view)->Show(); + if (!have_last_image) + view->DisableLastImageRadio(); + view->DisableSystemInformationCheckbox(); +#endif } } // namespace browser // BugReportView - create and submit a bug report from the user. // This is separate from crash reporting, which is handled by Breakpad. -// BugReportView::BugReportView(Profile* profile, TabContents* tab) : include_page_source_checkbox_(NULL), include_page_image_checkbox_(NULL), @@ -143,6 +240,19 @@ BugReportView::BugReportView(Profile* profile, TabContents* tab) tab->controller().GetActiveEntry()->url().spec())); } +#if defined(OS_CHROMEOS) + // Get and set the gaia e-mail + chromeos::UserManager* manager = chromeos::UserManager::Get(); + if (!manager) { + user_email_text_->SetText(UTF8ToUTF16(std::string(""))); + } else { + const std::string& email = manager->logged_in_user().email(); + user_email_text_->SetText(UTF8ToUTF16(email)); + if (!email.empty()) + user_email_text_->SetEnabled(false); + } +#endif + // Retrieve the application version info. scoped_ptr<FileVersionInfo> version_info( chrome_app::GetChromeVersionInfo()); @@ -151,6 +261,23 @@ BugReportView::BugReportView(Profile* profile, TabContents* tab) version_info->file_version() + L" (" + version_info->last_change() + L")"; } + + + FilePath tmpfilename; + +#if defined(OS_CHROMEOS) + chromeos::SyslogsLibrary* syslogs_lib = + chromeos::CrosLibrary::Get()->GetSyslogsLibrary(); + if (syslogs_lib) { + sys_info_.reset(syslogs_lib->GetSyslogs(&tmpfilename)); + if (sys_info_.get()) + system_information_url_ = std::string("file://") + tmpfilename.value(); + else + system_information_url_ = std::string(kAboutBlank); + } else { + system_information_url_ = std::string(kAboutBlank); + } +#endif } BugReportView::~BugReportView() { @@ -176,6 +303,15 @@ void BugReportView::SetupControl() { page_url_text_->SetController(this); page_url_text_->SetAccessibleName(page_url_label_->GetText()); +#if defined(OS_CHROMEOS) + user_email_label_ = new views::Label( + l10n_util::GetString(IDS_BUGREPORT_USER_EMAIL_LABEL)); + // user_email_text_'s text (if any) is filled in after dialog creation. + user_email_text_ = new views::Textfield; + user_email_text_->SetController(this); + user_email_text_->SetAccessibleName(user_email_label_->GetText()); +#endif + description_label_ = new views::Label( l10n_util::GetString(IDS_BUGREPORT_DESCRIPTION_LABEL)); #if defined(OS_LINUX) @@ -196,19 +332,22 @@ void BugReportView::SetupControl() { include_last_screen_image_radio_ = new views::RadioButton( l10n_util::GetString(IDS_BUGREPORT_INCLUDE_LAST_SCREEN_IMAGE), kScreenImageRadioGroup); - last_screenshot_iv_ = new views::ImageView(); include_new_screen_image_radio_ = new views::RadioButton( l10n_util::GetString(IDS_BUGREPORT_INCLUDE_NEW_SCREEN_IMAGE), kScreenImageRadioGroup); + include_no_screen_image_radio_ = new views::RadioButton( + l10n_util::GetString(IDS_BUGREPORT_INCLUDE_NO_SCREEN_IMAGE), + kScreenImageRadioGroup); + include_system_information_checkbox_ = new views::Checkbox( l10n_util::GetString(IDS_BUGREPORT_INCLUDE_SYSTEM_INFORMATION_CHKBOX)); - system_information_url_ = new views::Link( + system_information_url_control_ = new views::Link( l10n_util::GetString(IDS_BUGREPORT_SYSTEM_INFORMATION_URL_TEXT)); - system_information_url_->SetController(this); + system_information_url_control_->SetController(this); - include_last_screen_image_radio_->SetChecked(true); + include_new_screen_image_radio_->SetChecked(true); include_system_information_checkbox_->SetChecked(true); #endif include_page_image_checkbox_ = new views::Checkbox( @@ -251,6 +390,13 @@ void BugReportView::SetupControl() { GridLayout::LEADING); layout->AddView(description_text_, 1, 1, GridLayout::FILL, GridLayout::LEADING); +#if defined(OS_CHROMEOS) + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + // Page URL and text field. + layout->StartRow(0, column_set_id); + layout->AddView(user_email_label_); + layout->AddView(user_email_text_); +#endif layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); // Checkboxes. @@ -259,24 +405,34 @@ void BugReportView::SetupControl() { // layout->SkipColumns(1); // layout->AddView(include_page_source_checkbox_); // layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - layout->StartRow(0, column_set_id); - layout->SkipColumns(1); + layout->StartRow(0, column_set_id); + layout->SkipColumns(1); #if defined(OS_CHROMEOS) - // Radio boxes to select last screen shot or, - layout->AddView(include_last_screen_image_radio_); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - // new screenshot - layout->StartRow(0, column_set_id); - layout->SkipColumns(1); - layout->AddView(include_new_screen_image_radio_); - layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); + // Radio boxes to select last screen shot or, - // Checkbox for system information - layout->StartRow(0, column_set_id); - layout->SkipColumns(1); - layout->AddView(include_system_information_checkbox_); + // new screenshot + layout->AddView(include_new_screen_image_radio_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + // last screenshot taken + layout->StartRow(0, column_set_id); + layout->SkipColumns(1); + layout->AddView(include_last_screen_image_radio_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + // no screenshot + layout->StartRow(0, column_set_id); + layout->SkipColumns(1); + layout->AddView(include_no_screen_image_radio_); + layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); + + // Checkbox for system information + layout->StartRow(0, column_set_id); + layout->SkipColumns(1); + layout->AddView(include_system_information_checkbox_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - // TODO(rkc): Add a link once we're pulling system info, to it + layout->StartRow(0, column_set_id); + layout->SkipColumns(1); + layout->AddView(system_information_url_control_); #else if (include_page_image_checkbox_) { layout->StartRow(0, column_set_id); @@ -294,7 +450,6 @@ gfx::Size BugReportView::GetPreferredSize() { IDS_BUGREPORT_DIALOG_HEIGHT_LINES)); } - void BugReportView::UpdateReportingControls(bool is_phishing_report) { // page source, screen/page images, system information // are not needed if it's a phishing report @@ -303,13 +458,11 @@ void BugReportView::UpdateReportingControls(bool is_phishing_report) { include_page_source_checkbox_->SetChecked(!is_phishing_report); #if defined(OS_CHROMEOS) - include_last_screen_image_radio_->SetEnabled(!is_phishing_report); include_new_screen_image_radio_->SetEnabled(!is_phishing_report); - - include_system_information_checkbox_->SetEnabled(!is_phishing_report); + if (!last_image_->empty()) + include_last_screen_image_radio_->SetEnabled(!is_phishing_report); + include_no_screen_image_radio_->SetEnabled(!is_phishing_report); include_system_information_checkbox_->SetChecked(!is_phishing_report); - - system_information_url_->SetEnabled(!is_phishing_report); #else if (include_page_image_checkbox_) { include_page_image_checkbox_->SetEnabled(!is_phishing_report); @@ -390,25 +543,53 @@ std::wstring BugReportView::GetWindowTitle() const { return l10n_util::GetString(IDS_BUGREPORT_TITLE); } + bool BugReportView::Accept() { if (IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { - if (problem_type_ == BugReportUtil::PHISHING_PAGE) + if (problem_type_ == BugReportUtil::PHISHING_PAGE) { BugReportUtil::ReportPhishing(tab_, UTF16ToUTF8(page_url_text_->text())); - else + } else { + char* image_data = NULL; + size_t image_data_size = 0; +#if defined(OS_CHROMEOS) + if (include_new_screen_image_radio_->checked() && + !captured_image_->empty()) { + image_data = reinterpret_cast<char *>(&captured_image_->front()); + image_data_size = captured_image_->size(); + } else if (include_last_screen_image_radio_->checked() && + !last_image_->empty()) { + image_data = reinterpret_cast<char *>(&last_image_->front()); + image_data_size = last_image_->size(); + } +#else + if (include_page_image_checkbox_->checked() && captured_image_.get() && + !captured_image_->empty()) { + image_data = reinterpret_cast<char *>(&captured_image_->front()); + image_data_size = captured_image_->size(); + } +#endif +#if defined(OS_CHROMEOS) BugReportUtil::SendReport(profile_, WideToUTF8(page_title_text_->GetText()), problem_type_, UTF16ToUTF8(page_url_text_->text()), + UTF16ToUTF8(user_email_text_->text()), UTF16ToUTF8(description_text_->text()), -#if defined(OS_CHROMEOS) - include_new_screen_image_radio_->checked() && png_data_.get() ? + image_data, image_data_size, + screen_size_.width(), screen_size_.height(), + sys_info_.get()); #else - include_page_image_checkbox_->checked() && png_data_.get() ? + BugReportUtil::SendReport(profile_, + WideToUTF8(page_title_text_->GetText()), + problem_type_, + UTF16ToUTF8(page_url_text_->text()), + std::string(), + UTF16ToUTF8(description_text_->text()), + image_data, image_data_size, + screen_size_.width(), screen_size_.height()); #endif - reinterpret_cast<const char *>(&((*png_data_.get())[0])) : NULL, - png_data_->size(), screenshot_size_.width(), - screenshot_size_.height()); + } } return true; } @@ -417,15 +598,16 @@ bool BugReportView::Accept() { void BugReportView::LinkActivated(views::Link* source, int event_flags) { GURL url; - if (source == system_information_url_) { - url = GURL(l10n_util::GetStringUTF16(IDS_BUGREPORT_SYSTEM_INFORMATION_URL)); + if (source == system_information_url_control_) { + url = GURL(system_information_url_); } else { NOTREACHED() << "Unknown link source"; return; } Browser* browser = BrowserList::GetLastActive(); - browser->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); + if (browser) + browser->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); } #endif diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h index 1fa3e5d..8fd7bca 100644 --- a/chrome/browser/views/bug_report_view.h +++ b/chrome/browser/views/bug_report_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,11 @@ #include "views/view.h" #include "views/window/dialog_delegate.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/syslogs_library.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#endif + namespace views { class Checkbox; class Label; @@ -32,12 +37,13 @@ class BugReportComboBoxModel; // BugReportView draws the dialog that allows the user to report a // bug in rendering a particular page (note: this is not a crash // report, which are handled separately by Breakpad). It packages -// up the URL, a text description, and optionally a screenshot and/or -// the HTML page source, and submits them as an HTTP POST to the -// URL stored in the string resource IDS_BUGREPORT_POST_URL. +// up the URL, a text description, system information and optionally +// a screenshot; then it submits the info through https to the google +// feedback chrome end-point. // -// Note: The UI team hasn't defined yet how the bug report UI will look like. -// So now use dialog as a placeholder. +// Note: This UI is being used for the Chrome OS dogfood release only +// In the very next iteration, this will be replaced by a HTML +// based UI, which will be common for all platforms class BugReportView : public views::View, public views::DialogDelegate, public views::Combobox::Listener, @@ -46,16 +52,18 @@ class BugReportView : public views::View, #endif public views::Textfield::Controller { public: - explicit BugReportView(Profile* profile, TabContents* tab); + BugReportView(Profile* profile, TabContents* tab); virtual ~BugReportView(); - // NOTE: set_png_data takes ownership of the vector - void set_png_data(std::vector<unsigned char> *png_data) { - png_data_.reset(png_data); - }; - void set_screenshot_size(const gfx::Rect& screenshot_size) { - screenshot_size_ = screenshot_size; - }; + // NOTE: set_captured_image takes ownership of the vector + void set_captured_image(std::vector<unsigned char>* png_data) { + captured_image_.reset(png_data); + } + + void set_screen_size(const gfx::Rect& screen_size) { + screen_size_ = screen_size; + } + // Set all additional reporting controls to disabled // if phishing report void UpdateReportingControls(bool is_phishing_report); @@ -76,6 +84,21 @@ class BugReportView : public views::View, #if defined(OS_CHROMEOS) // Overridden from views::LinkController: virtual void LinkActivated(views::Link* source, int event_flags); + + // Disable the include last image radio control + void DisableLastImageRadio() { + include_last_screen_image_radio_->SetEnabled(false); + } + + // Disable the include system information checkbox + void DisableSystemInformationCheckbox() { + include_system_information_checkbox_->SetEnabled(false); + } + + // NOTE: set_last_image takes ownership of the vector + void set_last_image(std::vector<unsigned char>* png_data) { + last_image_.reset(png_data); + } #endif // Overridden from views::DialogDelegate: @@ -117,13 +140,18 @@ class BugReportView : public views::View, views::Textfield* description_text_; views::Checkbox* include_page_source_checkbox_; #if defined(OS_CHROMEOS) - views::RadioButton* include_last_screen_image_radio_; - views::ImageView* last_screenshot_iv_; + views::Label* user_email_label_; + views::Textfield* user_email_text_; views::RadioButton* include_new_screen_image_radio_; + views::RadioButton* include_last_screen_image_radio_; + views::RadioButton* include_no_screen_image_radio_; views::Checkbox* include_system_information_checkbox_; - views::Link* system_information_url_; + views::Link* system_information_url_control_; + + std::string system_information_url_; + scoped_ptr<chromeos::LogDictionaryType> sys_info_; + scoped_ptr< std::vector<unsigned char> > last_image_; #endif - // TODO: #else this once the BugReport function is fixed up views::Checkbox* include_page_image_checkbox_; @@ -132,8 +160,8 @@ class BugReportView : public views::View, Profile* profile_; std::wstring version_; - gfx::Rect screenshot_size_; - scoped_ptr< std::vector<unsigned char> > png_data_; + gfx::Rect screen_size_; + scoped_ptr< std::vector<unsigned char> > captured_image_; TabContents* tab_; |