Home | History | Annotate | Download | only in browser
      1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_BUG_REPORT_UTIL_H_
      6 #define CHROME_BROWSER_BUG_REPORT_UTIL_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "chrome/browser/userfeedback/proto/common.pb.h"
     13 #include "chrome/browser/userfeedback/proto/extension.pb.h"
     14 #include "chrome/browser/userfeedback/proto/math.pb.h"
     15 #include "ui/gfx/rect.h"
     16 
     17 #if defined(OS_MACOSX)
     18 #include "base/sys_info.h"
     19 #elif defined(OS_WIN)
     20 #include "base/win/windows_version.h"
     21 #elif defined(OS_CHROMEOS)
     22 #include "chrome/browser/chromeos/cros/syslogs_library.h"
     23 #include "chrome/browser/chromeos/cros/cros_library.h"
     24 #endif
     25 
     26 class Profile;
     27 class TabContents;
     28 
     29 class BugReportUtil {
     30  public:
     31 
     32 #if defined(OS_MACOSX)
     33   enum BugType {
     34     PAGE_WONT_LOAD = 0,
     35     PAGE_LOOKS_ODD,
     36     PHISHING_PAGE,
     37     CANT_SIGN_IN,
     38     CHROME_MISBEHAVES,
     39     SOMETHING_MISSING,
     40     BROWSER_CRASH,
     41     OTHER_PROBLEM
     42   };
     43 #endif
     44 
     45 
     46   // SetOSVersion copies the maj.minor.build + servicePack_string
     47   // into a string. We currently have:
     48   //   base::win::GetVersion returns WinVersion, which is just
     49   //     an enum of 2000, XP, 2003, or VISTA. Not enough detail for
     50   //     bug reports.
     51   //   base::SysInfo::OperatingSystemVersion returns an std::string
     52   //     but doesn't include the build or service pack. That function
     53   //     is probably the right one to extend, but will require changing
     54   //     all the call sites or making it a wrapper around another util.
     55   static void SetOSVersion(std::string *os_version);
     56 
     57   // This sets the address of the feedback server to be used by SendReport
     58   static void SetFeedbackServer(const std::string& server);
     59 
     60   // Send the feedback report after the specified delay
     61   static void DispatchFeedback(Profile* profile, std::string* feedback_data,
     62                                int64 delay);
     63 
     64 
     65   // Generates bug report data.
     66   static void SendReport(Profile* profile,
     67       int problem_type,
     68       const std::string& page_url_text,
     69       const std::string& description,
     70       const char* png_data,
     71       int png_data_length,
     72       int png_width,
     73 #if defined(OS_CHROMEOS)
     74       int png_height,
     75       const std::string& user_email_text,
     76       const char* zipped_logs_data,
     77       int zipped_logs_length,
     78       const chromeos::LogDictionaryType* const sys_info);
     79 #else
     80       int png_height);
     81 #endif
     82 
     83   // Redirects the user to Google's phishing reporting page.
     84   static void ReportPhishing(TabContents* currentTab,
     85                              const std::string& phishing_url);
     86 
     87   class PostCleanup;
     88 
     89  private:
     90   // Add a key value pair to the feedback object
     91   static void AddFeedbackData(
     92       userfeedback::ExternalExtensionSubmit* feedback_data,
     93       const std::string& key, const std::string& value);
     94 
     95   // Send the feedback report
     96   static void SendFeedback(Profile* profile, std::string* feedback_data,
     97                            int64 previous_delay);
     98 
     99 #if defined(OS_CHROMEOS)
    100   static bool ValidFeedbackSize(const std::string& content);
    101 #endif
    102 
    103   static std::string feedback_server_;
    104 
    105   DISALLOW_IMPLICIT_CONSTRUCTORS(BugReportUtil);
    106 };
    107 
    108 #endif  // CHROME_BROWSER_BUG_REPORT_UTIL_H_
    109