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

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

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Unittests added. 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("", R"(
59 semantics {
60 sender: ""
61 description: ""
62 trigger: ""
63 data: ""
64 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
65 }
66 policy {
67 cookies_allowed: false/true
68 cookies_store_exceptions: ""
69 setting: ""
70 policy {
71 [POLICY_NAME] {
72 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698