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

Side by Side Diff: cloud_print/service/win/cloud_print_service_config.cc

Issue 1408623002: Add cloud_print to the GN build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlapp.h> // NOLINT 6 #include <atlapp.h> // NOLINT
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/message_loop/message_pump_dispatcher.h" 14 #include "base/message_loop/message_pump_dispatcher.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "cloud_print/common/win/cloud_print_utils.h" 19 #include "cloud_print/common/win/cloud_print_utils.h"
20 #include "cloud_print/resources.h" 20 #include "cloud_print/service/resources.h"
21 #include "cloud_print/service/service_state.h" 21 #include "cloud_print/service/service_state.h"
22 #include "cloud_print/service/win/chrome_launcher.h" 22 #include "cloud_print/service/win/chrome_launcher.h"
23 #include "cloud_print/service/win/service_controller.h" 23 #include "cloud_print/service/win/service_controller.h"
24 #include "cloud_print/service/win/service_utils.h" 24 #include "cloud_print/service/win/service_utils.h"
25 #include "cloud_print/service/win/setup_listener.h" 25 #include "cloud_print/service/win/setup_listener.h"
26 26
27 using cloud_print::LoadLocalString; 27 using cloud_print::LoadLocalString;
28 using cloud_print::GetErrorMessage; 28 using cloud_print::GetErrorMessage;
29 29
30 class SetupDialog : public base::RefCounted<SetupDialog>, 30 class SetupDialog : public base::RefCounted<SetupDialog>,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 GetDlgItem(IDC_INSTALL).EnableWindow(FALSE); 290 GetDlgItem(IDC_INSTALL).EnableWindow(FALSE);
291 GetDlgItem(IDC_USER).EnableWindow(FALSE); 291 GetDlgItem(IDC_USER).EnableWindow(FALSE);
292 GetDlgItem(IDC_PASSWORD).EnableWindow(FALSE); 292 GetDlgItem(IDC_PASSWORD).EnableWindow(FALSE);
293 GetDlgItem(IDC_LOGGING).EnableWindow(FALSE); 293 GetDlgItem(IDC_LOGGING).EnableWindow(FALSE);
294 } 294 }
295 295
296 base::string16 SetupDialog::GetDlgItemText(int id) const { 296 base::string16 SetupDialog::GetDlgItemText(int id) const {
297 const ATL::CWindow& item = GetDlgItem(id); 297 const ATL::CWindow& item = GetDlgItem(id);
298 size_t length = item.GetWindowTextLength(); 298 size_t length = item.GetWindowTextLength();
299 base::string16 result(length + 1, L'\0'); 299 base::string16 result(length + 1, L'\0');
300 result.resize(item.GetWindowText(&result[0], result.size())); 300 result.resize(item.GetWindowText(&result[0],
301 static_cast<int>(result.size())));
301 return result; 302 return result;
302 } 303 }
303 304
304 base::string16 SetupDialog::GetUser() const { 305 base::string16 SetupDialog::GetUser() const {
305 return GetDlgItemText(IDC_USER); 306 return GetDlgItemText(IDC_USER);
306 } 307 }
307 308
308 base::string16 SetupDialog::GetPassword() const { 309 base::string16 SetupDialog::GetPassword() const {
309 return GetDlgItemText(IDC_PASSWORD); 310 return GetDlgItemText(IDC_PASSWORD);
310 } 311 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (service_state.FromString(contents)) 390 if (service_state.FromString(contents))
390 proxy_id = service_state.proxy_id(); 391 proxy_id = service_state.proxy_id();
391 } 392 }
392 PostUITask(base::Bind(&SetupDialog::AskToCloseChrome, this)); 393 PostUITask(base::Bind(&SetupDialog::AskToCloseChrome, this));
393 contents = ChromeLauncher::CreateServiceStateFile(proxy_id, setup.printers()); 394 contents = ChromeLauncher::CreateServiceStateFile(proxy_id, setup.printers());
394 395
395 if (contents.empty()) 396 if (contents.empty())
396 return ShowError(IDS_ERROR_FAILED_CREATE_CONFIG); 397 return ShowError(IDS_ERROR_FAILED_CREATE_CONFIG);
397 398
398 size_t written = base::WriteFile(file, contents.c_str(), 399 size_t written = base::WriteFile(file, contents.c_str(),
399 contents.size()); 400 static_cast<int>(contents.size()));
400 if (written != contents.size()) { 401 if (written != contents.size()) {
401 DWORD last_error = GetLastError(); 402 DWORD last_error = GetLastError();
402 if (!last_error) 403 if (!last_error)
403 return ShowError(IDS_ERROR_FAILED_CREATE_CONFIG); 404 return ShowError(IDS_ERROR_FAILED_CREATE_CONFIG);
404 return ShowError(HRESULT_FROM_WIN32(last_error)); 405 return ShowError(HRESULT_FROM_WIN32(last_error));
405 } 406 }
406 407
407 hr = controller_.InstallConnectorService(user, password, base::FilePath(), 408 hr = controller_.InstallConnectorService(user, password, base::FilePath(),
408 enable_logging); 409 enable_logging);
409 if (FAILED(hr)) 410 if (FAILED(hr))
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 454
454 base::MessageLoopForUI loop; 455 base::MessageLoopForUI loop;
455 scoped_refptr<SetupDialog> dialog(new SetupDialog()); 456 scoped_refptr<SetupDialog> dialog(new SetupDialog());
456 dialog->Create(NULL); 457 dialog->Create(NULL);
457 dialog->ShowWindow(SW_SHOW); 458 dialog->ShowWindow(SW_SHOW);
458 SetupDialog::Dispatcher dispatcher(dialog.get()); 459 SetupDialog::Dispatcher dispatcher(dialog.get());
459 base::RunLoop run_loop(&dispatcher); 460 base::RunLoop run_loop(&dispatcher);
460 run_loop.Run(); 461 run_loop.Run();
461 return 0; 462 return 0;
462 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698