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/extensions/extension_uninstall_dialog.h" | 5 #include "chrome/browser/extensions/extension_uninstall_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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/extensions/image_loader.h" | 10 #include "chrome/browser/extensions/image_loader.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/extensions/api/icons/icons_handler.h" | 14 #include "chrome/common/extensions/api/icons/icons_handler.h" |
14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 16 #include "chrome/common/extensions/extension_constants.h" |
16 #include "chrome/common/extensions/extension_icon_set.h" | 17 #include "chrome/common/extensions/extension_icon_set.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
19 #include "extensions/common/extension_resource.h" | 20 #include "extensions/common/extension_resource.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (state_ == kImageIsLoading) { | 144 if (state_ == kImageIsLoading) { |
144 state_ = kBrowserIsClosing; | 145 state_ = kBrowserIsClosing; |
145 delegate_->ExtensionUninstallCanceled(); | 146 delegate_->ExtensionUninstallCanceled(); |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 #if defined(ENABLE_MANAGED_USERS) | 150 #if defined(ENABLE_MANAGED_USERS) |
150 bool ExtensionUninstallDialog::ShowAuthorizationDialog() { | 151 bool ExtensionUninstallDialog::ShowAuthorizationDialog() { |
151 ManagedUserService* service = | 152 ManagedUserService* service = |
152 ManagedUserServiceFactory::GetForProfile(profile_); | 153 ManagedUserServiceFactory::GetForProfile(profile_); |
153 if (service->ProfileIsManaged() && !service->CanSkipPassphraseDialog()) { | 154 content::WebContents* web_contents = |
154 service->RequestAuthorizationUsingActiveWebContents( | 155 browser_->tab_strip_model()->GetActiveWebContents(); |
155 browser_, | 156 if (service->ProfileIsManaged() && |
| 157 !service->CanSkipPassphraseDialog(web_contents)) { |
| 158 service->RequestAuthorization( |
| 159 web_contents, |
156 base::Bind(&ExtensionUninstallDialog::OnAuthorizationResult, | 160 base::Bind(&ExtensionUninstallDialog::OnAuthorizationResult, |
157 base::Unretained(this))); | 161 base::Unretained(this))); |
158 return true; | 162 return true; |
159 } | 163 } |
| 164 service->AddElevationForExtension(extension_->id()); |
160 return false; | 165 return false; |
161 } | 166 } |
162 | 167 |
163 void ExtensionUninstallDialog::OnAuthorizationResult(bool success) { | 168 void ExtensionUninstallDialog::OnAuthorizationResult(bool success) { |
164 if (success) { | 169 if (success) { |
165 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( | 170 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( |
166 profile_); | 171 profile_); |
167 DCHECK(service); | 172 DCHECK(service); |
168 service->AddElevationForExtension(extension_->id()); | 173 service->AddElevationForExtension(extension_->id()); |
169 delegate_->ExtensionUninstallAccepted(); | 174 delegate_->ExtensionUninstallAccepted(); |
170 } else { | 175 } else { |
171 delegate_->ExtensionUninstallCanceled(); | 176 delegate_->ExtensionUninstallCanceled(); |
172 } | 177 } |
173 } | 178 } |
174 #endif | 179 #endif |
OLD | NEW |