Chromium Code Reviews| 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 their text, system logs that helps in " | |
|
msramek
2017/03/14 22:20:59
nit: s/their/text/the free-form text they entered/
Ramin Halavati
2017/03/15 06:08:01
Done.
| |
| 58 "diagnosis of the issue are sent to Google. This service uploads " | |
| 59 "the report to Google feedback server." | |
|
msramek
2017/03/14 22:20:59
nit: Feedback
Ramin Halavati
2017/03/15 06:08:01
Done.
| |
| 60 trigger: | |
| 61 "When user chooses to send a feedback to Google." | |
| 62 data: | |
| 63 "User entered message and useful debugging logs. The logs are " | |
|
msramek
2017/03/14 22:20:59
nit: User-entered ("User entered" reads as a subje
afakhry
2017/03/15 03:01:32
All sorts of logs, UI logs, chrome logs, kernel lo
Ramin Halavati
2017/03/15 06:08:01
Done.
msramek
2017/03/15 09:41:11
The reason why I'm asking is that I see two checkb
afakhry
2017/03/15 16:00:11
If the user unchecks the entry for "system informa
Ramin Halavati
2017/03/16 06:51:59
Acknowledged.
| |
| 64 "anonymized to remove any user-private data. The user can also " | |
| 65 "view the system information before sending, and choose to send " | |
| 66 "the feedback report without the logs, the screenshot, or even " | |
| 67 "his/her email address." | |
| 68 destination: GOOGLE_OWNED_SERVICE | |
| 69 } | |
| 70 policy { | |
| 71 cookies_allowed: false | |
| 72 setting: | |
| 73 "This feature cannot be disabled by settings and is only activated " | |
| 74 "by direct user request." | |
| 75 policy_exception_justification: "Not implemented." | |
| 76 })"); | |
| 50 // Note: FeedbackUploaderDelegate deletes itself and the fetcher. | 77 // Note: FeedbackUploaderDelegate deletes itself and the fetcher. |
| 51 net::URLFetcher* fetcher = | 78 net::URLFetcher* fetcher = |
| 52 net::URLFetcher::Create( | 79 net::URLFetcher::Create( |
| 53 post_url, net::URLFetcher::POST, | 80 post_url, net::URLFetcher::POST, |
| 54 new FeedbackUploaderDelegate( | 81 new FeedbackUploaderDelegate( |
| 55 data, base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, | 82 data, |
| 56 AsWeakPtr()), | 83 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, |
| 57 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr()))) | 84 AsWeakPtr()), |
| 85 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr())), | |
| 86 traffic_annotation) | |
| 58 .release(); | 87 .release(); |
| 59 data_use_measurement::DataUseUserData::AttachToFetcher( | 88 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 60 fetcher, data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER); | 89 fetcher, data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER); |
| 61 // Tell feedback server about the variation state of this install. | 90 // Tell feedback server about the variation state of this install. |
| 62 net::HttpRequestHeaders headers; | 91 net::HttpRequestHeaders headers; |
| 63 // Note: It's OK to pass |is_signed_in| false if it's unknown, as it does | 92 // 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. | 93 // not affect transmission of experiments coming from the variations server. |
| 65 bool is_signed_in = false; | 94 bool is_signed_in = false; |
| 66 variations::AppendVariationHeaders(fetcher->GetOriginalURL(), | 95 variations::AppendVariationHeaders(fetcher->GetOriginalURL(), |
| 67 context_->IsOffTheRecord(), false, | 96 context_->IsOffTheRecord(), false, |
| 68 is_signed_in, &headers); | 97 is_signed_in, &headers); |
| 69 fetcher->SetExtraRequestHeaders(headers.ToString()); | 98 fetcher->SetExtraRequestHeaders(headers.ToString()); |
| 70 | 99 |
| 71 fetcher->SetUploadData(kProtoBufMimeType, data); | 100 fetcher->SetUploadData(kProtoBufMimeType, data); |
| 72 fetcher->SetRequestContext( | 101 fetcher->SetRequestContext( |
| 73 content::BrowserContext::GetDefaultStoragePartition(context_)-> | 102 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 74 GetURLRequestContext()); | 103 GetURLRequestContext()); |
| 75 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 104 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 76 net::LOAD_DO_NOT_SEND_COOKIES); | 105 net::LOAD_DO_NOT_SEND_COOKIES); |
| 77 fetcher->Start(); | 106 fetcher->Start(); |
| 78 } | 107 } |
| 79 | 108 |
| 80 } // namespace feedback | 109 } // namespace feedback |
| OLD | NEW |