Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/api/management/chrome_management_api_delegat e.h" | 5 #include "chrome/browser/extensions/api/management/chrome_management_api_delegat e.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/bookmark_app_helper.h" | 8 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 9 #include "chrome/browser/extensions/chrome_extension_function_details.h" | |
| 9 #include "chrome/browser/extensions/chrome_requirements_checker.h" | 10 #include "chrome/browser/extensions/chrome_requirements_checker.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
| 12 #include "chrome/browser/extensions/launch_util.h" | 13 #include "chrome/browser/extensions/launch_util.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" | 14 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/extensions/app_launch_params.h" | 19 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 71 |
| 71 class ManagementUninstallFunctionUninstallDialogDelegate | 72 class ManagementUninstallFunctionUninstallDialogDelegate |
| 72 : public extensions::ExtensionUninstallDialog::Delegate, | 73 : public extensions::ExtensionUninstallDialog::Delegate, |
| 73 public extensions::UninstallDialogDelegate { | 74 public extensions::UninstallDialogDelegate { |
| 74 public: | 75 public: |
| 75 ManagementUninstallFunctionUninstallDialogDelegate( | 76 ManagementUninstallFunctionUninstallDialogDelegate( |
| 76 extensions::ManagementUninstallFunctionBase* function, | 77 extensions::ManagementUninstallFunctionBase* function, |
| 77 const extensions::Extension* target_extension, | 78 const extensions::Extension* target_extension, |
| 78 bool show_programmatic_uninstall_ui) | 79 bool show_programmatic_uninstall_ui) |
| 79 : function_(function) { | 80 : function_(function) { |
| 80 content::WebContents* web_contents = function->GetSenderWebContents(); | 81 Profile* profile = Profile::FromBrowserContext(function->browser_context()); |
| 82 content::WebContents* web_contents = | |
| 83 ChromeExtensionFunctionDetails(function).GetVisibleWebContents(); | |
|
not at google - send to devlin
2015/07/10 17:02:25
I'd slightly restructure this, to avoid the cast f
| |
| 84 gfx::NativeWindow window = | |
| 85 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr; | |
| 86 | |
| 87 if (!window) { | |
| 88 // This shouldn't happen if we have user gesture. | |
| 89 Browser* browser = | |
| 90 chrome::FindBrowserWithProfile(profile, chrome::GetActiveDesktop()); | |
|
not at google - send to devlin
2015/07/10 17:02:25
You could move this into GetNativeWindowForUI?
| |
| 91 window = browser->window()->GetNativeWindow(); | |
| 92 } | |
| 93 | |
| 81 extension_uninstall_dialog_.reset( | 94 extension_uninstall_dialog_.reset( |
| 82 extensions::ExtensionUninstallDialog::Create( | 95 extensions::ExtensionUninstallDialog::Create(profile, window, this)); |
| 83 Profile::FromBrowserContext(function->browser_context()), | |
| 84 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr, | |
| 85 this)); | |
| 86 if (show_programmatic_uninstall_ui) { | 96 if (show_programmatic_uninstall_ui) { |
| 87 extension_uninstall_dialog_->ConfirmUninstallByExtension( | 97 extension_uninstall_dialog_->ConfirmUninstallByExtension( |
| 88 target_extension, function->extension(), | 98 target_extension, function->extension(), |
| 89 extensions::UNINSTALL_REASON_MANAGEMENT_API); | 99 extensions::UNINSTALL_REASON_MANAGEMENT_API); |
| 90 } else { | 100 } else { |
| 91 extension_uninstall_dialog_->ConfirmUninstall( | 101 extension_uninstall_dialog_->ConfirmUninstall( |
| 92 target_extension, extensions::UNINSTALL_REASON_MANAGEMENT_API); | 102 target_extension, extensions::UNINSTALL_REASON_MANAGEMENT_API); |
| 93 } | 103 } |
| 94 } | 104 } |
| 95 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} | 105 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 | 320 |
| 311 GURL ChromeManagementAPIDelegate::GetIconURL( | 321 GURL ChromeManagementAPIDelegate::GetIconURL( |
| 312 const extensions::Extension* extension, | 322 const extensions::Extension* extension, |
| 313 int icon_size, | 323 int icon_size, |
| 314 ExtensionIconSet::MatchType match, | 324 ExtensionIconSet::MatchType match, |
| 315 bool grayscale, | 325 bool grayscale, |
| 316 bool* exists) const { | 326 bool* exists) const { |
| 317 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, | 327 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, |
| 318 match, grayscale, exists); | 328 match, grayscale, exists); |
| 319 } | 329 } |
| OLD | NEW |