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

Side by Side Diff: chrome/browser/feedback/feedback_util.cc

Issue 9006003: Refactor and fix feedback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra include. Created 9 years 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/bug_report_util.h" 5 #include "chrome/browser/feedback/feedback_util.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/file_util.h" 13 #include "base/file_util.h"
13 #include "base/file_version_info.h" 14 #include "base/file_version_info.h"
14 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
(...skipping 13 matching lines...) Expand all
32 #include "net/url_request/url_request_status.h" 33 #include "net/url_request/url_request_status.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "unicode/locid.h" 35 #include "unicode/locid.h"
35 36
36 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/notifications/system_notification.h" 38 #include "chrome/browser/chromeos/notifications/system_notification.h"
38 #endif 39 #endif
39 40
40 namespace { 41 namespace {
41 42
42 const int kBugReportVersion = 1; 43 const int kFeedbackVersion = 1;
43 44
44 const char kReportPhishingUrl[] = 45 const char kReportPhishingUrl[] =
45 "http://www.google.com/safebrowsing/report_phish/"; 46 "http://www.google.com/safebrowsing/report_phish/";
46 47
47 // URL to post bug reports to. 48 // URL to post bug reports to.
48 static char const kBugReportPostUrl[] = 49 static char const kFeedbackPostUrl[] =
49 "https://www.google.com/tools/feedback/chrome/__submit"; 50 "https://www.google.com/tools/feedback/chrome/__submit";
50 51
51 static char const kProtBufMimeType[] = "application/x-protobuf"; 52 static char const kProtBufMimeType[] = "application/x-protobuf";
52 static char const kPngMimeType[] = "image/png"; 53 static char const kPngMimeType[] = "image/png";
53 54
54 // Tags we use in product specific data 55 // Tags we use in product specific data
55 static char const kChromeVersionTag[] = "CHROME VERSION"; 56 static char const kChromeVersionTag[] = "CHROME VERSION";
56 static char const kOsVersionTag[] = "OS VERSION"; 57 static char const kOsVersionTag[] = "OS VERSION";
57 58
58 static char const kNotificationId[] = "feedback.chromeos";
59
60 static int const kHttpPostSuccessNoContent = 204; 59 static int const kHttpPostSuccessNoContent = 204;
61 static int const kHttpPostFailNoConnection = -1; 60 static int const kHttpPostFailNoConnection = -1;
62 static int const kHttpPostFailClientError = 400; 61 static int const kHttpPostFailClientError = 400;
63 static int const kHttpPostFailServerError = 500; 62 static int const kHttpPostFailServerError = 500;
64 63
65 #if defined(OS_CHROMEOS) 64 #if defined(OS_CHROMEOS)
66 static char const kBZip2MimeType[] = "application/x-bzip2"; 65 static char const kBZip2MimeType[] = "application/x-bzip2";
67 static char const kLogsAttachmentName[] = "system_logs.bz2"; 66 static char const kLogsAttachmentName[] = "system_logs.bz2";
68 // Maximum number of lines in system info log chunk to be still included 67 // Maximum number of lines in system info log chunk to be still included
69 // in product specific data. 68 // in product specific data.
70 const size_t kMaxLineCount = 40; 69 const size_t kMaxLineCount = 40;
71 // Maximum number of bytes in system info log chunk to be still included 70 // Maximum number of bytes in system info log chunk to be still included
72 // in product specific data. 71 // in product specific data.
73 const size_t kMaxSystemLogLength = 4 * 1024; 72 const size_t kMaxSystemLogLength = 4 * 1024;
74 #endif 73 #endif
75 74
76 const int64 kInitialRetryDelay = 900000; // 15 minutes 75 const int64 kInitialRetryDelay = 900000; // 15 minutes
77 const int64 kRetryDelayIncreaseFactor = 2; 76 const int64 kRetryDelayIncreaseFactor = 2;
78 const int64 kRetryDelayLimit = 14400000; // 4 hours 77 const int64 kRetryDelayLimit = 14400000; // 4 hours
79 78
80 79
81 } // namespace 80 } // namespace
82 81
83 82
84 // Simple content::URLFetcherDelegate to clean up URLFetcher on completion. 83 // Simple content::URLFetcherDelegate to clean up URLFetcher on completion.
85 class BugReportUtil::PostCleanup : public content::URLFetcherDelegate { 84 class FeedbackUtil::PostCleanup : public content::URLFetcherDelegate {
86 public: 85 public:
87 PostCleanup(Profile* profile, std::string* post_body, 86 PostCleanup(Profile* profile, std::string* post_body,
88 int64 previous_delay) : profile_(profile), 87 int64 previous_delay) : profile_(profile),
89 post_body_(post_body), 88 post_body_(post_body),
90 previous_delay_(previous_delay) { } 89 previous_delay_(previous_delay) { }
91 // Overridden from content::URLFetcherDelegate. 90 // Overridden from content::URLFetcherDelegate.
92 virtual void OnURLFetchComplete(const content::URLFetcher* source); 91 virtual void OnURLFetchComplete(const content::URLFetcher* source);
93 92
94 protected: 93 protected:
95 virtual ~PostCleanup() {} 94 virtual ~PostCleanup() {}
96 95
97 private: 96 private:
98 Profile* profile_; 97 Profile* profile_;
99 std::string* post_body_; 98 std::string* post_body_;
100 int64 previous_delay_; 99 int64 previous_delay_;
101 100
102 DISALLOW_COPY_AND_ASSIGN(PostCleanup); 101 DISALLOW_COPY_AND_ASSIGN(PostCleanup);
103 }; 102 };
104 103
105 // Don't use the data parameter, instead use the pointer we pass into every 104 // Don't use the data parameter, instead use the pointer we pass into every
106 // post cleanup object - that pointer will be deleted and deleted only on a 105 // post cleanup object - that pointer will be deleted and deleted only on a
107 // successful post to the feedback server. 106 // successful post to the feedback server.
108 void BugReportUtil::PostCleanup::OnURLFetchComplete( 107 void FeedbackUtil::PostCleanup::OnURLFetchComplete(
109 const content::URLFetcher* source) { 108 const content::URLFetcher* source) {
110 std::stringstream error_stream; 109 std::stringstream error_stream;
111 int response_code = source->GetResponseCode(); 110 int response_code = source->GetResponseCode();
112 if (response_code == kHttpPostSuccessNoContent) { 111 if (response_code == kHttpPostSuccessNoContent) {
113 // We've sent our report, delete the report data 112 // We've sent our report, delete the report data
114 delete post_body_; 113 delete post_body_;
115 114
116 error_stream << "Success"; 115 error_stream << "Success";
117 } else { 116 } else {
118 // Uh oh, feedback failed, send it off to retry 117 // Uh oh, feedback failed, send it off to retry
119 if (previous_delay_) { 118 if (previous_delay_) {
120 if (previous_delay_ < kRetryDelayLimit) 119 if (previous_delay_ < kRetryDelayLimit)
121 previous_delay_ *= kRetryDelayIncreaseFactor; 120 previous_delay_ *= kRetryDelayIncreaseFactor;
122 } else { 121 } else {
123 previous_delay_ = kInitialRetryDelay; 122 previous_delay_ = kInitialRetryDelay;
124 } 123 }
125 BugReportUtil::DispatchFeedback(profile_, post_body_, previous_delay_); 124 FeedbackUtil::DispatchFeedback(profile_, post_body_, previous_delay_);
126 125
127 // Process the error for debug output 126 // Process the error for debug output
128 if (response_code == kHttpPostFailNoConnection) { 127 if (response_code == kHttpPostFailNoConnection) {
129 error_stream << "No connection to server."; 128 error_stream << "No connection to server.";
130 } else if ((response_code > kHttpPostFailClientError) && 129 } else if ((response_code > kHttpPostFailClientError) &&
131 (response_code < kHttpPostFailServerError)) { 130 (response_code < kHttpPostFailServerError)) {
132 error_stream << "Client error: HTTP response code " << response_code; 131 error_stream << "Client error: HTTP response code " << response_code;
133 } else if (response_code > kHttpPostFailServerError) { 132 } else if (response_code > kHttpPostFailServerError) {
134 error_stream << "Server error: HTTP response code " << response_code; 133 error_stream << "Server error: HTTP response code " << response_code;
135 } else { 134 } else {
136 error_stream << "Unknown error: HTTP response code " << response_code; 135 error_stream << "Unknown error: HTTP response code " << response_code;
137 } 136 }
138 } 137 }
139 138
140 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << 139 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" <<
141 source->GetURL() << ") status: " << error_stream.str(); 140 source->GetURL() << ") status: " << error_stream.str();
142 141
143 // Delete the URLFetcher. 142 // Delete the URLFetcher.
144 delete source; 143 delete source;
145 // And then delete ourselves. 144 // And then delete ourselves.
146 delete this; 145 delete this;
147 } 146 }
148 147
149 // static 148 // static
150 void BugReportUtil::SetOSVersion(std::string* os_version) { 149 void FeedbackUtil::SetOSVersion(std::string* os_version) {
151 #if defined(OS_WIN) 150 #if defined(OS_WIN)
152 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); 151 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
153 base::win::OSInfo::VersionNumber version_number = os_info->version_number(); 152 base::win::OSInfo::VersionNumber version_number = os_info->version_number();
154 *os_version = base::StringPrintf("%d.%d.%d", 153 *os_version = base::StringPrintf("%d.%d.%d",
155 version_number.major, 154 version_number.major,
156 version_number.minor, 155 version_number.minor,
157 version_number.build); 156 version_number.build);
158 int service_pack = os_info->service_pack().major; 157 int service_pack = os_info->service_pack().major;
159 if (service_pack > 0) 158 if (service_pack > 0)
160 os_version->append(base::StringPrintf("Service Pack %d", service_pack)); 159 os_version->append(base::StringPrintf("Service Pack %d", service_pack));
161 #elif defined(OS_MACOSX) 160 #elif defined(OS_MACOSX)
162 *os_version = base::SysInfo::OperatingSystemVersion(); 161 *os_version = base::SysInfo::OperatingSystemVersion();
163 #else 162 #else
164 *os_version = "unknown"; 163 *os_version = "unknown";
165 #endif 164 #endif
166 } 165 }
167 166
168 // static 167 // static
169 void BugReportUtil::DispatchFeedback(Profile* profile, 168 void FeedbackUtil::DispatchFeedback(Profile* profile,
170 std::string* post_body, 169 std::string* post_body,
171 int64 delay) { 170 int64 delay) {
172 DCHECK(post_body); 171 DCHECK(post_body);
173 172
174 MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind( 173 MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(
175 &BugReportUtil::SendFeedback, profile, post_body, delay), delay); 174 &FeedbackUtil::SendFeedback, profile, post_body, delay), delay);
176 } 175 }
177 176
178 // static 177 // static
179 void BugReportUtil::SendFeedback(Profile* profile, 178 void FeedbackUtil::SendFeedback(Profile* profile,
180 std::string* post_body, 179 std::string* post_body,
181 int64 previous_delay) { 180 int64 previous_delay) {
182 DCHECK(post_body); 181 DCHECK(post_body);
183 182
184 GURL post_url; 183 GURL post_url;
185 if (CommandLine::ForCurrentProcess()-> 184 if (CommandLine::ForCurrentProcess()->
186 HasSwitch(switches::kFeedbackServer)) 185 HasSwitch(switches::kFeedbackServer))
187 post_url = GURL(CommandLine::ForCurrentProcess()-> 186 post_url = GURL(CommandLine::ForCurrentProcess()->
188 GetSwitchValueASCII(switches::kFeedbackServer)); 187 GetSwitchValueASCII(switches::kFeedbackServer));
189 else 188 else
190 post_url = GURL(kBugReportPostUrl); 189 post_url = GURL(kFeedbackPostUrl);
191 190
192 content::URLFetcher* fetcher = content::URLFetcher::Create( 191 content::URLFetcher* fetcher = content::URLFetcher::Create(
193 post_url, content::URLFetcher::POST, 192 post_url, content::URLFetcher::POST,
194 new BugReportUtil::PostCleanup(profile, post_body, previous_delay)); 193 new FeedbackUtil::PostCleanup(profile, post_body, previous_delay));
195 fetcher->SetRequestContext(profile->GetRequestContext()); 194 fetcher->SetRequestContext(profile->GetRequestContext());
196 195
197 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); 196 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body);
198 fetcher->Start(); 197 fetcher->Start();
199 } 198 }
200 199
201 200
202 // static 201 // static
203 void BugReportUtil::AddFeedbackData( 202 void FeedbackUtil::AddFeedbackData(
204 userfeedback::ExternalExtensionSubmit* feedback_data, 203 userfeedback::ExtensionSubmit* feedback_data,
205 const std::string& key, const std::string& value) { 204 const std::string& key, const std::string& value) {
206 // Don't bother with empty keys or values 205 // Don't bother with empty keys or values
207 if (key=="" || value == "") return; 206 if (key == "" || value == "") return;
208 // Create log_value object and add it to the web_data object 207 // Create log_value object and add it to the web_data object
209 userfeedback::ProductSpecificData log_value; 208 userfeedback::ProductSpecificData log_value;
210 log_value.set_key(key); 209 log_value.set_key(key);
211 log_value.set_value(value); 210 log_value.set_value(value);
212 userfeedback::WebData* web_data = feedback_data->mutable_web_data(); 211 userfeedback::WebData* web_data = feedback_data->mutable_web_data();
213 *(web_data->add_product_specific_data()) = log_value; 212 *(web_data->add_product_specific_data()) = log_value;
214 } 213 }
215 214
216 #if defined(OS_CHROMEOS) 215 #if defined(OS_CHROMEOS)
217 bool BugReportUtil::ValidFeedbackSize(const std::string& content) { 216 bool FeedbackUtil::ValidFeedbackSize(const std::string& content) {
218 if (content.length() > kMaxSystemLogLength) 217 if (content.length() > kMaxSystemLogLength)
219 return false; 218 return false;
220 size_t line_count = 0; 219 size_t line_count = 0;
221 const char* text = content.c_str(); 220 const char* text = content.c_str();
222 for (size_t i = 0; i < content.length(); i++) { 221 for (size_t i = 0; i < content.length(); i++) {
223 if (*(text + i) == '\n') { 222 if (*(text + i) == '\n') {
224 line_count++; 223 line_count++;
225 if (line_count > kMaxLineCount) 224 if (line_count > kMaxLineCount)
226 return false; 225 return false;
227 } 226 }
228 } 227 }
229 return true; 228 return true;
230 } 229 }
231 #endif 230 #endif
232 231
233 // static 232 // static
234 void BugReportUtil::SendReport( 233 void FeedbackUtil::SendReport(
235 Profile* profile 234 Profile* profile
236 , int problem_type 235 , const std::string& category_tag
237 , const std::string& page_url_text 236 , const std::string& page_url_text
238 , const std::string& description 237 , const std::string& description
239 , ScreenshotDataPtr image_data_ptr 238 , ScreenshotDataPtr image_data_ptr
240 , int png_width 239 , int png_width
241 , int png_height 240 , int png_height
242 #if defined(OS_CHROMEOS) 241 #if defined(OS_CHROMEOS)
243 , const std::string& user_email_text 242 , const std::string& user_email_text
244 , const char* zipped_logs_data 243 , const char* zipped_logs_data
245 , int zipped_logs_length 244 , int zipped_logs_length
246 , const chromeos::system::LogDictionaryType* const sys_info 245 , const chromeos::system::LogDictionaryType* const sys_info
247 #endif 246 #endif
248 ) { 247 ) {
249 // Create google feedback protocol buffer objects 248 // Create google feedback protocol buffer objects
250 userfeedback::ExternalExtensionSubmit feedback_data; 249 userfeedback::ExtensionSubmit feedback_data;
251 // type id set to 0, unused field but needs to be initialized to 0 250 // type id set to 0, unused field but needs to be initialized to 0
252 feedback_data.set_type_id(0); 251 feedback_data.set_type_id(0);
253 252
254 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); 253 userfeedback::CommonData* common_data = feedback_data.mutable_common_data();
255 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); 254 userfeedback::WebData* web_data = feedback_data.mutable_web_data();
256 255
257 // Set GAIA id to 0. We're not using gaia id's for recording 256 // Set GAIA id to 0. We're not using gaia id's for recording
258 // use feedback - we're using the e-mail field, allows users to 257 // use feedback - we're using the e-mail field, allows users to
259 // submit feedback from incognito mode and specify any mail id 258 // submit feedback from incognito mode and specify any mail id
260 // they wish 259 // they wish
(...skipping 17 matching lines...) Expand all
278 // Add the Chrome version 277 // Add the Chrome version
279 chrome::VersionInfo version_info; 278 chrome::VersionInfo version_info;
280 if (version_info.is_valid()) { 279 if (version_info.is_valid()) {
281 std::string chrome_version = version_info.Name() + " - " + 280 std::string chrome_version = version_info.Name() + " - " +
282 version_info.Version() + 281 version_info.Version() +
283 " (" + version_info.LastChange() + ")"; 282 " (" + version_info.LastChange() + ")";
284 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), 283 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag),
285 chrome_version); 284 chrome_version);
286 } 285 }
287 286
287 // We don't need the OS version for ChromeOS since we get it in
288 // CHROMEOS_RELEASE_VERSION from /etc/lsb-release
289 #if !defined(OS_CHROMEOS)
288 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). 290 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2").
289 std::string os_version = ""; 291 std::string os_version = "";
290 SetOSVersion(&os_version); 292 SetOSVersion(&os_version);
291 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); 293 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version);
294 #endif
292 295
293 // Include the page image if we have one. 296 // Include the page image if we have one.
294 if (image_data_ptr.get() && image_data_ptr->size()) { 297 if (image_data_ptr.get() && image_data_ptr->size()) {
295 userfeedback::PostedScreenshot screenshot; 298 userfeedback::PostedScreenshot screenshot;
296 screenshot.set_mime_type(kPngMimeType); 299 screenshot.set_mime_type(kPngMimeType);
297 // Set the dimensions of the screenshot 300 // Set the dimensions of the screenshot
298 userfeedback::Dimensions dimensions; 301 userfeedback::Dimensions dimensions;
299 dimensions.set_width(static_cast<float>(png_width)); 302 dimensions.set_width(static_cast<float>(png_width));
300 dimensions.set_height(static_cast<float>(png_height)); 303 dimensions.set_height(static_cast<float>(png_height));
301 *(screenshot.mutable_dimensions()) = dimensions; 304 *(screenshot.mutable_dimensions()) = dimensions;
(...skipping 22 matching lines...) Expand all
324 switches::kCompressSystemFeedback)) { 327 switches::kCompressSystemFeedback)) {
325 userfeedback::ProductSpecificBinaryData attachment; 328 userfeedback::ProductSpecificBinaryData attachment;
326 attachment.set_mime_type(kBZip2MimeType); 329 attachment.set_mime_type(kBZip2MimeType);
327 attachment.set_name(kLogsAttachmentName); 330 attachment.set_name(kLogsAttachmentName);
328 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); 331 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length));
329 *(feedback_data.add_product_specific_binary_data()) = attachment; 332 *(feedback_data.add_product_specific_binary_data()) = attachment;
330 } 333 }
331 } 334 }
332 #endif 335 #endif
333 336
337 // Set our category tag
338 // 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
339
334 // Set our Chrome specific data 340 // Set our Chrome specific data
335 userfeedback::ChromeData chrome_data; 341 userfeedback::ChromeData chrome_data;
342 chrome_data.set_chrome_platform(
336 #if defined(OS_CHROMEOS) 343 #if defined(OS_CHROMEOS)
337 chrome_data.set_chrome_platform(
338 userfeedback::ChromeData_ChromePlatform_CHROME_OS); 344 userfeedback::ChromeData_ChromePlatform_CHROME_OS);
339 userfeedback::ChromeOsData chrome_os_data; 345 userfeedback::ChromeOsData chrome_os_data;
340 chrome_os_data.set_category( 346 chrome_os_data.set_category(
341 (userfeedback::ChromeOsData_ChromeOsCategory) problem_type); 347 userfeedback::ChromeOsData_ChromeOsCategory_OTHER);
342 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; 348 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data;
343 #else 349 #else
344 chrome_data.set_chrome_platform(
345 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); 350 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER);
346 userfeedback::ChromeBrowserData chrome_browser_data; 351 userfeedback::ChromeBrowserData chrome_browser_data;
347 chrome_browser_data.set_category( 352 chrome_browser_data.set_category(
348 (userfeedback::ChromeBrowserData_ChromeBrowserCategory) problem_type); 353 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER);
349 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; 354 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data;
350 #endif 355 #endif
351 356
352 *(feedback_data.mutable_chrome_data()) = chrome_data; 357 *(feedback_data.mutable_chrome_data()) = chrome_data;
353 358
354 // Serialize our report to a string pointer we can pass around 359 // Serialize our report to a string pointer we can pass around
355 std::string* post_body = new std::string; 360 std::string* post_body = new std::string;
356 feedback_data.SerializeToString(post_body); 361 feedback_data.SerializeToString(post_body);
357 362
358 // We have the body of our POST, so send it off to the server with 0 delay 363 // We have the body of our POST, so send it off to the server with 0 delay
359 DispatchFeedback(profile, post_body, 0); 364 DispatchFeedback(profile, post_body, 0);
360 } 365 }
361 366
362 #if defined(ENABLE_SAFE_BROWSING) 367 #if defined(ENABLE_SAFE_BROWSING)
363 // static 368 // static
364 void BugReportUtil::ReportPhishing(TabContents* currentTab, 369 void FeedbackUtil::ReportPhishing(TabContents* currentTab,
365 const std::string& phishing_url) { 370 const std::string& phishing_url) {
366 currentTab->controller().LoadURL( 371 currentTab->controller().LoadURL(
367 safe_browsing_util::GeneratePhishingReportUrl( 372 safe_browsing_util::GeneratePhishingReportUrl(
368 kReportPhishingUrl, phishing_url, 373 kReportPhishingUrl, phishing_url,
369 false /* not client-side detection */), 374 false /* not client-side detection */),
370 content::Referrer(), 375 content::Referrer(),
371 content::PAGE_TRANSITION_LINK, 376 content::PAGE_TRANSITION_LINK,
372 std::string()); 377 std::string());
373 } 378 }
374 #endif 379 #endif
375 380
376 static std::vector<unsigned char>* screenshot_png = NULL; 381 static std::vector<unsigned char>* screenshot_png = NULL;
377 static gfx::Rect* screenshot_size = NULL; 382 static gfx::Rect* screenshot_size = NULL;
378 383
379 // static 384 // static
380 std::vector<unsigned char>* BugReportUtil::GetScreenshotPng() { 385 std::vector<unsigned char>* FeedbackUtil::GetScreenshotPng() {
381 if (screenshot_png == NULL) 386 if (screenshot_png == NULL)
382 screenshot_png = new std::vector<unsigned char>; 387 screenshot_png = new std::vector<unsigned char>;
383 return screenshot_png; 388 return screenshot_png;
384 } 389 }
385 390
386 // static 391 // static
387 void BugReportUtil::ClearScreenshotPng() { 392 void FeedbackUtil::ClearScreenshotPng() {
388 if (screenshot_png) 393 if (screenshot_png)
389 screenshot_png->clear(); 394 screenshot_png->clear();
390 } 395 }
391 396
392 // static 397 // static
393 gfx::Rect& BugReportUtil::GetScreenshotSize() { 398 gfx::Rect& FeedbackUtil::GetScreenshotSize() {
394 if (screenshot_size == NULL) 399 if (screenshot_size == NULL)
395 screenshot_size = new gfx::Rect(); 400 screenshot_size = new gfx::Rect();
396 return *screenshot_size; 401 return *screenshot_size;
397 } 402 }
398 403
399 // static 404 // static
400 void BugReportUtil::SetScreenshotSize(const gfx::Rect& rect) { 405 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) {
401 gfx::Rect& screen_size = GetScreenshotSize(); 406 gfx::Rect& screen_size = GetScreenshotSize();
402 screen_size = rect; 407 screen_size = rect;
403 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698