Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/extensions/webstore_install_helper.cc

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Minor correction. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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("webstore_install_helper", R"(
59 semantics {
60 sender: "Webstore Install Helper"
61 description:
62 "Fetches the bitmap corresponding to an extension icon."
63 trigger:
64 "This can happen in a few different circumstances: "
65 "1-User initiated an install from the Chrome Web Store."
66 "2-User initiated an inline installation from another website."
67 "3-...Something with kiosk apps - maybe steel@ knows more about "
tbarzic 2017/02/14 21:24:57 Loading of kiosk app data on Chrome OS (provided t
Ramin Halavati 2017/02/15 11:52:02 Done.
68 "that one."
69 data:
70 "The url of the icon for the extension, which includes the "
71 "extension id."
72 destination: GOOGLE_OWNED_SERVICE
73 }
74 policy {
75 cookies_allowed: false
76 setting:
77 "There's no direct Chrome setting to disable this, but you could "
78 "uninstall all extensions and not install (or begin the "
79 "installation flow for) any more."
80 policy {
81 [POLICY_NAME] {
82 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
83 value: ...
84 }
85 }
86 })");
87 icon_fetcher_.reset(
88 new chrome::BitmapFetcher(icon_url_, this, traffic_annotation));
57 icon_fetcher_->Init( 89 icon_fetcher_->Init(
58 context_getter_, std::string(), 90 context_getter_, std::string(),
59 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 91 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
60 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); 92 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES);
61 icon_fetcher_->Start(); 93 icon_fetcher_->Start();
62 } 94 }
63 } 95 }
64 96
65 void WebstoreInstallHelper::OnFetchComplete(const GURL& url, 97 void WebstoreInstallHelper::OnFetchComplete(const GURL& url,
66 const SkBitmap* image) { 98 const SkBitmap* image) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (!icon_decode_complete_ || !manifest_parse_complete_) 142 if (!icon_decode_complete_ || !manifest_parse_complete_)
111 return; 143 return;
112 144
113 if (error_.empty() && parsed_manifest_) 145 if (error_.empty() && parsed_manifest_)
114 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); 146 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release());
115 else 147 else
116 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); 148 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_);
117 } 149 }
118 150
119 } // namespace extensions 151 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698