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

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

Issue 2906633004: Modify PrinterSetupResult enum to constant style. (Closed)
Patch Set: git squash commit for enum-style. Created 3 years, 7 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 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 "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" 5 #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 prefs_->GetPrinter(printer_name); 118 prefs_->GetPrinter(printer_name);
119 if (!printer) { 119 if (!printer) {
120 // If the printer was removed, the lookup will fail. 120 // If the printer was removed, the lookup will fail.
121 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 121 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
122 base::Bind(cb, nullptr)); 122 base::Bind(cb, nullptr));
123 return; 123 return;
124 } 124 }
125 125
126 if (prefs_->IsConfigurationCurrent(*printer)) { 126 if (prefs_->IsConfigurationCurrent(*printer)) {
127 // Skip setup if the printer is already installed. 127 // Skip setup if the printer is already installed.
128 HandlePrinterSetup(std::move(printer), cb, chromeos::SUCCESS); 128 HandlePrinterSetup(std::move(printer), cb, chromeos::kSuccess);
129 return; 129 return;
130 } 130 }
131 131
132 const chromeos::Printer& printer_ref = *printer; 132 const chromeos::Printer& printer_ref = *printer;
133 printer_configurer_->SetUpPrinter( 133 printer_configurer_->SetUpPrinter(
134 printer_ref, 134 printer_ref,
135 base::Bind(&PrinterBackendProxyChromeos::HandlePrinterSetup, 135 base::Bind(&PrinterBackendProxyChromeos::HandlePrinterSetup,
136 weak_factory_.GetWeakPtr(), base::Passed(&printer), cb)); 136 weak_factory_.GetWeakPtr(), base::Passed(&printer), cb));
137 }; 137 };
138 138
139 private: 139 private:
140 void HandlePrinterSetup(std::unique_ptr<chromeos::Printer> printer, 140 void HandlePrinterSetup(std::unique_ptr<chromeos::Printer> printer,
141 const PrinterSetupCallback& cb, 141 const PrinterSetupCallback& cb,
142 chromeos::PrinterSetupResult result) { 142 chromeos::PrinterSetupResult result) {
143 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 143 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
144 144
145 switch (result) { 145 switch (result) {
146 case chromeos::PrinterSetupResult::SUCCESS: 146 case chromeos::PrinterSetupResult::kSuccess:
147 VLOG(1) << "Printer setup successful for " << printer->id() 147 VLOG(1) << "Printer setup successful for " << printer->id()
148 << " fetching properties"; 148 << " fetching properties";
149 prefs_->PrinterInstalled(*printer); 149 prefs_->PrinterInstalled(*printer);
150 150
151 // fetch settings on the blocking pool and invoke callback. 151 // fetch settings on the blocking pool and invoke callback.
152 FetchCapabilities(std::move(printer), cb); 152 FetchCapabilities(std::move(printer), cb);
153 return; 153 return;
154 case chromeos::PrinterSetupResult::PPD_NOT_FOUND: 154 case chromeos::PrinterSetupResult::kPpdNotFound:
155 LOG(WARNING) << "Could not find PPD. Check printer configuration."; 155 LOG(WARNING) << "Could not find PPD. Check printer configuration.";
156 // Prompt user to update configuration. 156 // Prompt user to update configuration.
157 // TODO(skau): Fill me in 157 // TODO(skau): Fill me in
158 break; 158 break;
159 case chromeos::PrinterSetupResult::PPD_UNRETRIEVABLE: 159 case chromeos::PrinterSetupResult::kPpdUnretrievable:
160 LOG(WARNING) << "Could not download PPD. Check Internet connection."; 160 LOG(WARNING) << "Could not download PPD. Check Internet connection.";
161 // Could not download PPD. Connect to Internet. 161 // Could not download PPD. Connect to Internet.
162 // TODO(skau): Fill me in 162 // TODO(skau): Fill me in
163 break; 163 break;
164 case chromeos::PrinterSetupResult::PRINTER_UNREACHABLE: 164 case chromeos::PrinterSetupResult::kPrinterUnreachable:
165 case chromeos::PrinterSetupResult::DBUS_ERROR: 165 case chromeos::PrinterSetupResult::kDbusError:
166 case chromeos::PrinterSetupResult::PPD_TOO_LARGE: 166 case chromeos::PrinterSetupResult::kPpdTooLarge:
167 case chromeos::PrinterSetupResult::INVALID_PPD: 167 case chromeos::PrinterSetupResult::kInvalidPpd:
168 case chromeos::PrinterSetupResult::FATAL_ERROR: 168 case chromeos::PrinterSetupResult::kFatalError:
169 LOG(ERROR) << "Unexpected error in printer setup." << result; 169 LOG(ERROR) << "Unexpected error in printer setup." << result;
170 break; 170 break;
171 } 171 }
172 172
173 // TODO(skau): Open printer settings if this is resolvable. 173 // TODO(skau): Open printer settings if this is resolvable.
174 cb.Run(nullptr); 174 cb.Run(nullptr);
175 } 175 }
176 176
177 chromeos::PrintersManager* prefs_; 177 chromeos::PrintersManager* prefs_;
178 scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_; 178 scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_;
179 std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer_; 179 std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer_;
180 base::WeakPtrFactory<PrinterBackendProxyChromeos> weak_factory_; 180 base::WeakPtrFactory<PrinterBackendProxyChromeos> weak_factory_;
181 181
182 DISALLOW_COPY_AND_ASSIGN(PrinterBackendProxyChromeos); 182 DISALLOW_COPY_AND_ASSIGN(PrinterBackendProxyChromeos);
183 }; 183 };
184 184
185 } // namespace 185 } // namespace
186 186
187 std::unique_ptr<PrinterBackendProxy> PrinterBackendProxy::Create( 187 std::unique_ptr<PrinterBackendProxy> PrinterBackendProxy::Create(
188 Profile* profile) { 188 Profile* profile) {
189 return base::MakeUnique<PrinterBackendProxyChromeos>(profile); 189 return base::MakeUnique<PrinterBackendProxyChromeos>(profile);
190 } 190 }
191 191
192 } // namespace printing 192 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698