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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stddef.h> 8 #include <stddef.h>
9
9 #include <map> 10 #include <map>
11 #include <memory>
10 #include <string> 12 #include <string>
11 #include <utility> 13 #include <utility>
12 14
13 #include "base/base64.h" 15 #include "base/base64.h"
14 #include "base/bind.h" 16 #include "base/bind.h"
15 #include "base/bind_helpers.h" 17 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 18 #include "base/command_line.h"
17 #include "base/i18n/file_util_icu.h" 19 #include "base/i18n/file_util_icu.h"
18 #include "base/i18n/number_formatting.h" 20 #include "base/i18n/number_formatting.h"
19 #include "base/json/json_reader.h" 21 #include "base/json/json_reader.h"
20 #include "base/lazy_instance.h" 22 #include "base/lazy_instance.h"
21 #include "base/macros.h" 23 #include "base/macros.h"
22 #include "base/memory/ref_counted_memory.h" 24 #include "base/memory/ref_counted_memory.h"
23 #include "base/memory/scoped_ptr.h"
24 #include "base/metrics/histogram.h" 25 #include "base/metrics/histogram.h"
25 #include "base/path_service.h" 26 #include "base/path_service.h"
26 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
27 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
29 #include "base/threading/thread.h" 30 #include "base/threading/thread.h"
30 #include "base/threading/thread_restrictions.h" 31 #include "base/threading/thread_restrictions.h"
31 #include "base/values.h" 32 #include "base/values.h"
32 #include "build/build_config.h" 33 #include "build/build_config.h"
33 #include "chrome/browser/app_mode/app_mode_utils.h" 34 #include "chrome/browser/app_mode/app_mode_utils.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 // Id of the predefined PDF printer. 177 // Id of the predefined PDF printer.
177 const char kLocalPdfPrinterId[] = "Save as PDF"; 178 const char kLocalPdfPrinterId[] = "Save as PDF";
178 179
179 // Additional printer capability setting keys. 180 // Additional printer capability setting keys.
180 const char kPrinterId[] = "printerId"; 181 const char kPrinterId[] = "printerId";
181 const char kPrinterCapabilities[] = "capabilities"; 182 const char kPrinterCapabilities[] = "capabilities";
182 183
183 // Get the print job settings dictionary from |args|. The caller takes 184 // Get the print job settings dictionary from |args|. The caller takes
184 // ownership of the returned DictionaryValue. Returns NULL on failure. 185 // ownership of the returned DictionaryValue. Returns NULL on failure.
185 scoped_ptr<base::DictionaryValue> GetSettingsDictionary( 186 std::unique_ptr<base::DictionaryValue> GetSettingsDictionary(
186 const base::ListValue* args) { 187 const base::ListValue* args) {
187 std::string json_str; 188 std::string json_str;
188 if (!args->GetString(0, &json_str)) { 189 if (!args->GetString(0, &json_str)) {
189 NOTREACHED() << "Could not read JSON argument"; 190 NOTREACHED() << "Could not read JSON argument";
190 return NULL; 191 return NULL;
191 } 192 }
192 if (json_str.empty()) { 193 if (json_str.empty()) {
193 NOTREACHED() << "Empty print job settings"; 194 NOTREACHED() << "Empty print job settings";
194 return NULL; 195 return NULL;
195 } 196 }
196 scoped_ptr<base::DictionaryValue> settings = 197 std::unique_ptr<base::DictionaryValue> settings =
197 base::DictionaryValue::From(base::JSONReader::Read(json_str)); 198 base::DictionaryValue::From(base::JSONReader::Read(json_str));
198 if (!settings) { 199 if (!settings) {
199 NOTREACHED() << "Print job settings must be a dictionary."; 200 NOTREACHED() << "Print job settings must be a dictionary.";
200 return NULL; 201 return NULL;
201 } 202 }
202 203
203 if (settings->empty()) { 204 if (settings->empty()) {
204 NOTREACHED() << "Print job settings dictionary is empty"; 205 NOTREACHED() << "Print job settings dictionary is empty";
205 return NULL; 206 return NULL;
206 } 207 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 public: 320 public:
320 // PrintingContext::Delegate methods. 321 // PrintingContext::Delegate methods.
321 gfx::NativeView GetParentView() override { return NULL; } 322 gfx::NativeView GetParentView() override { return NULL; }
322 std::string GetAppLocale() override { 323 std::string GetAppLocale() override {
323 return g_browser_process->GetApplicationLocale(); 324 return g_browser_process->GetApplicationLocale();
324 } 325 }
325 }; 326 };
326 327
327 gfx::Size GetDefaultPdfMediaSizeMicrons() { 328 gfx::Size GetDefaultPdfMediaSizeMicrons() {
328 PrintingContextDelegate delegate; 329 PrintingContextDelegate delegate;
329 scoped_ptr<printing::PrintingContext> printing_context( 330 std::unique_ptr<printing::PrintingContext> printing_context(
330 printing::PrintingContext::Create(&delegate)); 331 printing::PrintingContext::Create(&delegate));
331 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() || 332 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() ||
332 printing_context->settings().device_units_per_inch() <= 0) { 333 printing_context->settings().device_units_per_inch() <= 0) {
333 return gfx::Size(); 334 return gfx::Size();
334 } 335 }
335 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); 336 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits();
336 float deviceMicronsPerDeviceUnit = 337 float deviceMicronsPerDeviceUnit =
337 (printing::kHundrethsMMPerInch * 10.0f) / 338 (printing::kHundrethsMMPerInch * 10.0f) /
338 printing_context->settings().device_units_per_inch(); 339 printing_context->settings().device_units_per_inch();
339 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, 340 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit,
340 pdf_media_size.height() * deviceMicronsPerDeviceUnit); 341 pdf_media_size.height() * deviceMicronsPerDeviceUnit);
341 } 342 }
342 343
343 typedef base::Callback<void(const base::DictionaryValue*)> 344 typedef base::Callback<void(const base::DictionaryValue*)>
344 GetPdfCapabilitiesCallback; 345 GetPdfCapabilitiesCallback;
345 346
346 scoped_ptr<base::DictionaryValue> GetPdfCapabilitiesOnFileThread( 347 std::unique_ptr<base::DictionaryValue> GetPdfCapabilitiesOnFileThread(
347 const std::string& locale) { 348 const std::string& locale) {
348 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 349 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
349 350
350 cloud_devices::CloudDeviceDescription description; 351 cloud_devices::CloudDeviceDescription description;
351 using namespace cloud_devices::printer; 352 using namespace cloud_devices::printer;
352 353
353 OrientationCapability orientation; 354 OrientationCapability orientation;
354 orientation.AddOption(cloud_devices::printer::PORTRAIT); 355 orientation.AddOption(cloud_devices::printer::PORTRAIT);
355 orientation.AddOption(cloud_devices::printer::LANDSCAPE); 356 orientation.AddOption(cloud_devices::printer::LANDSCAPE);
356 orientation.AddDefaultOption(AUTO_ORIENTATION, true); 357 orientation.AddDefaultOption(AUTO_ORIENTATION, true);
(...skipping 28 matching lines...) Expand all
385 default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4); 386 default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4);
386 } 387 }
387 MediaCapability media; 388 MediaCapability media;
388 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) { 389 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) {
389 Media media_option(kPdfMedia[i]); 390 Media media_option(kPdfMedia[i]);
390 media.AddDefaultOption(media_option, 391 media.AddDefaultOption(media_option,
391 default_media.type == media_option.type); 392 default_media.type == media_option.type);
392 } 393 }
393 media.SaveTo(&description); 394 media.SaveTo(&description);
394 395
395 return scoped_ptr<base::DictionaryValue>(description.root().DeepCopy()); 396 return std::unique_ptr<base::DictionaryValue>(description.root().DeepCopy());
396 } 397 }
397 398
398 scoped_ptr<base::DictionaryValue> GetLocalPrinterCapabilitiesOnFileThread( 399 std::unique_ptr<base::DictionaryValue> GetLocalPrinterCapabilitiesOnFileThread(
399 const std::string& printer_name) { 400 const std::string& printer_name) {
400 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 401 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
401 402
402 scoped_refptr<printing::PrintBackend> print_backend( 403 scoped_refptr<printing::PrintBackend> print_backend(
403 printing::PrintBackend::CreateInstance(NULL)); 404 printing::PrintBackend::CreateInstance(NULL));
404 405
405 VLOG(1) << "Get printer capabilities start for " << printer_name; 406 VLOG(1) << "Get printer capabilities start for " << printer_name;
406 crash_keys::ScopedPrinterInfo crash_key( 407 crash_keys::ScopedPrinterInfo crash_key(
407 print_backend->GetPrinterDriverInfo(printer_name)); 408 print_backend->GetPrinterDriverInfo(printer_name));
408 409
409 if (!print_backend->IsValidPrinter(printer_name)) { 410 if (!print_backend->IsValidPrinter(printer_name)) {
410 LOG(WARNING) << "Invalid printer " << printer_name; 411 LOG(WARNING) << "Invalid printer " << printer_name;
411 return scoped_ptr<base::DictionaryValue>(); 412 return std::unique_ptr<base::DictionaryValue>();
412 } 413 }
413 414
414 printing::PrinterSemanticCapsAndDefaults info; 415 printing::PrinterSemanticCapsAndDefaults info;
415 if (!print_backend->GetPrinterSemanticCapsAndDefaults(printer_name, &info)) { 416 if (!print_backend->GetPrinterSemanticCapsAndDefaults(printer_name, &info)) {
416 LOG(WARNING) << "Failed to get capabilities for " << printer_name; 417 LOG(WARNING) << "Failed to get capabilities for " << printer_name;
417 return scoped_ptr<base::DictionaryValue>(); 418 return std::unique_ptr<base::DictionaryValue>();
418 } 419 }
419 420
420 scoped_ptr<base::DictionaryValue> description( 421 std::unique_ptr<base::DictionaryValue> description(
421 cloud_print::PrinterSemanticCapsAndDefaultsToCdd(info)); 422 cloud_print::PrinterSemanticCapsAndDefaultsToCdd(info));
422 if (!description) { 423 if (!description) {
423 LOG(WARNING) << "Failed to convert capabilities for " << printer_name; 424 LOG(WARNING) << "Failed to convert capabilities for " << printer_name;
424 return scoped_ptr<base::DictionaryValue>(); 425 return std::unique_ptr<base::DictionaryValue>();
425 } 426 }
426 427
427 return description; 428 return description;
428 } 429 }
429 430
430 void EnumeratePrintersOnFileThread(base::ListValue* printers) { 431 void EnumeratePrintersOnFileThread(base::ListValue* printers) {
431 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 432 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
432 433
433 scoped_refptr<printing::PrintBackend> print_backend( 434 scoped_refptr<printing::PrintBackend> print_backend(
434 printing::PrintBackend::CreateInstance(NULL)); 435 printing::PrintBackend::CreateInstance(NULL));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 GetPrinterCapabilitiesFailureCallback; 482 GetPrinterCapabilitiesFailureCallback;
482 483
483 void GetPrinterCapabilitiesOnFileThread( 484 void GetPrinterCapabilitiesOnFileThread(
484 const std::string& printer_name, 485 const std::string& printer_name,
485 const std::string& locale, 486 const std::string& locale,
486 const GetPrinterCapabilitiesSuccessCallback& success_cb, 487 const GetPrinterCapabilitiesSuccessCallback& success_cb,
487 const GetPrinterCapabilitiesFailureCallback& failure_cb) { 488 const GetPrinterCapabilitiesFailureCallback& failure_cb) {
488 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 489 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
489 DCHECK(!printer_name.empty()); 490 DCHECK(!printer_name.empty());
490 491
491 scoped_ptr<base::DictionaryValue> printer_capabilities( 492 std::unique_ptr<base::DictionaryValue> printer_capabilities(
492 printer_name == kLocalPdfPrinterId ? 493 printer_name == kLocalPdfPrinterId
493 GetPdfCapabilitiesOnFileThread(locale) : 494 ? GetPdfCapabilitiesOnFileThread(locale)
494 GetLocalPrinterCapabilitiesOnFileThread(printer_name)); 495 : GetLocalPrinterCapabilitiesOnFileThread(printer_name));
495 if (!printer_capabilities) { 496 if (!printer_capabilities) {
496 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 497 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
497 base::Bind(failure_cb, printer_name)); 498 base::Bind(failure_cb, printer_name));
498 return; 499 return;
499 } 500 }
500 501
501 scoped_ptr<base::DictionaryValue> printer_info(new base::DictionaryValue); 502 std::unique_ptr<base::DictionaryValue> printer_info(
503 new base::DictionaryValue);
502 printer_info->SetString(kPrinterId, printer_name); 504 printer_info->SetString(kPrinterId, printer_name);
503 printer_info->Set(kPrinterCapabilities, printer_capabilities.release()); 505 printer_info->Set(kPrinterCapabilities, printer_capabilities.release());
504 506
505 BrowserThread::PostTask( 507 BrowserThread::PostTask(
506 BrowserThread::UI, FROM_HERE, 508 BrowserThread::UI, FROM_HERE,
507 base::Bind(success_cb, base::Owned(printer_info.release()))); 509 base::Bind(success_cb, base::Owned(printer_info.release())));
508 } 510 }
509 511
510 base::LazyInstance<printing::StickySettings> g_sticky_settings = 512 base::LazyInstance<printing::StickySettings> g_sticky_settings =
511 LAZY_INSTANCE_INITIALIZER; 513 LAZY_INSTANCE_INITIALIZER;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 chromeos::DeviceOAuth2TokenService* token_service = 559 chromeos::DeviceOAuth2TokenService* token_service =
558 chromeos::DeviceOAuth2TokenServiceFactory::Get(); 560 chromeos::DeviceOAuth2TokenServiceFactory::Get();
559 account_id = token_service->GetRobotAccountId(); 561 account_id = token_service->GetRobotAccountId();
560 service = token_service; 562 service = token_service;
561 #endif 563 #endif
562 } 564 }
563 565
564 if (service) { 566 if (service) {
565 OAuth2TokenService::ScopeSet oauth_scopes; 567 OAuth2TokenService::ScopeSet oauth_scopes;
566 oauth_scopes.insert(cloud_devices::kCloudPrintAuthScope); 568 oauth_scopes.insert(cloud_devices::kCloudPrintAuthScope);
567 scoped_ptr<OAuth2TokenService::Request> request( 569 std::unique_ptr<OAuth2TokenService::Request> request(
568 service->StartRequest(account_id, oauth_scopes, this)); 570 service->StartRequest(account_id, oauth_scopes, this));
569 requests_[type].reset(request.release()); 571 requests_[type].reset(request.release());
570 } else { 572 } else {
571 handler_->SendAccessToken(type, std::string()); // Unknown type. 573 handler_->SendAccessToken(type, std::string()); // Unknown type.
572 } 574 }
573 } 575 }
574 576
575 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 577 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
576 const std::string& access_token, 578 const std::string& access_token,
577 const base::Time& expiration_time) override { 579 const base::Time& expiration_time) override {
(...skipping 12 matching lines...) Expand all
590 if (i->second.get() == request) { 592 if (i->second.get() == request) {
591 handler_->SendAccessToken(i->first, access_token); 593 handler_->SendAccessToken(i->first, access_token);
592 requests_.erase(i); 594 requests_.erase(i);
593 return; 595 return;
594 } 596 }
595 } 597 }
596 NOTREACHED(); 598 NOTREACHED();
597 } 599 }
598 600
599 using Requests = 601 using Requests =
600 std::map<std::string, scoped_ptr<OAuth2TokenService::Request>>; 602 std::map<std::string, std::unique_ptr<OAuth2TokenService::Request>>;
601 Requests requests_; 603 Requests requests_;
602 PrintPreviewHandler* handler_; 604 PrintPreviewHandler* handler_;
603 605
604 DISALLOW_COPY_AND_ASSIGN(AccessTokenService); 606 DISALLOW_COPY_AND_ASSIGN(AccessTokenService);
605 }; 607 };
606 608
607 PrintPreviewHandler::PrintPreviewHandler() 609 PrintPreviewHandler::PrintPreviewHandler()
608 : regenerate_preview_request_count_(0), 610 : regenerate_preview_request_count_(0),
609 manage_printers_dialog_request_count_(0), 611 manage_printers_dialog_request_count_(0),
610 manage_cloud_printers_dialog_request_count_(0), 612 manage_cloud_printers_dialog_request_count_(0),
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 787
786 EnsureExtensionPrinterHandlerSet(); 788 EnsureExtensionPrinterHandlerSet();
787 extension_printer_handler_->StartGetCapability( 789 extension_printer_handler_->StartGetCapability(
788 printer_id, 790 printer_id,
789 base::Bind(&PrintPreviewHandler::OnGotExtensionPrinterCapabilities, 791 base::Bind(&PrintPreviewHandler::OnGotExtensionPrinterCapabilities,
790 base::Unretained(this))); 792 base::Unretained(this)));
791 } 793 }
792 794
793 void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) { 795 void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
794 DCHECK_EQ(3U, args->GetSize()); 796 DCHECK_EQ(3U, args->GetSize());
795 scoped_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args); 797 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args);
796 if (!settings) 798 if (!settings)
797 return; 799 return;
798 int request_id = -1; 800 int request_id = -1;
799 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id)) 801 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id))
800 return; 802 return;
801 803
802 print_preview_ui()->OnPrintPreviewRequest(request_id); 804 print_preview_ui()->OnPrintPreviewRequest(request_id);
803 // Add an additional key in order to identify |print_preview_ui| later on 805 // Add an additional key in order to identify |print_preview_ui| later on
804 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO 806 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
805 // thread. 807 // thread.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 883 }
882 884
883 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { 885 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
884 ReportStats(); 886 ReportStats();
885 887
886 // Record the number of times the user requests to regenerate preview data 888 // Record the number of times the user requests to regenerate preview data
887 // before printing. 889 // before printing.
888 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 890 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
889 regenerate_preview_request_count_); 891 regenerate_preview_request_count_);
890 892
891 scoped_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args); 893 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args);
892 if (!settings) 894 if (!settings)
893 return; 895 return;
894 896
895 ReportPrintSettingsStats(*settings); 897 ReportPrintSettingsStats(*settings);
896 898
897 // Never try to add headers/footers here. It's already in the generated PDF. 899 // Never try to add headers/footers here. It's already in the generated PDF.
898 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); 900 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
899 901
900 bool print_to_pdf = false; 902 bool print_to_pdf = false;
901 bool is_cloud_printer = false; 903 bool is_cloud_printer = false;
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 } 1553 }
1552 } 1554 }
1553 1555
1554 void PrintPreviewHandler::LocalPrinterRemoved(const std::string& name) { 1556 void PrintPreviewHandler::LocalPrinterRemoved(const std::string& name) {
1555 } 1557 }
1556 1558
1557 void PrintPreviewHandler::LocalPrinterCacheFlushed() { 1559 void PrintPreviewHandler::LocalPrinterCacheFlushed() {
1558 } 1560 }
1559 1561
1560 void PrintPreviewHandler::PrivetCapabilitiesUpdateClient( 1562 void PrintPreviewHandler::PrivetCapabilitiesUpdateClient(
1561 scoped_ptr<cloud_print::PrivetHTTPClient> http_client) { 1563 std::unique_ptr<cloud_print::PrivetHTTPClient> http_client) {
1562 if (!PrivetUpdateClient(std::move(http_client))) 1564 if (!PrivetUpdateClient(std::move(http_client)))
1563 return; 1565 return;
1564 1566
1565 privet_capabilities_operation_ = 1567 privet_capabilities_operation_ =
1566 privet_http_client_->CreateCapabilitiesOperation( 1568 privet_http_client_->CreateCapabilitiesOperation(
1567 base::Bind(&PrintPreviewHandler::OnPrivetCapabilities, 1569 base::Bind(&PrintPreviewHandler::OnPrivetCapabilities,
1568 base::Unretained(this))); 1570 base::Unretained(this)));
1569 privet_capabilities_operation_->Start(); 1571 privet_capabilities_operation_->Start();
1570 } 1572 }
1571 1573
1572 bool PrintPreviewHandler::PrivetUpdateClient( 1574 bool PrintPreviewHandler::PrivetUpdateClient(
1573 scoped_ptr<cloud_print::PrivetHTTPClient> http_client) { 1575 std::unique_ptr<cloud_print::PrivetHTTPClient> http_client) {
1574 if (!http_client) { 1576 if (!http_client) {
1575 SendPrivetCapabilitiesError(privet_http_resolution_->GetName()); 1577 SendPrivetCapabilitiesError(privet_http_resolution_->GetName());
1576 privet_http_resolution_.reset(); 1578 privet_http_resolution_.reset();
1577 return false; 1579 return false;
1578 } 1580 }
1579 1581
1580 privet_local_print_operation_.reset(); 1582 privet_local_print_operation_.reset();
1581 privet_capabilities_operation_.reset(); 1583 privet_capabilities_operation_.reset();
1582 privet_http_client_ = cloud_print::PrivetV1HTTPClient::CreateDefault( 1584 privet_http_client_ = cloud_print::PrivetV1HTTPClient::CreateDefault(
1583 std::move(http_client)); 1585 std::move(http_client));
1584 1586
1585 privet_http_resolution_.reset(); 1587 privet_http_resolution_.reset();
1586 1588
1587 return true; 1589 return true;
1588 } 1590 }
1589 1591
1590 void PrintPreviewHandler::PrivetLocalPrintUpdateClient( 1592 void PrintPreviewHandler::PrivetLocalPrintUpdateClient(
1591 std::string print_ticket, 1593 std::string print_ticket,
1592 std::string capabilities, 1594 std::string capabilities,
1593 gfx::Size page_size, 1595 gfx::Size page_size,
1594 scoped_ptr<cloud_print::PrivetHTTPClient> http_client) { 1596 std::unique_ptr<cloud_print::PrivetHTTPClient> http_client) {
1595 if (!PrivetUpdateClient(std::move(http_client))) 1597 if (!PrivetUpdateClient(std::move(http_client)))
1596 return; 1598 return;
1597 1599
1598 StartPrivetLocalPrint(print_ticket, capabilities, page_size); 1600 StartPrivetLocalPrint(print_ticket, capabilities, page_size);
1599 } 1601 }
1600 1602
1601 void PrintPreviewHandler::StartPrivetLocalPrint(const std::string& print_ticket, 1603 void PrintPreviewHandler::StartPrivetLocalPrint(const std::string& print_ticket,
1602 const std::string& capabilities, 1604 const std::string& capabilities,
1603 const gfx::Size& page_size) { 1605 const gfx::Size& page_size) {
1604 privet_local_print_operation_ = 1606 privet_local_print_operation_ =
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 1805
1804 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1806 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1805 if (gaia_cookie_manager_service_) 1807 if (gaia_cookie_manager_service_)
1806 gaia_cookie_manager_service_->RemoveObserver(this); 1808 gaia_cookie_manager_service_->RemoveObserver(this);
1807 } 1809 }
1808 1810
1809 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1811 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1810 const base::Closure& closure) { 1812 const base::Closure& closure) {
1811 pdf_file_saved_closure_ = closure; 1813 pdf_file_saved_closure_ = closure;
1812 } 1814 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview/printer_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698