| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/feedback/feedback_uploader_chrome.h" | 5 #include "components/feedback/feedback_uploader_chrome.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" | 14 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "components/feedback/feedback_report.h" | 15 #include "components/feedback/feedback_report.h" |
| 16 #include "components/feedback/feedback_switches.h" | 16 #include "components/feedback/feedback_switches.h" |
| 17 #include "components/feedback/feedback_uploader_delegate.h" | 17 #include "components/feedback/feedback_uploader_delegate.h" |
| 18 #include "components/variations/net/variations_http_headers.h" | 18 #include "components/variations/net/variations_http_headers.h" |
| 19 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/storage_partition.h" | 21 #include "content/public/browser/storage_partition.h" |
| 22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
| 23 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 using content::BrowserThread; | 27 using content::BrowserThread; |
| 27 | 28 |
| 28 namespace feedback { | 29 namespace feedback { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const char kProtoBufMimeType[] = "application/x-protobuf"; | 32 const char kProtoBufMimeType[] = "application/x-protobuf"; |
| 32 | 33 |
| 33 } // namespace | 34 } // namespace |
| 34 | 35 |
| 35 FeedbackUploaderChrome::FeedbackUploaderChrome( | 36 FeedbackUploaderChrome::FeedbackUploaderChrome( |
| 36 content::BrowserContext* context) | 37 content::BrowserContext* context) |
| 37 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), | 38 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), |
| 38 BrowserThread::GetBlockingPool()), | 39 BrowserThread::GetBlockingPool()), |
| 39 context_(context) { | 40 context_(context) { |
| 40 CHECK(context_); | 41 CHECK(context_); |
| 41 const base::CommandLine& command_line = | 42 const base::CommandLine& command_line = |
| 42 *base::CommandLine::ForCurrentProcess(); | 43 *base::CommandLine::ForCurrentProcess(); |
| 43 if (command_line.HasSwitch(switches::kFeedbackServer)) | 44 if (command_line.HasSwitch(switches::kFeedbackServer)) |
| 44 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); | 45 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { | 48 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { |
| 48 GURL post_url(url_); | 49 GURL post_url(url_); |
| 49 | 50 |
| 51 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 52 net::DefineNetworkTrafficAnnotation("chrome_feedback_report_app", R"( |
| 53 semantics { |
| 54 sender: "Chrome Feedback Report App" |
| 55 description: |
| 56 "Users can press Alt+Shift+i to report a bug or a feedback in " |
| 57 "general. Along with the free-form text they entered, system logs " |
| 58 "that helps in diagnosis of the issue are sent to Google. This " |
| 59 "service uploads the report to Google Feedback server." |
| 60 trigger: |
| 61 "When user chooses to send a feedback to Google." |
| 62 data: |
| 63 "The free-form text that user has entered and useful debugging " |
| 64 "logs (UI logs, Chrome logs, kernel logs, auto update engine logs, " |
| 65 "ARC++ logs, etc.). The logs are anonymized to remove any " |
| 66 "user-private data. The user can view the system information " |
| 67 "before sending, and choose to send the feedback report without " |
| 68 "system information and the logs (unchecking 'Send system " |
| 69 "information' prevents sending logs as well), the screenshot, or " |
| 70 "even his/her email address." |
| 71 destination: GOOGLE_OWNED_SERVICE |
| 72 } |
| 73 policy { |
| 74 cookies_allowed: false |
| 75 setting: |
| 76 "This feature cannot be disabled by settings and is only activated " |
| 77 "by direct user request." |
| 78 policy_exception_justification: "Not implemented." |
| 79 })"); |
| 50 // Note: FeedbackUploaderDelegate deletes itself and the fetcher. | 80 // Note: FeedbackUploaderDelegate deletes itself and the fetcher. |
| 51 net::URLFetcher* fetcher = | 81 net::URLFetcher* fetcher = |
| 52 net::URLFetcher::Create( | 82 net::URLFetcher::Create( |
| 53 post_url, net::URLFetcher::POST, | 83 post_url, net::URLFetcher::POST, |
| 54 new FeedbackUploaderDelegate( | 84 new FeedbackUploaderDelegate( |
| 55 data, base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, | 85 data, |
| 56 AsWeakPtr()), | 86 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, |
| 57 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr()))) | 87 AsWeakPtr()), |
| 88 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr())), |
| 89 traffic_annotation) |
| 58 .release(); | 90 .release(); |
| 59 data_use_measurement::DataUseUserData::AttachToFetcher( | 91 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 60 fetcher, data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER); | 92 fetcher, data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER); |
| 61 // Tell feedback server about the variation state of this install. | 93 // Tell feedback server about the variation state of this install. |
| 62 net::HttpRequestHeaders headers; | 94 net::HttpRequestHeaders headers; |
| 63 // Note: It's OK to pass |is_signed_in| false if it's unknown, as it does | 95 // Note: It's OK to pass |is_signed_in| false if it's unknown, as it does |
| 64 // not affect transmission of experiments coming from the variations server. | 96 // not affect transmission of experiments coming from the variations server. |
| 65 bool is_signed_in = false; | 97 bool is_signed_in = false; |
| 66 variations::AppendVariationHeaders(fetcher->GetOriginalURL(), | 98 variations::AppendVariationHeaders(fetcher->GetOriginalURL(), |
| 67 context_->IsOffTheRecord(), false, | 99 context_->IsOffTheRecord(), false, |
| 68 is_signed_in, &headers); | 100 is_signed_in, &headers); |
| 69 fetcher->SetExtraRequestHeaders(headers.ToString()); | 101 fetcher->SetExtraRequestHeaders(headers.ToString()); |
| 70 | 102 |
| 71 fetcher->SetUploadData(kProtoBufMimeType, data); | 103 fetcher->SetUploadData(kProtoBufMimeType, data); |
| 72 fetcher->SetRequestContext( | 104 fetcher->SetRequestContext( |
| 73 content::BrowserContext::GetDefaultStoragePartition(context_)-> | 105 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 74 GetURLRequestContext()); | 106 GetURLRequestContext()); |
| 75 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 107 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 76 net::LOAD_DO_NOT_SEND_COOKIES); | 108 net::LOAD_DO_NOT_SEND_COOKIES); |
| 77 fetcher->Start(); | 109 fetcher->Start(); |
| 78 } | 110 } |
| 79 | 111 |
| 80 } // namespace feedback | 112 } // namespace feedback |
| OLD | NEW |