Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chromeos/ui/screensaver_extension_dialog.h" | 5 #include "chrome/browser/chromeos/ui/screensaver_extension_dialog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_helper.h" | 10 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_helper.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 ScreensaverExtensionDialog::ScreensaverExtensionDialog() | 53 ScreensaverExtensionDialog::ScreensaverExtensionDialog() |
| 54 : screensaver_extension_(NULL), | 54 : screensaver_extension_(NULL), |
| 55 loading_extension_(false) { | 55 loading_extension_(false) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ScreensaverExtensionDialog::LoadExtension() { | 58 void ScreensaverExtensionDialog::LoadExtension() { |
| 59 // If the helper is not initialized, call us again when it is. | 59 // If the helper is not initialized, call us again when it is. |
| 60 // We can't get the screensaver path till the helper is ready. | 60 // We can't get the screensaver path till the helper is ready. |
| 61 if (!chromeos::KioskModeHelper::Get()->is_initialized()) { | 61 if (!chromeos::KioskModeHelper::Get()->is_initialized()) { |
| 62 chromeos::KioskModeHelper::Get()->Initialize( | 62 chromeos::KioskModeHelper::Get()->Initialize( |
| 63 base::Bind(&ScreensaverExtensionDialog::LoadExtension, | 63 base::Bind(&ScreensaverExtensionDialog::LoadExtension, |
| 64 base::Unretained(this))); | 64 base::Unretained(this))); |
|
Mattias Nissler (ping if slow)
2012/03/16 09:56:46
How do you ensure that the dialog object is till a
rkc
2012/03/19 23:59:48
g_instance is alive for the lifetime of chrome; so
| |
| 65 return; | 65 return; |
| 66 } | 66 } |
| 67 | 67 |
| 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 69 std::string error; | 69 std::string error; |
| 70 | 70 |
| 71 scoped_refptr<Extension> screensaver_extension = | 71 scoped_refptr<Extension> screensaver_extension = |
| 72 extension_file_util::LoadExtension( | 72 extension_file_util::LoadExtension( |
| 73 FilePath(chromeos::KioskModeHelper::Get()->GetScreensaverPath()), | 73 FilePath(chromeos::KioskModeHelper::Get()->GetScreensaverPath()), |
| 74 Extension::COMPONENT, | 74 Extension::COMPONENT, |
| 75 Extension::NO_FLAGS, | 75 Extension::NO_FLAGS, |
| 76 &error); | 76 &error); |
| 77 | 77 |
| 78 if (!screensaver_extension) { | 78 if (!screensaver_extension) { |
| 79 LOG(ERROR) << "Could not load screensaver extension from: " << | 79 LOG(ERROR) << "Could not load screensaver extension from: " |
| 80 chromeos::KioskModeHelper::Get()->GetScreensaverPath(); | 80 << chromeos::KioskModeHelper::Get()->GetScreensaverPath(); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 | 83 |
| 84 BrowserThread::PostTask(BrowserThread::UI, | 84 BrowserThread::PostTask(BrowserThread::UI, |
| 85 FROM_HERE, | 85 FROM_HERE, |
| 86 base::Bind( | 86 base::Bind( |
| 87 &ScreensaverExtensionDialog::SetExtensionAndShow, | 87 &ScreensaverExtensionDialog::SetExtensionAndShow, |
| 88 base::Unretained(this), | 88 base::Unretained(this), |
| 89 screensaver_extension)); | 89 screensaver_extension)); |
| 90 } | 90 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 base::Unretained(this))); | 157 base::Unretained(this))); |
| 158 dialog->Close(); | 158 dialog->Close(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ScreensaverExtensionDialog::ReloadAndShow() { | 161 void ScreensaverExtensionDialog::ReloadAndShow() { |
| 162 ProfileManager::GetDefaultProfile()->GetExtensionService()->ReloadExtension( | 162 ProfileManager::GetDefaultProfile()->GetExtensionService()->ReloadExtension( |
| 163 screensaver_extension_->id()); | 163 screensaver_extension_->id()); |
| 164 | 164 |
| 165 Show(); | 165 Show(); |
| 166 } | 166 } |
| OLD | NEW |