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_requirements_checker.h" | 9 #include "chrome/browser/extensions/chrome_requirements_checker.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ManagementSetEnabledFunctionInstallPromptDelegate); | 68 DISALLOW_COPY_AND_ASSIGN(ManagementSetEnabledFunctionInstallPromptDelegate); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 class ManagementUninstallFunctionUninstallDialogDelegate | 71 class ManagementUninstallFunctionUninstallDialogDelegate |
| 72 : public extensions::ExtensionUninstallDialog::Delegate, | 72 : public extensions::ExtensionUninstallDialog::Delegate, |
| 73 public extensions::UninstallDialogDelegate { | 73 public extensions::UninstallDialogDelegate { |
| 74 public: | 74 public: |
| 75 ManagementUninstallFunctionUninstallDialogDelegate( | 75 ManagementUninstallFunctionUninstallDialogDelegate( |
| 76 extensions::ManagementUninstallFunctionBase* function, | 76 extensions::ManagementUninstallFunctionBase* function, |
| 77 const std::string& target_extension_id) | 77 const extensions::Extension* target_extension, |
|
not at google - send to devlin
2015/02/25 23:55:58
Well, technically you can read the target extensio
Devlin
2015/02/26 00:19:54
Agreed, the function is a lot of state. But we ne
| |
| 78 bool show_programmatic_uninstall_ui) | |
| 78 : function_(function) { | 79 : function_(function) { |
| 79 const extensions::Extension* target_extension = | 80 content::WebContents* web_contents = function->GetSenderWebContents(); |
| 80 extensions::ExtensionRegistry::Get(function->browser_context()) | |
| 81 ->GetExtensionById(target_extension_id, | |
| 82 extensions::ExtensionRegistry::EVERYTHING); | |
| 83 content::WebContents* web_contents = function->GetAssociatedWebContents(); | |
| 84 extension_uninstall_dialog_.reset( | 81 extension_uninstall_dialog_.reset( |
| 85 extensions::ExtensionUninstallDialog::Create( | 82 extensions::ExtensionUninstallDialog::Create( |
| 86 Profile::FromBrowserContext(function->browser_context()), | 83 Profile::FromBrowserContext(function->browser_context()), |
| 87 web_contents ? web_contents->GetTopLevelNativeWindow() : NULL, | 84 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr, |
| 88 this)); | 85 this)); |
| 89 if (function->extension_id() != target_extension_id) { | 86 if (show_programmatic_uninstall_ui) { |
| 90 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( | 87 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( |
| 91 target_extension, function->extension()); | 88 target_extension, function->extension()); |
| 92 } else { | 89 } else { |
| 93 // If this is a self uninstall, show the generic uninstall dialog. | |
| 94 extension_uninstall_dialog_->ConfirmUninstall(target_extension); | 90 extension_uninstall_dialog_->ConfirmUninstall(target_extension); |
| 95 } | 91 } |
| 96 } | 92 } |
| 97 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} | 93 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} |
| 98 | 94 |
| 99 // ExtensionUninstallDialog::Delegate implementation. | 95 // ExtensionUninstallDialog::Delegate implementation. |
| 100 void ExtensionUninstallAccepted() override { | 96 void ExtensionUninstallAccepted() override { |
| 101 function_->ExtensionUninstallAccepted(); | 97 function_->ExtensionUninstallAccepted(); |
| 102 } | 98 } |
| 103 void ExtensionUninstallCanceled() override { | 99 void ExtensionUninstallCanceled() override { |
| 104 function_->ExtensionUninstallCanceled(); | 100 function_->ExtensionUninstallCanceled(); |
| 105 } | 101 } |
| 106 | 102 |
| 107 protected: | 103 private: |
| 108 extensions::ManagementUninstallFunctionBase* function_; | 104 extensions::ManagementUninstallFunctionBase* function_; |
| 109 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 105 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(ManagementUninstallFunctionUninstallDialogDelegate); | |
| 110 }; | 108 }; |
| 111 | 109 |
| 112 class ChromeAppForLinkDelegate : public extensions::AppForLinkDelegate { | 110 class ChromeAppForLinkDelegate : public extensions::AppForLinkDelegate { |
| 113 public: | 111 public: |
| 114 ChromeAppForLinkDelegate() {} | 112 ChromeAppForLinkDelegate() {} |
| 115 ~ChromeAppForLinkDelegate() override {} | 113 ~ChromeAppForLinkDelegate() override {} |
| 116 | 114 |
| 117 void OnFaviconForApp( | 115 void OnFaviconForApp( |
| 118 extensions::ManagementGenerateAppForLinkFunction* function, | 116 extensions::ManagementGenerateAppForLinkFunction* function, |
| 119 content::BrowserContext* context, | 117 content::BrowserContext* context, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 } | 207 } |
| 210 | 208 |
| 211 scoped_ptr<extensions::RequirementsChecker> | 209 scoped_ptr<extensions::RequirementsChecker> |
| 212 ChromeManagementAPIDelegate::CreateRequirementsChecker() const { | 210 ChromeManagementAPIDelegate::CreateRequirementsChecker() const { |
| 213 return make_scoped_ptr(new extensions::ChromeRequirementsChecker()); | 211 return make_scoped_ptr(new extensions::ChromeRequirementsChecker()); |
| 214 } | 212 } |
| 215 | 213 |
| 216 scoped_ptr<extensions::UninstallDialogDelegate> | 214 scoped_ptr<extensions::UninstallDialogDelegate> |
| 217 ChromeManagementAPIDelegate::UninstallFunctionDelegate( | 215 ChromeManagementAPIDelegate::UninstallFunctionDelegate( |
| 218 extensions::ManagementUninstallFunctionBase* function, | 216 extensions::ManagementUninstallFunctionBase* function, |
| 219 const std::string& target_extension_id) const { | 217 const extensions::Extension* target_extension, |
| 218 bool show_programmatic_uninstall_ui) const { | |
| 220 return scoped_ptr<extensions::UninstallDialogDelegate>( | 219 return scoped_ptr<extensions::UninstallDialogDelegate>( |
| 221 new ManagementUninstallFunctionUninstallDialogDelegate( | 220 new ManagementUninstallFunctionUninstallDialogDelegate( |
| 222 function, target_extension_id)); | 221 function, target_extension, show_programmatic_uninstall_ui)); |
| 223 } | 222 } |
| 224 | 223 |
| 225 bool ChromeManagementAPIDelegate::CreateAppShortcutFunctionDelegate( | 224 bool ChromeManagementAPIDelegate::CreateAppShortcutFunctionDelegate( |
| 226 extensions::ManagementCreateAppShortcutFunction* function, | 225 extensions::ManagementCreateAppShortcutFunction* function, |
| 227 const extensions::Extension* extension) const { | 226 const extensions::Extension* extension) const { |
| 228 Browser* browser = chrome::FindBrowserWithProfile( | 227 Browser* browser = chrome::FindBrowserWithProfile( |
| 229 Profile::FromBrowserContext(function->browser_context()), | 228 Profile::FromBrowserContext(function->browser_context()), |
| 230 chrome::HOST_DESKTOP_TYPE_NATIVE); | 229 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 231 if (!browser) { | 230 if (!browser) { |
| 232 // Shouldn't happen if we have user gesture. | 231 // Shouldn't happen if we have user gesture. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 310 |
| 312 GURL ChromeManagementAPIDelegate::GetIconURL( | 311 GURL ChromeManagementAPIDelegate::GetIconURL( |
| 313 const extensions::Extension* extension, | 312 const extensions::Extension* extension, |
| 314 int icon_size, | 313 int icon_size, |
| 315 ExtensionIconSet::MatchType match, | 314 ExtensionIconSet::MatchType match, |
| 316 bool grayscale, | 315 bool grayscale, |
| 317 bool* exists) const { | 316 bool* exists) const { |
| 318 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, | 317 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, |
| 319 match, grayscale, exists); | 318 match, grayscale, exists); |
| 320 } | 319 } |
| OLD | NEW |