Chromium Code Reviews| Index: chrome/browser/feedback/feedback_util.cc |
| diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/feedback/feedback_util.cc |
| similarity index 87% |
| rename from chrome/browser/bug_report_util.cc |
| rename to chrome/browser/feedback/feedback_util.cc |
| index e36991ca6f4bd3be5aa1a2d6577321daddbc42c6..ff2c564e2d5d0c8f442529c4cd6e507a418b46a7 100644 |
| --- a/chrome/browser/bug_report_util.cc |
| +++ b/chrome/browser/feedback/feedback_util.cc |
| @@ -2,10 +2,11 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/bug_report_util.h" |
| +#include "chrome/browser/feedback/feedback_util.h" |
| #include <sstream> |
| #include <string> |
| +#include <vector> |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| @@ -39,13 +40,13 @@ |
| namespace { |
| -const int kBugReportVersion = 1; |
| +const int kFeedbackVersion = 1; |
| const char kReportPhishingUrl[] = |
| "http://www.google.com/safebrowsing/report_phish/"; |
| // URL to post bug reports to. |
| -static char const kBugReportPostUrl[] = |
| +static char const kFeedbackPostUrl[] = |
| "https://www.google.com/tools/feedback/chrome/__submit"; |
| static char const kProtBufMimeType[] = "application/x-protobuf"; |
| @@ -55,8 +56,6 @@ static char const kPngMimeType[] = "image/png"; |
| static char const kChromeVersionTag[] = "CHROME VERSION"; |
| static char const kOsVersionTag[] = "OS VERSION"; |
| -static char const kNotificationId[] = "feedback.chromeos"; |
| - |
| static int const kHttpPostSuccessNoContent = 204; |
| static int const kHttpPostFailNoConnection = -1; |
| static int const kHttpPostFailClientError = 400; |
| @@ -73,16 +72,16 @@ const size_t kMaxLineCount = 40; |
| const size_t kMaxSystemLogLength = 4 * 1024; |
| #endif |
| -const int64 kInitialRetryDelay = 900000; // 15 minutes |
| +const int64 kInitialRetryDelay = 900000; // 15 minutes |
| const int64 kRetryDelayIncreaseFactor = 2; |
| -const int64 kRetryDelayLimit = 14400000; // 4 hours |
| +const int64 kRetryDelayLimit = 14400000; // 4 hours |
| } // namespace |
| // Simple content::URLFetcherDelegate to clean up URLFetcher on completion. |
| -class BugReportUtil::PostCleanup : public content::URLFetcherDelegate { |
| +class FeedbackUtil::PostCleanup : public content::URLFetcherDelegate { |
| public: |
| PostCleanup(Profile* profile, std::string* post_body, |
| int64 previous_delay) : profile_(profile), |
| @@ -105,7 +104,7 @@ class BugReportUtil::PostCleanup : public content::URLFetcherDelegate { |
| // Don't use the data parameter, instead use the pointer we pass into every |
| // post cleanup object - that pointer will be deleted and deleted only on a |
| // successful post to the feedback server. |
| -void BugReportUtil::PostCleanup::OnURLFetchComplete( |
| +void FeedbackUtil::PostCleanup::OnURLFetchComplete( |
| const content::URLFetcher* source) { |
| std::stringstream error_stream; |
| int response_code = source->GetResponseCode(); |
| @@ -122,7 +121,7 @@ void BugReportUtil::PostCleanup::OnURLFetchComplete( |
| } else { |
| previous_delay_ = kInitialRetryDelay; |
| } |
| - BugReportUtil::DispatchFeedback(profile_, post_body_, previous_delay_); |
| + FeedbackUtil::DispatchFeedback(profile_, post_body_, previous_delay_); |
| // Process the error for debug output |
| if (response_code == kHttpPostFailNoConnection) { |
| @@ -147,7 +146,7 @@ void BugReportUtil::PostCleanup::OnURLFetchComplete( |
| } |
| // static |
| -void BugReportUtil::SetOSVersion(std::string* os_version) { |
| +void FeedbackUtil::SetOSVersion(std::string* os_version) { |
| #if defined(OS_WIN) |
| base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); |
| base::win::OSInfo::VersionNumber version_number = os_info->version_number(); |
| @@ -166,17 +165,17 @@ void BugReportUtil::SetOSVersion(std::string* os_version) { |
| } |
| // static |
| -void BugReportUtil::DispatchFeedback(Profile* profile, |
| +void FeedbackUtil::DispatchFeedback(Profile* profile, |
| std::string* post_body, |
| int64 delay) { |
| DCHECK(post_body); |
| MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind( |
| - &BugReportUtil::SendFeedback, profile, post_body, delay), delay); |
| + &FeedbackUtil::SendFeedback, profile, post_body, delay), delay); |
| } |
| // static |
| -void BugReportUtil::SendFeedback(Profile* profile, |
| +void FeedbackUtil::SendFeedback(Profile* profile, |
| std::string* post_body, |
| int64 previous_delay) { |
| DCHECK(post_body); |
| @@ -187,11 +186,11 @@ void BugReportUtil::SendFeedback(Profile* profile, |
| post_url = GURL(CommandLine::ForCurrentProcess()-> |
| GetSwitchValueASCII(switches::kFeedbackServer)); |
| else |
| - post_url = GURL(kBugReportPostUrl); |
| + post_url = GURL(kFeedbackPostUrl); |
| content::URLFetcher* fetcher = content::URLFetcher::Create( |
| post_url, content::URLFetcher::POST, |
| - new BugReportUtil::PostCleanup(profile, post_body, previous_delay)); |
| + new FeedbackUtil::PostCleanup(profile, post_body, previous_delay)); |
| fetcher->SetRequestContext(profile->GetRequestContext()); |
| fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); |
| @@ -200,11 +199,11 @@ void BugReportUtil::SendFeedback(Profile* profile, |
| // static |
| -void BugReportUtil::AddFeedbackData( |
| - userfeedback::ExternalExtensionSubmit* feedback_data, |
| +void FeedbackUtil::AddFeedbackData( |
| + userfeedback::ExtensionSubmit* feedback_data, |
| const std::string& key, const std::string& value) { |
| // Don't bother with empty keys or values |
| - if (key=="" || value == "") return; |
| + if (key == "" || value == "") return; |
| // Create log_value object and add it to the web_data object |
| userfeedback::ProductSpecificData log_value; |
| log_value.set_key(key); |
| @@ -214,7 +213,7 @@ void BugReportUtil::AddFeedbackData( |
| } |
| #if defined(OS_CHROMEOS) |
| -bool BugReportUtil::ValidFeedbackSize(const std::string& content) { |
| +bool FeedbackUtil::ValidFeedbackSize(const std::string& content) { |
| if (content.length() > kMaxSystemLogLength) |
| return false; |
| size_t line_count = 0; |
| @@ -231,9 +230,9 @@ bool BugReportUtil::ValidFeedbackSize(const std::string& content) { |
| #endif |
| // static |
| -void BugReportUtil::SendReport( |
| +void FeedbackUtil::SendReport( |
| Profile* profile |
| - , int problem_type |
| + , const std::string& category_tag |
| , const std::string& page_url_text |
| , const std::string& description |
| , ScreenshotDataPtr image_data_ptr |
| @@ -247,7 +246,7 @@ void BugReportUtil::SendReport( |
| #endif |
| ) { |
| // Create google feedback protocol buffer objects |
| - userfeedback::ExternalExtensionSubmit feedback_data; |
| + userfeedback::ExtensionSubmit feedback_data; |
| // type id set to 0, unused field but needs to be initialized to 0 |
| feedback_data.set_type_id(0); |
| @@ -285,10 +284,14 @@ void BugReportUtil::SendReport( |
| chrome_version); |
| } |
| + // We don't need the OS version for ChromeOS since we get it in |
| + // CHROMEOS_RELEASE_VERSION from /etc/lsb-release |
| +#if !defined(OS_CHROMEOS) |
| // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). |
| std::string os_version = ""; |
| SetOSVersion(&os_version); |
| AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); |
| +#endif |
| // Include the page image if we have one. |
| if (image_data_ptr.get() && image_data_ptr->size()) { |
| @@ -331,21 +334,23 @@ void BugReportUtil::SendReport( |
| } |
| #endif |
| + // Set our category tag |
| +// feedback_data.set_category_tag(category_tag); |
|
xiyuan
2011/12/22 02:18:23
Is this line needed?
rkc
2011/12/22 22:41:46
Oops. Yes, just need to check to see if a category
|
| + |
| // Set our Chrome specific data |
| userfeedback::ChromeData chrome_data; |
| -#if defined(OS_CHROMEOS) |
| chrome_data.set_chrome_platform( |
| +#if defined(OS_CHROMEOS) |
| userfeedback::ChromeData_ChromePlatform_CHROME_OS); |
| userfeedback::ChromeOsData chrome_os_data; |
| chrome_os_data.set_category( |
| - (userfeedback::ChromeOsData_ChromeOsCategory) problem_type); |
| + userfeedback::ChromeOsData_ChromeOsCategory_OTHER); |
| *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; |
| #else |
| - chrome_data.set_chrome_platform( |
| userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); |
| userfeedback::ChromeBrowserData chrome_browser_data; |
| chrome_browser_data.set_category( |
| - (userfeedback::ChromeBrowserData_ChromeBrowserCategory) problem_type); |
| + userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER); |
| *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; |
| #endif |
| @@ -361,7 +366,7 @@ void BugReportUtil::SendReport( |
| #if defined(ENABLE_SAFE_BROWSING) |
| // static |
| -void BugReportUtil::ReportPhishing(TabContents* currentTab, |
| +void FeedbackUtil::ReportPhishing(TabContents* currentTab, |
| const std::string& phishing_url) { |
| currentTab->controller().LoadURL( |
| safe_browsing_util::GeneratePhishingReportUrl( |
| @@ -377,27 +382,27 @@ static std::vector<unsigned char>* screenshot_png = NULL; |
| static gfx::Rect* screenshot_size = NULL; |
| // static |
| -std::vector<unsigned char>* BugReportUtil::GetScreenshotPng() { |
| +std::vector<unsigned char>* FeedbackUtil::GetScreenshotPng() { |
| if (screenshot_png == NULL) |
| screenshot_png = new std::vector<unsigned char>; |
| return screenshot_png; |
| } |
| // static |
| -void BugReportUtil::ClearScreenshotPng() { |
| +void FeedbackUtil::ClearScreenshotPng() { |
| if (screenshot_png) |
| screenshot_png->clear(); |
| } |
| // static |
| -gfx::Rect& BugReportUtil::GetScreenshotSize() { |
| +gfx::Rect& FeedbackUtil::GetScreenshotSize() { |
| if (screenshot_size == NULL) |
| screenshot_size = new gfx::Rect(); |
| return *screenshot_size; |
| } |
| // static |
| -void BugReportUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| +void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| gfx::Rect& screen_size = GetScreenshotSize(); |
| screen_size = rect; |
| } |