OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/feedback/feedback_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 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
25 #include "chrome/common/metrics/metrics_log_manager.h" | 26 #include "chrome/common/metrics/metrics_log_manager.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
32 #include "grit/locale_settings.h" | 33 #include "grit/locale_settings.h" |
33 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
34 #include "net/base/load_flags.h" | 35 #include "net/base/load_flags.h" |
| 36 #include "net/http/http_request_headers.h" |
35 #include "net/url_request/url_fetcher.h" | 37 #include "net/url_request/url_fetcher.h" |
36 #include "net/url_request/url_fetcher_delegate.h" | 38 #include "net/url_request/url_fetcher_delegate.h" |
37 #include "net/url_request/url_request_status.h" | 39 #include "net/url_request/url_request_status.h" |
38 #include "third_party/icu/public/common/unicode/locid.h" | 40 #include "third_party/icu/public/common/unicode/locid.h" |
39 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
40 | 42 |
41 using content::WebContents; | 43 using content::WebContents; |
42 | 44 |
43 namespace chrome { | 45 namespace chrome { |
44 const char kAppLauncherCategoryTag[] = "AppLauncher"; | 46 const char kAppLauncherCategoryTag[] = "AppLauncher"; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 GetSwitchValueASCII(switches::kFeedbackServer)); | 195 GetSwitchValueASCII(switches::kFeedbackServer)); |
194 else | 196 else |
195 post_url = GURL(kFeedbackPostUrl); | 197 post_url = GURL(kFeedbackPostUrl); |
196 | 198 |
197 net::URLFetcher* fetcher = net::URLFetcher::Create( | 199 net::URLFetcher* fetcher = net::URLFetcher::Create( |
198 post_url, net::URLFetcher::POST, | 200 post_url, net::URLFetcher::POST, |
199 new FeedbackUtil::PostCleanup(profile, post_body, previous_delay)); | 201 new FeedbackUtil::PostCleanup(profile, post_body, previous_delay)); |
200 fetcher->SetRequestContext(profile->GetRequestContext()); | 202 fetcher->SetRequestContext(profile->GetRequestContext()); |
201 fetcher->SetLoadFlags( | 203 fetcher->SetLoadFlags( |
202 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); | 204 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); |
| 205 |
| 206 net::HttpRequestHeaders headers; |
| 207 chrome_variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( |
| 208 fetcher->GetOriginalURL(), profile->IsOffTheRecord(), false, &headers); |
| 209 fetcher->SetExtraRequestHeaders(headers.ToString()); |
| 210 |
203 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); | 211 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); |
204 fetcher->Start(); | 212 fetcher->Start(); |
205 } | 213 } |
206 | 214 |
207 | 215 |
208 // static | 216 // static |
209 void FeedbackUtil::AddFeedbackData( | 217 void FeedbackUtil::AddFeedbackData( |
210 userfeedback::ExtensionSubmit* feedback_data, | 218 userfeedback::ExtensionSubmit* feedback_data, |
211 const std::string& key, const std::string& value) { | 219 const std::string& key, const std::string& value) { |
212 // Don't bother with empty keys or values | 220 // Don't bother with empty keys or values |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 if (screenshot_size == NULL) | 417 if (screenshot_size == NULL) |
410 screenshot_size = new gfx::Rect(); | 418 screenshot_size = new gfx::Rect(); |
411 return *screenshot_size; | 419 return *screenshot_size; |
412 } | 420 } |
413 | 421 |
414 // static | 422 // static |
415 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { | 423 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
416 gfx::Rect& screen_size = GetScreenshotSize(); | 424 gfx::Rect& screen_size = GetScreenshotSize(); |
417 screen_size = rect; | 425 screen_size = rect; |
418 } | 426 } |
OLD | NEW |