- Added search icon and search clear button in 1x and 2x. Screenshot: http://i.imgur...
[chromium-blink-merge.git] / chrome / browser / feedback / feedback_util.h
blob7849186c01a469fae2d366d8c0dbdb5cebd459ee
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_UTIL_H_
6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_UTIL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "chrome/browser/feedback/feedback_data.h"
13 #include "chrome/browser/feedback/proto/common.pb.h"
14 #include "chrome/browser/feedback/proto/dom.pb.h"
15 #include "chrome/browser/feedback/proto/extension.pb.h"
16 #include "chrome/browser/feedback/proto/math.pb.h"
17 #include "chrome/browser/ui/webui/screenshot_source.h"
18 #include "ui/gfx/rect.h"
20 #if defined(OS_MACOSX)
21 #include "base/sys_info.h"
22 #elif defined(OS_WIN)
23 #include "base/win/windows_version.h"
24 #endif
26 class Profile;
28 namespace content {
29 class WebContents;
32 namespace chrome {
33 extern const char kAppLauncherCategoryTag[];
34 } // namespace chrome
36 class FeedbackUtil {
37 public:
39 #if defined(OS_MACOSX)
40 enum BugType {
41 PAGE_WONT_LOAD = 0,
42 PAGE_LOOKS_ODD,
43 PHISHING_PAGE,
44 CANT_SIGN_IN,
45 CHROME_MISBEHAVES,
46 SOMETHING_MISSING,
47 BROWSER_CRASH,
48 OTHER_PROBLEM
50 #endif
53 // SetOSVersion copies the maj.minor.build + servicePack_string
54 // into a string. We currently have:
55 // base::win::GetVersion returns WinVersion, which is just
56 // an enum of 2000, XP, 2003, or VISTA. Not enough detail for
57 // bug reports.
58 // base::SysInfo::OperatingSystemVersion returns an std::string
59 // but doesn't include the build or service pack. That function
60 // is probably the right one to extend, but will require changing
61 // all the call sites or making it a wrapper around another util.
62 static void SetOSVersion(std::string *os_version);
64 // Send the feedback report after the specified delay
65 static void DispatchFeedback(Profile* profile,
66 std::string* feedback_data,
67 int64 delay);
69 // Generates bug report data.
70 static void SendReport(scoped_refptr<FeedbackData> data);
71 // Redirects the user to Google's phishing reporting page.
72 static void ReportPhishing(content::WebContents* current_tab,
73 const std::string& phishing_url);
74 // Maintains a single vector of bytes to store the last screenshot taken.
75 static std::vector<unsigned char>* GetScreenshotPng();
76 static void ClearScreenshotPng();
77 static void SetScreenshotSize(const gfx::Rect& rect);
78 static gfx::Rect& GetScreenshotSize();
79 static bool ZipString(const std::string& logs, std::string* compressed_logs);
81 class PostCleanup;
83 private:
84 // Add a key value pair to the feedback object
85 static void AddFeedbackData(
86 userfeedback::ExtensionSubmit* feedback_data,
87 const std::string& key, const std::string& value);
89 // Send the feedback report
90 static void SendFeedback(Profile* profile,
91 std::string* feedback_data,
92 int64 previous_delay);
94 #if defined(OS_CHROMEOS)
95 static bool ValidFeedbackSize(const std::string& content);
96 #endif
98 DISALLOW_IMPLICIT_CONSTRUCTORS(FeedbackUtil);
101 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_UTIL_H_