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/extensions/webstore_install_helper.h" | 5 #include "chrome/browser/extensions/webstore_install_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
10 #include "components/safe_json/safe_json_parser.h" | 10 #include "components/safe_json/safe_json_parser.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/traffic_annotation/network_traffic_annotation.h" | |
13 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
14 | 15 |
15 using content::BrowserThread; | 16 using content::BrowserThread; |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const char kImageDecodeError[] = "Image decode failed"; | 20 const char kImageDecodeError[] = "Image decode failed"; |
20 | 21 |
21 } // namespace | 22 } // namespace |
22 | 23 |
(...skipping 23 matching lines...) Expand all Loading... | |
46 safe_json::SafeJsonParser::Parse( | 47 safe_json::SafeJsonParser::Parse( |
47 manifest_, base::Bind(&WebstoreInstallHelper::OnJSONParseSucceeded, this), | 48 manifest_, base::Bind(&WebstoreInstallHelper::OnJSONParseSucceeded, this), |
48 base::Bind(&WebstoreInstallHelper::OnJSONParseFailed, this)); | 49 base::Bind(&WebstoreInstallHelper::OnJSONParseFailed, this)); |
49 | 50 |
50 if (icon_url_.is_empty()) { | 51 if (icon_url_.is_empty()) { |
51 icon_decode_complete_ = true; | 52 icon_decode_complete_ = true; |
52 } else { | 53 } else { |
53 // No existing |icon_fetcher_| to avoid unbalanced AddRef(). | 54 // No existing |icon_fetcher_| to avoid unbalanced AddRef(). |
54 CHECK(!icon_fetcher_.get()); | 55 CHECK(!icon_fetcher_.get()); |
55 AddRef(); // Balanced in OnFetchComplete(). | 56 AddRef(); // Balanced in OnFetchComplete(). |
56 icon_fetcher_.reset(new chrome::BitmapFetcher(icon_url_, this)); | 57 net::NetworkTrafficAnnotationTag traffic_annotation = |
58 net::DefineNetworkTrafficAnnotation("", R"( | |
59 semantics { | |
60 sender: "" | |
Devlin
2017/02/13 23:35:56
Webstore Install Helper
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
61 description: "" | |
Devlin
2017/02/13 23:35:56
Fetches the bitmap corresponding to an extension i
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
62 trigger: "" | |
Devlin
2017/02/13 23:35:56
This can happen in a few different circumstances:
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
63 data: "" | |
Devlin
2017/02/13 23:35:56
The url of the icon for the extension, which inclu
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
64 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
Devlin
2017/02/13 23:35:56
Chrome Web Store == GOOGLE_OWNED_SERVICE.
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
65 } | |
66 policy { | |
67 cookies_allowed: false/true | |
Devlin
2017/02/13 23:35:56
Good question - how would we determine this?
Ramin Halavati
2017/02/14 10:05:54
In current case, it is specified in the icon_fetch
| |
68 cookies_store_exceptions: "" | |
69 setting: "" | |
Devlin
2017/02/13 23:35:56
There's no direct Chrome setting to disable this,
Ramin Halavati
2017/02/14 10:05:54
Done.
| |
70 policy { | |
71 [POLICY_NAME] { | |
72 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
Devlin
2017/02/13 23:35:57
I don't see policy_options in the traffic_annotati
Ramin Halavati
2017/02/14 10:05:54
The policy options are here:
https://cs.chromium.o
Devlin
2017/02/15 00:36:08
But what are the policy options indicative of? Th
Ramin Halavati
2017/02/15 11:52:02
The questions is if any of the policy options will
| |
73 value: ... | |
74 } | |
75 } | |
76 })"); | |
77 icon_fetcher_.reset( | |
78 new chrome::BitmapFetcher(icon_url_, this, traffic_annotation)); | |
57 icon_fetcher_->Init( | 79 icon_fetcher_->Init( |
58 context_getter_, std::string(), | 80 context_getter_, std::string(), |
59 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 81 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
60 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); | 82 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); |
61 icon_fetcher_->Start(); | 83 icon_fetcher_->Start(); |
62 } | 84 } |
63 } | 85 } |
64 | 86 |
65 void WebstoreInstallHelper::OnFetchComplete(const GURL& url, | 87 void WebstoreInstallHelper::OnFetchComplete(const GURL& url, |
66 const SkBitmap* image) { | 88 const SkBitmap* image) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 if (!icon_decode_complete_ || !manifest_parse_complete_) | 132 if (!icon_decode_complete_ || !manifest_parse_complete_) |
111 return; | 133 return; |
112 | 134 |
113 if (error_.empty() && parsed_manifest_) | 135 if (error_.empty() && parsed_manifest_) |
114 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); | 136 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); |
115 else | 137 else |
116 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); | 138 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); |
117 } | 139 } |
118 | 140 |
119 } // namespace extensions | 141 } // namespace extensions |
OLD | NEW |