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

Side by Side Diff: chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc

Issue 11778097: Revert revision 176015 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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/api/cloud_print_private/cloud_print_private_ api.h" 5 #include "chrome/browser/extensions/api/cloud_print_private/cloud_print_private_ api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 CloudPrintTestsDelegate::CloudPrintTestsDelegate() { 26 CloudPrintTestsDelegate::CloudPrintTestsDelegate() {
27 instance_ = this; 27 instance_ = this;
28 } 28 }
29 29
30 CloudPrintTestsDelegate::~CloudPrintTestsDelegate() { 30 CloudPrintTestsDelegate::~CloudPrintTestsDelegate() {
31 instance_ = NULL; 31 instance_ = NULL;
32 } 32 }
33 33
34 CloudPrintPrivateSetupConnectorFunction:: 34 CloudPrintSetupConnectorFunction::CloudPrintSetupConnectorFunction() {
35 CloudPrintPrivateSetupConnectorFunction() {
36 } 35 }
37 36
38 CloudPrintPrivateSetupConnectorFunction:: 37 CloudPrintSetupConnectorFunction::~CloudPrintSetupConnectorFunction() {
39 ~CloudPrintPrivateSetupConnectorFunction() {
40 } 38 }
41 39
42 40
43 bool CloudPrintPrivateSetupConnectorFunction::RunImpl() { 41 bool CloudPrintSetupConnectorFunction::RunImpl() {
44 using extensions::api::cloud_print_private::SetupConnector::Params; 42 using extensions::api::cloud_print_private::SetupConnector::Params;
45 scoped_ptr<Params> params(Params::Create(*args_)); 43 scoped_ptr<Params> params(Params::Create(*args_));
46 if (CloudPrintTestsDelegate::instance()) { 44 if (CloudPrintTestsDelegate::instance()) {
47 CloudPrintTestsDelegate::instance()->SetupConnector( 45 CloudPrintTestsDelegate::instance()->SetupConnector(
48 params->user_email, 46 params->user_email,
49 params->robot_email, 47 params->robot_email,
50 params->credentials, 48 params->credentials,
51 params->connect_new_printers, 49 params->connect_new_printers,
52 params->printer_blacklist); 50 params->printer_blacklist);
53 } else { 51 } else {
54 CloudPrintProxyServiceFactory::GetForProfile(profile_)-> 52 CloudPrintProxyServiceFactory::GetForProfile(profile_)->
55 EnableForUserWithRobot(params->credentials, 53 EnableForUserWithRobot(params->credentials,
56 params->robot_email, 54 params->robot_email,
57 params->user_email, 55 params->user_email,
58 params->connect_new_printers, 56 params->connect_new_printers,
59 params->printer_blacklist); 57 params->printer_blacklist);
60 } 58 }
61 SendResponse(true); 59 SendResponse(true);
62 return true; 60 return true;
63 } 61 }
64 62
65 CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() { 63 CloudPrintGetHostNameFunction::CloudPrintGetHostNameFunction() {
66 } 64 }
67 65
68 CloudPrintPrivateGetHostNameFunction::~CloudPrintPrivateGetHostNameFunction() { 66 CloudPrintGetHostNameFunction::~CloudPrintGetHostNameFunction() {
69 } 67 }
70 68
71 bool CloudPrintPrivateGetHostNameFunction::RunImpl() { 69 bool CloudPrintGetHostNameFunction::RunImpl() {
72 SetResult(Value::CreateStringValue( 70 SetResult(Value::CreateStringValue(
73 CloudPrintTestsDelegate::instance() ? 71 CloudPrintTestsDelegate::instance() ?
74 CloudPrintTestsDelegate::instance()->GetHostName() : 72 CloudPrintTestsDelegate::instance()->GetHostName() :
75 net::GetHostName())); 73 net::GetHostName()));
76 SendResponse(true); 74 SendResponse(true);
77 return true; 75 return true;
78 } 76 }
79 77
80 CloudPrintPrivateGetPrintersFunction::CloudPrintPrivateGetPrintersFunction() { 78 CloudPrintGetPrintersFunction::CloudPrintGetPrintersFunction() {
81 } 79 }
82 80
83 CloudPrintPrivateGetPrintersFunction::~CloudPrintPrivateGetPrintersFunction() { 81 CloudPrintGetPrintersFunction::~CloudPrintGetPrintersFunction() {
84 } 82 }
85 83
86 void CloudPrintPrivateGetPrintersFunction::ReturnResult( 84 void CloudPrintGetPrintersFunction::ReturnResult(
87 const base::ListValue* printers) { 85 const base::ListValue* printers) {
88 SetResult(printers->DeepCopy()); 86 SetResult(printers->DeepCopy());
89 SendResponse(true); 87 SendResponse(true);
90 } 88 }
91 89
92 void CloudPrintPrivateGetPrintersFunction::CollectPrinters() { 90 void CloudPrintGetPrintersFunction::CollectPrinters() {
93 scoped_ptr<base::ListValue> result(new base::ListValue()); 91 scoped_ptr<base::ListValue> result(new base::ListValue());
94 if (CloudPrintTestsDelegate::instance()) { 92 if (CloudPrintTestsDelegate::instance()) {
95 std::vector<std::string> printers = 93 std::vector<std::string> printers =
96 CloudPrintTestsDelegate::instance()->GetPrinters(); 94 CloudPrintTestsDelegate::instance()->GetPrinters();
97 for (size_t i = 0; i < printers.size(); ++i) 95 for (size_t i = 0; i < printers.size(); ++i)
98 result->Append(Value::CreateStringValue(printers[i])); 96 result->Append(Value::CreateStringValue(printers[i]));
99 } else { 97 } else {
100 printing::PrinterList printers; 98 printing::PrinterList printers;
101 scoped_refptr<printing::PrintBackend> backend( 99 scoped_refptr<printing::PrintBackend> backend(
102 printing::PrintBackend::CreateInstance(NULL)); 100 printing::PrintBackend::CreateInstance(NULL));
103 if (backend) 101 if (backend)
104 backend->EnumeratePrinters(&printers); 102 backend->EnumeratePrinters(&printers);
105 for (size_t i = 0; i < printers.size(); ++i) 103 for (size_t i = 0; i < printers.size(); ++i)
106 result->Append(Value::CreateStringValue(printers[i].printer_name)); 104 result->Append(Value::CreateStringValue(printers[i].printer_name));
107 } 105 }
108 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 106 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
109 base::Bind(&CloudPrintPrivateGetPrintersFunction::ReturnResult, this, 107 base::Bind(&CloudPrintGetPrintersFunction::ReturnResult, this,
110 base::Owned(result.release()))); 108 base::Owned(result.release())));
111 } 109 }
112 110
113 111
114 bool CloudPrintPrivateGetPrintersFunction::RunImpl() { 112 bool CloudPrintGetPrintersFunction::RunImpl() {
115 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, 113 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE,
116 base::Bind(&CloudPrintPrivateGetPrintersFunction::CollectPrinters, this)); 114 base::Bind(&CloudPrintGetPrintersFunction::CollectPrinters, this));
117 return true; 115 return true;
118 } 116 }
119 117
120 } // namespace extensions 118 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698