Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/settings/chromeos/cups_printers_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/files/file_util.h" | |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/threading/sequenced_task_runner_handle.h" | 15 #include "base/threading/sequenced_task_runner_handle.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h" | 18 #include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h" |
| 18 #include "chrome/browser/download/download_prefs.h" | 19 #include "chrome/browser/download/download_prefs.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 73 |
| 73 return printer_info; | 74 return printer_info; |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace | 77 } // namespace |
| 77 | 78 |
| 78 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui) | 79 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui) |
| 79 : printer_discoverer_(nullptr), | 80 : printer_discoverer_(nullptr), |
| 80 profile_(Profile::FromWebUI(webui)), | 81 profile_(Profile::FromWebUI(webui)), |
| 81 weak_factory_(this) { | 82 weak_factory_(this) { |
| 82 base::FilePath ppd_cache_path; | 83 base::FilePath ppd_cache_path = profile_->GetPath().Append("PPDCache"); |
|
sky
2016/11/15 22:18:37
I think you need FILE_PATH_LITERAL here, or Append
Carlson
2016/11/15 22:25:12
It is chromeos-specific, but no harm in being orth
| |
| 83 CHECK( | 84 if (!base::PathExists(ppd_cache_path) && |
| 84 base::PathService::Get(chrome::DIR_CHROMEOS_PPD_CACHE, &ppd_cache_path)); | 85 !base::CreateDirectory(ppd_cache_path)) { |
| 86 LOG(ERROR) << "Failed to create ppd cache directory " | |
| 87 << ppd_cache_path.MaybeAsASCII(); | |
| 88 } | |
| 85 ppd_provider_ = chromeos::printing::PpdProvider::Create( | 89 ppd_provider_ = chromeos::printing::PpdProvider::Create( |
| 86 google_apis::GetAPIKey(), g_browser_process->system_request_context(), | 90 google_apis::GetAPIKey(), g_browser_process->system_request_context(), |
| 87 content::BrowserThread::GetTaskRunnerForThread( | 91 content::BrowserThread::GetTaskRunnerForThread( |
| 88 content::BrowserThread::FILE), | 92 content::BrowserThread::FILE), |
| 89 chromeos::printing::PpdCache::Create(ppd_cache_path)); | 93 chromeos::printing::PpdCache::Create(ppd_cache_path)); |
| 90 } | 94 } |
| 91 | 95 |
| 92 CupsPrintersHandler::~CupsPrintersHandler() {} | 96 CupsPrintersHandler::~CupsPrintersHandler() {} |
| 93 | 97 |
| 94 void CupsPrintersHandler::RegisterMessages() { | 98 void CupsPrintersHandler::RegisterMessages() { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 *printers_list); | 390 *printers_list); |
| 387 } | 391 } |
| 388 | 392 |
| 389 void CupsPrintersHandler::OnDiscoveryDone() { | 393 void CupsPrintersHandler::OnDiscoveryDone() { |
| 390 CallJavascriptFunction("cr.webUIListenerCallback", | 394 CallJavascriptFunction("cr.webUIListenerCallback", |
| 391 base::StringValue("on-printer-discovery-done")); | 395 base::StringValue("on-printer-discovery-done")); |
| 392 } | 396 } |
| 393 | 397 |
| 394 } // namespace settings | 398 } // namespace settings |
| 395 } // namespace chromeos | 399 } // namespace chromeos |
| OLD | NEW |