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

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

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: nits 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
58 net::NetworkTrafficAnnotationTag traffic_annotation =
59 net::DefineNetworkTrafficAnnotation("webstore_install_helper", R"(
60 semantics {
61 sender: "Webstore Install Helper"
62 description:
63 "Fetches the bitmap corresponding to an extension icon."
64 trigger:
65 "This can happen in a few different circumstances: "
66 "1-User initiated an install from the Chrome Web Store."
67 "2-User initiated an inline installation from another website."
68 "3-Loading of kiosk app data on Chrome OS (provided that the "
69 "kiosk app is a Web Store app)."
70 data:
71 "The url of the icon for the extension, which includes the "
72 "extension id."
73 destination: GOOGLE_OWNED_SERVICE
74 }
75 policy {
76 cookies_allowed: false
77 setting:
78 "There's no direct Chromium's setting to disable this, but you "
79 "could uninstall all extensions and not install (or begin the "
80 "installation flow for) any more."
81 policy_exception_justification:
82 "Not implemented, considered not useful."
83 })");
84
85 icon_fetcher_.reset(
86 new chrome::BitmapFetcher(icon_url_, this, traffic_annotation));
57 icon_fetcher_->Init( 87 icon_fetcher_->Init(
58 context_getter_, std::string(), 88 context_getter_, std::string(),
59 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 89 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
60 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES); 90 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES);
61 icon_fetcher_->Start(); 91 icon_fetcher_->Start();
62 } 92 }
63 } 93 }
64 94
65 void WebstoreInstallHelper::OnFetchComplete(const GURL& url, 95 void WebstoreInstallHelper::OnFetchComplete(const GURL& url,
66 const SkBitmap* image) { 96 const SkBitmap* image) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (!icon_decode_complete_ || !manifest_parse_complete_) 140 if (!icon_decode_complete_ || !manifest_parse_complete_)
111 return; 141 return;
112 142
113 if (error_.empty() && parsed_manifest_) 143 if (error_.empty() && parsed_manifest_)
114 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); 144 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release());
115 else 145 else
116 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); 146 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_);
117 } 147 }
118 148
119 } // namespace extensions 149 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc ('k') | chrome/browser/profiles/profile_avatar_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698