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/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/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/common/extensions/api/icons/icons_handler.h" | 13 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
| 16 #include "chrome/common/extensions/extension_icon_set.h" | 16 #include "chrome/common/extensions/extension_icon_set.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "extensions/common/extension_resource.h" | 19 #include "extensions/common/extension_resource.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 | 24 |
| 25 #if defined(ENABLE_MANAGED_USERS) | 25 #if defined(ENABLE_MANAGED_USERS) |
| 26 #include "chrome/browser/managed_mode/managed_user_service.h" | 26 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 27 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 27 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
|
Bernhard Bauer
2013/03/27 15:48:14
Include this unconditionally.
Adrian Kuegel
2013/03/27 16:17:43
Done.
| |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // Returns pixel size under maximal scale factor for the icon whose device | 33 // Returns pixel size under maximal scale factor for the icon whose device |
| 33 // independent size is |size_in_dip| | 34 // independent size is |size_in_dip| |
| 34 int GetSizeForMaxScaleFactor(int size_in_dip) { | 35 int GetSizeForMaxScaleFactor(int size_in_dip) { |
| 35 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); | 36 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); |
| 36 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); | 37 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); |
| 37 | 38 |
| (...skipping 105 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 |