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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 std::string& target_extension_id) |
| 78 : function_(function) { | 78 : function_(function) { |
| 79 const extensions::Extension* target_extension = | 79 const extensions::Extension* target_extension = |
| 80 extensions::ExtensionRegistry::Get(function->browser_context()) | 80 extensions::ExtensionRegistry::Get(function->browser_context()) |
| 81 ->GetExtensionById(target_extension_id, | 81 ->GetExtensionById(target_extension_id, |
| 82 extensions::ExtensionRegistry::EVERYTHING); | 82 extensions::ExtensionRegistry::EVERYTHING); |
| 83 content::WebContents* web_contents = function->GetAssociatedWebContents(); | 83 content::WebContents* web_contents = function->GetSenderWebContents(); |
| 84 extension_uninstall_dialog_.reset( | 84 extension_uninstall_dialog_.reset( |
| 85 extensions::ExtensionUninstallDialog::Create( | 85 extensions::ExtensionUninstallDialog::Create( |
| 86 Profile::FromBrowserContext(function->browser_context()), | 86 Profile::FromBrowserContext(function->browser_context()), |
| 87 web_contents ? web_contents->GetTopLevelNativeWindow() : NULL, | 87 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr, |
| 88 this)); | 88 this)); |
| 89 if (function->extension_id() != target_extension_id) { | 89 if (function->extension() && |
| 90 function->extension_id() != target_extension_id) { | |
| 90 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( | 91 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( |
| 91 target_extension, function->extension()); | 92 target_extension, function->extension()); |
| 92 } else { | 93 } else { |
| 93 // If this is a self uninstall, show the generic uninstall dialog. | 94 // If this is a self uninstall, or triggered by webui (in which case |
|
not at google - send to devlin
2015/02/25 21:37:57
This decision belongs in the API implementation, n
Devlin
2015/02/25 23:12:47
Done.
| |
| 95 // function->extension() is null), show the generic uninstall dialog. | |
| 94 extension_uninstall_dialog_->ConfirmUninstall(target_extension); | 96 extension_uninstall_dialog_->ConfirmUninstall(target_extension); |
| 95 } | 97 } |
| 96 } | 98 } |
| 97 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} | 99 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} |
| 98 | 100 |
| 99 // ExtensionUninstallDialog::Delegate implementation. | 101 // ExtensionUninstallDialog::Delegate implementation. |
| 100 void ExtensionUninstallAccepted() override { | 102 void ExtensionUninstallAccepted() override { |
| 101 function_->ExtensionUninstallAccepted(); | 103 function_->ExtensionUninstallAccepted(); |
| 102 } | 104 } |
| 103 void ExtensionUninstallCanceled() override { | 105 void ExtensionUninstallCanceled() override { |
| 104 function_->ExtensionUninstallCanceled(); | 106 function_->ExtensionUninstallCanceled(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 protected: | 109 private: |
| 108 extensions::ManagementUninstallFunctionBase* function_; | 110 extensions::ManagementUninstallFunctionBase* function_; |
| 109 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 111 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 112 | |
| 113 DISALLOW_COPY_AND_ASSIGN(ManagementUninstallFunctionUninstallDialogDelegate); | |
| 110 }; | 114 }; |
| 111 | 115 |
| 112 class ChromeAppForLinkDelegate : public extensions::AppForLinkDelegate { | 116 class ChromeAppForLinkDelegate : public extensions::AppForLinkDelegate { |
| 113 public: | 117 public: |
| 114 ChromeAppForLinkDelegate() {} | 118 ChromeAppForLinkDelegate() {} |
| 115 ~ChromeAppForLinkDelegate() override {} | 119 ~ChromeAppForLinkDelegate() override {} |
| 116 | 120 |
| 117 void OnFaviconForApp( | 121 void OnFaviconForApp( |
| 118 extensions::ManagementGenerateAppForLinkFunction* function, | 122 extensions::ManagementGenerateAppForLinkFunction* function, |
| 119 content::BrowserContext* context, | 123 content::BrowserContext* context, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 315 |
| 312 GURL ChromeManagementAPIDelegate::GetIconURL( | 316 GURL ChromeManagementAPIDelegate::GetIconURL( |
| 313 const extensions::Extension* extension, | 317 const extensions::Extension* extension, |
| 314 int icon_size, | 318 int icon_size, |
| 315 ExtensionIconSet::MatchType match, | 319 ExtensionIconSet::MatchType match, |
| 316 bool grayscale, | 320 bool grayscale, |
| 317 bool* exists) const { | 321 bool* exists) const { |
| 318 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, | 322 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, |
| 319 match, grayscale, exists); | 323 match, grayscale, exists); |
| 320 } | 324 } |
| OLD | NEW |