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

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 2858113003: Enable device-wide EAP-TLS networks (Closed)
Patch Set: Addressed comments (and accidental rebase). 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/chromeos/chrome_browser_main_chromeos.h" 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 #include "components/user_manager/user.h" 139 #include "components/user_manager/user.h"
140 #include "components/user_manager/user_manager.h" 140 #include "components/user_manager/user_manager.h"
141 #include "components/user_manager/user_names.h" 141 #include "components/user_manager/user_names.h"
142 #include "components/version_info/version_info.h" 142 #include "components/version_info/version_info.h"
143 #include "components/wallpaper/wallpaper_manager_base.h" 143 #include "components/wallpaper/wallpaper_manager_base.h"
144 #include "content/public/browser/browser_thread.h" 144 #include "content/public/browser/browser_thread.h"
145 #include "content/public/browser/media_capture_devices.h" 145 #include "content/public/browser/media_capture_devices.h"
146 #include "content/public/browser/notification_service.h" 146 #include "content/public/browser/notification_service.h"
147 #include "content/public/common/content_switches.h" 147 #include "content/public/common/content_switches.h"
148 #include "content/public/common/main_function_params.h" 148 #include "content/public/common/main_function_params.h"
149 #include "crypto/nss_util_internal.h"
149 #include "dbus/object_path.h" 150 #include "dbus/object_path.h"
150 #include "device/bluetooth/bluetooth_adapter_factory.h" 151 #include "device/bluetooth/bluetooth_adapter_factory.h"
151 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 152 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
152 #include "media/audio/sounds/sounds_manager.h" 153 #include "media/audio/sounds/sounds_manager.h"
153 #include "net/base/network_change_notifier.h" 154 #include "net/base/network_change_notifier.h"
155 #include "net/cert/nss_cert_database_chromeos.h"
154 #include "net/url_request/url_request.h" 156 #include "net/url_request/url_request.h"
155 #include "net/url_request/url_request_context_getter.h" 157 #include "net/url_request/url_request_context_getter.h"
156 #include "printing/backend/print_backend.h" 158 #include "printing/backend/print_backend.h"
157 #include "rlz/features/features.h" 159 #include "rlz/features/features.h"
158 #include "third_party/cros_system_api/dbus/service_constants.h" 160 #include "third_party/cros_system_api/dbus/service_constants.h"
159 #include "ui/base/ime/chromeos/ime_keyboard.h" 161 #include "ui/base/ime/chromeos/ime_keyboard.h"
160 #include "ui/base/ime/chromeos/input_method_manager.h" 162 #include "ui/base/ime/chromeos/input_method_manager.h"
161 #include "ui/base/touch/touch_device.h" 163 #include "ui/base/touch/touch_device.h"
162 #include "ui/chromeos/events/event_rewriter_chromeos.h" 164 #include "ui/chromeos/events/event_rewriter_chromeos.h"
163 #include "ui/chromeos/events/pref_names.h" 165 #include "ui/chromeos/events/pref_names.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 std::unique_ptr<CrosDBusService> cros_dbus_service_; 360 std::unique_ptr<CrosDBusService> cros_dbus_service_;
359 361
360 std::unique_ptr<CrosDBusService> proxy_resolution_service_; 362 std::unique_ptr<CrosDBusService> proxy_resolution_service_;
361 std::unique_ptr<CrosDBusService> kiosk_info_service_; 363 std::unique_ptr<CrosDBusService> kiosk_info_service_;
362 364
363 std::unique_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_; 365 std::unique_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_;
364 366
365 DISALLOW_COPY_AND_ASSIGN(DBusServices); 367 DISALLOW_COPY_AND_ASSIGN(DBusServices);
366 }; 368 };
367 369
370 // Initializes a global NSSCertDatabase for the system token and starts
371 // CertLoader with that database.
372 class SystemTokenCertDBInitializer {
373 public:
374 // Entry point, called on UI thread.
375 void Initialize() {
376 content::BrowserThread::PostTask(
377 content::BrowserThread::IO, FROM_HERE,
378 base::BindOnce(&SystemTokenCertDBInitializer::GetSystemSlotOnIOThread,
379 base::Unretained(this)));
emaxx 2017/05/11 02:57:45 It seems to be unsafe to use Unretained(this) thro
pmarko 2017/05/11 11:49:17 You are right, this could get destroyed if we clos
380 }
381
382 private:
383 // Called on IO Thread, initiates retrieval of system slot.
384 void GetSystemSlotOnIOThread() {
385 auto callback =
386 base::Bind(&SystemTokenCertDBInitializer::GotSystemSlotOnIOThread,
387 base::Unretained(this));
388 crypto::ScopedPK11Slot system_nss_slot =
emaxx 2017/05/11 02:57:46 nit: #include "crypto/scoped_nss_types.h"
pmarko 2017/05/11 11:49:17 Done.
389 crypto::GetSystemNSSKeySlot(callback);
390 if (system_nss_slot) {
391 callback.Run(std::move(system_nss_slot));
392 }
393 }
394
395 // Called on IO Thread when the system slot has been retrieved.
396 void GotSystemSlotOnIOThread(crypto::ScopedPK11Slot system_slot) {
397 content::BrowserThread::PostTask(
398 content::BrowserThread::UI, FROM_HERE,
399 base::BindOnce(&SystemTokenCertDBInitializer::InitializeDatabase,
400 base::Unretained(this), std::move(system_slot)));
401 }
402
403 // Initializes the global system token NSSCertDatabase with |system_slot|.
404 // Also starts CertLoader with the system token database.
405 void InitializeDatabase(crypto::ScopedPK11Slot system_slot) {
406 crypto::ScopedPK11Slot system_slot_copy =
407 crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_slot.get()));
408 auto database = base::MakeUnique<net::NSSCertDatabaseChromeOS>(
409 std::move(system_slot), crypto::ScopedPK11Slot());
emaxx 2017/05/11 02:57:46 nit: I'd prefer having some hints here for what th
pmarko 2017/05/11 11:49:17 Done.
410 database->SetSystemSlot(std::move(system_slot_copy));
emaxx 2017/05/11 02:57:46 I think this trick with passing the same slot twic
pmarko 2017/05/11 11:49:17 Done.
411 system_token_cert_database_ = std::move(database);
412
413 CertLoader::Get()->StartWithSystemNSSDB(system_token_cert_database_.get());
414 }
415
416 // Global NSSCertDatabase which sees the system token.
417 std::unique_ptr<net::NSSCertDatabase> system_token_cert_database_;
emaxx 2017/05/11 02:57:45 nit: #include "net/cert/nss_cert_database.h"
pmarko 2017/05/11 11:49:17 Done.
418 };
419
368 } // namespace internal 420 } // namespace internal
369 421
370 // ChromeBrowserMainPartsChromeos ---------------------------------------------- 422 // ChromeBrowserMainPartsChromeos ----------------------------------------------
371 423
372 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( 424 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos(
373 const content::MainFunctionParams& parameters) 425 const content::MainFunctionParams& parameters)
374 : ChromeBrowserMainPartsLinux(parameters) { 426 : ChromeBrowserMainPartsLinux(parameters) {
375 } 427 }
376 428
377 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { 429 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 515 }
464 516
465 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. 517 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun.
466 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. 518 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads.
467 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { 519 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
468 // Set the crypto thread after the IO thread has been created/started. 520 // Set the crypto thread after the IO thread has been created/started.
469 TPMTokenLoader::Get()->SetCryptoTaskRunner( 521 TPMTokenLoader::Get()->SetCryptoTaskRunner(
470 content::BrowserThread::GetTaskRunnerForThread( 522 content::BrowserThread::GetTaskRunnerForThread(
471 content::BrowserThread::IO)); 523 content::BrowserThread::IO));
472 524
525 // Initialize NSS database for system token.
526 TPMTokenLoader::Get()->EnsureStarted();
527 system_token_certdb_initializer_ =
528 base::MakeUnique<internal::SystemTokenCertDBInitializer>();
529 system_token_certdb_initializer_->Initialize();
530
473 CrasAudioHandler::Initialize( 531 CrasAudioHandler::Initialize(
474 new AudioDevicesPrefHandlerImpl(g_browser_process->local_state())); 532 new AudioDevicesPrefHandlerImpl(g_browser_process->local_state()));
475 533
476 content::MediaCaptureDevices::GetInstance()->AddVideoCaptureObserver( 534 content::MediaCaptureDevices::GetInstance()->AddVideoCaptureObserver(
477 CrasAudioHandler::Get()); 535 CrasAudioHandler::Get());
478 536
479 quirks::QuirksManager::Initialize( 537 quirks::QuirksManager::Initialize(
480 std::unique_ptr<quirks::QuirksManager::Delegate>( 538 std::unique_ptr<quirks::QuirksManager::Delegate>(
481 new quirks::QuirksManagerDelegateImpl()), 539 new quirks::QuirksManagerDelegateImpl()),
482 content::BrowserThread::GetBlockingPool(), 540 content::BrowserThread::GetBlockingPool(),
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1059
1002 ChromeBrowserMainPartsLinux::PostDestroyThreads(); 1060 ChromeBrowserMainPartsLinux::PostDestroyThreads();
1003 1061
1004 // Destroy DeviceSettingsService after g_browser_process. 1062 // Destroy DeviceSettingsService after g_browser_process.
1005 DeviceSettingsService::Shutdown(); 1063 DeviceSettingsService::Shutdown();
1006 1064
1007 chromeos::ShutdownCloseTracking(); 1065 chromeos::ShutdownCloseTracking();
1008 } 1066 }
1009 1067
1010 } // namespace chromeos 1068 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698