Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/extensions/api/dial/device_description_fetcher.h" | 5 #include "chrome/browser/extensions/api/dial/device_description_fetcher.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/api/dial/dial_device_data.h" | 9 #include "chrome/browser/extensions/api/dial/dial_device_data.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
| 14 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
| 15 #include "net/http/http_util.h" | 15 #include "net/http/http_util.h" |
| 16 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 16 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 18 | 19 |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 20 | 21 |
| 21 constexpr char kApplicationUrlHeaderName[] = "Application-URL"; | 22 constexpr char kApplicationUrlHeaderName[] = "Application-URL"; |
| 22 constexpr int kMaxRetries = 3; | 23 constexpr int kMaxRetries = 3; |
| 23 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb | 24 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb |
| 24 // should be more than sufficient. | 25 // should be more than sufficient. |
| 25 constexpr int kMaxDescriptionSizeBytes = 262144; | 26 constexpr int kMaxDescriptionSizeBytes = 262144; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 42 } | 43 } |
| 43 | 44 |
| 44 DeviceDescriptionFetcher::~DeviceDescriptionFetcher() { | 45 DeviceDescriptionFetcher::~DeviceDescriptionFetcher() { |
| 45 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void DeviceDescriptionFetcher::Start() { | 49 void DeviceDescriptionFetcher::Start() { |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 50 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 DCHECK(!fetcher_); | 51 DCHECK(!fetcher_); |
| 51 | 52 |
| 53 net::NetworkTrafficAnnotationTag traffic_annotation = | |
| 54 net::DefineNetworkTrafficAnnotation("...", R"( | |
|
imcheng
2017/03/13 19:59:42
dial_get_device_description
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 55 semantics { | |
| 56 sender: "..." | |
|
imcheng
2017/03/13 19:59:42
dial
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 57 description: "..." | |
|
imcheng
2017/03/13 19:59:42
Chromium sends a request to a device (such as a sm
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 58 trigger: "..." | |
|
imcheng
2017/03/13 19:59:42
A new or updated device has been discovered via DI
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 59 data: "..." | |
|
imcheng
2017/03/13 19:59:42
A HTTP GET request.
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 60 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
imcheng
2017/03/13 19:59:42
I suppose this should be WEBSITE as the destinatio
Ramin Halavati
2017/03/13 21:44:30
I think it's OTHER, as it is not a website that us
| |
| 61 } | |
| 62 policy { | |
| 63 cookies_allowed: false/true | |
|
imcheng
2017/03/13 19:59:42
false
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 64 cookies_store: "..." | |
| 65 setting: "..." | |
|
imcheng
2017/03/13 19:59:42
This (and the Media Router) can be disabled via th
Ramin Halavati
2017/03/13 21:44:30
So it cannot be disabled by settings?
imcheng
2017/03/14 22:48:19
You can disable it via the media-router flag but n
Ramin Halavati
2017/03/15 06:37:37
Thank you.
| |
| 66 chrome_policy { | |
| 67 [POLICY_NAME] { | |
|
imcheng
2017/03/13 19:59:42
EnableMediaRouter
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 68 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
|
imcheng
2017/03/13 19:59:42
MANDATORY
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 69 [POLICY_NAME]: ... //(value to disable it) | |
|
imcheng
2017/03/13 19:59:42
false
Ramin Halavati
2017/03/13 21:44:30
Done.
| |
| 70 } | |
| 71 } | |
| 72 policy_exception_justification: "..." | |
| 73 })"); | |
| 52 // DIAL returns device descriptions via GET request. | 74 // DIAL returns device descriptions via GET request. |
| 53 fetcher_ = | 75 fetcher_ = |
| 54 net::URLFetcher::Create(kURLFetcherIDForTest, device_description_url_, | 76 net::URLFetcher::Create(kURLFetcherIDForTest, device_description_url_, |
| 55 net::URLFetcher::GET, this); | 77 net::URLFetcher::GET, this, traffic_annotation); |
| 56 | 78 |
| 57 // net::LOAD_BYPASS_PROXY: Proxies almost certainly hurt more cases than they | 79 // net::LOAD_BYPASS_PROXY: Proxies almost certainly hurt more cases than they |
| 58 // help. | 80 // help. |
| 59 // net::LOAD_DISABLE_CACHE: The request should not touch the cache. | 81 // net::LOAD_DISABLE_CACHE: The request should not touch the cache. |
| 60 // net::LOAD_DO_NOT_{SAVE,SEND}_COOKIES: The request should not touch cookies. | 82 // net::LOAD_DO_NOT_{SAVE,SEND}_COOKIES: The request should not touch cookies. |
| 61 // net::LOAD_DO_NOT_SEND_AUTH_DATA: The request should not send auth data. | 83 // net::LOAD_DO_NOT_SEND_AUTH_DATA: The request should not send auth data. |
| 62 fetcher_->SetLoadFlags(net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE | | 84 fetcher_->SetLoadFlags(net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE | |
| 63 net::LOAD_DO_NOT_SAVE_COOKIES | | 85 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 64 net::LOAD_DO_NOT_SEND_COOKIES | | 86 net::LOAD_DO_NOT_SEND_COOKIES | |
| 65 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 87 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 int64_t current, | 164 int64_t current, |
| 143 int64_t total) {} | 165 int64_t total) {} |
| 144 | 166 |
| 145 void DeviceDescriptionFetcher::ReportError(const std::string& message) { | 167 void DeviceDescriptionFetcher::ReportError(const std::string& message) { |
| 146 std::move(error_cb_).Run(message); | 168 std::move(error_cb_).Run(message); |
| 147 } | 169 } |
| 148 | 170 |
| 149 } // namespace dial | 171 } // namespace dial |
| 150 } // namespace api | 172 } // namespace api |
| 151 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |