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

Side by Side Diff: chromeos/printing/ppd_provider.cc

Issue 2580973002: Base64-decode encoded ppds from the quirksserver, and update tests. (Closed)
Patch Set: Fix some comments. Created 4 years 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
« no previous file with comments | « no previous file | chromeos/printing/ppd_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chromeos/printing/ppd_provider.h" 5 #include "chromeos/printing/ppd_provider.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
12 #include "base/json/json_parser.h" 13 #include "base/json/json_parser.h"
13 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
19 #include "base/threading/sequenced_task_runner_handle.h" 20 #include "base/threading/sequenced_task_runner_handle.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // PPD is too big. 302 // PPD is too big.
302 // 303 //
303 // Note -- if we ever add shared-ppd-sourcing, e.g. we may serve a ppd to 304 // Note -- if we ever add shared-ppd-sourcing, e.g. we may serve a ppd to
304 // a user that's not from an explicitly trusted source, we should also 305 // a user that's not from an explicitly trusted source, we should also
305 // check *uncompressed* size here to head off zip-bombs (e.g. let's 306 // check *uncompressed* size here to head off zip-bombs (e.g. let's
306 // compress 1GBs of zeros into a 900kb file and see what cups does when it 307 // compress 1GBs of zeros into a 900kb file and see what cups does when it
307 // tries to expand that...) 308 // tries to expand that...)
308 ppd_contents->clear(); 309 ppd_contents->clear();
309 return false; 310 return false;
310 } 311 }
311 return true; 312 return base::Base64Decode(*ppd_contents, ppd_contents);
312 } 313 }
313 314
314 // Return the ResolveFetchData associated with |source|. 315 // Return the ResolveFetchData associated with |source|.
315 std::unique_ptr<ResolveFetchData> GetResolveFetchData( 316 std::unique_ptr<ResolveFetchData> GetResolveFetchData(
316 const net::URLFetcher* source) { 317 const net::URLFetcher* source) {
317 base::AutoLock l(resolve_fetches_lock_); 318 base::AutoLock l(resolve_fetches_lock_);
318 auto it = resolve_fetches_.find(source); 319 auto it = resolve_fetches_.find(source);
319 CHECK(it != resolve_fetches_.end()); 320 CHECK(it != resolve_fetches_.end());
320 auto ret = std::move(it->second); 321 auto ret = std::move(it->second);
321 resolve_fetches_.erase(it); 322 resolve_fetches_.erase(it);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 scoped_refptr<net::URLRequestContextGetter> url_context_getter, 464 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
464 scoped_refptr<base::SequencedTaskRunner> io_task_runner, 465 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
465 std::unique_ptr<PpdCache> cache, 466 std::unique_ptr<PpdCache> cache,
466 const PpdProvider::Options& options) { 467 const PpdProvider::Options& options) {
467 return base::MakeUnique<PpdProviderImpl>( 468 return base::MakeUnique<PpdProviderImpl>(
468 api_key, url_context_getter, io_task_runner, std::move(cache), options); 469 api_key, url_context_getter, io_task_runner, std::move(cache), options);
469 } 470 }
470 471
471 } // namespace printing 472 } // namespace printing
472 } // namespace chromeos 473 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/printing/ppd_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698