| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extensions_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_tabs_module.h" | 9 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/common/extensions/extension_action.h" | 13 #include "chrome/common/extensions/extension_action.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 browser_->OpenURL(extension->GetHomepageURL(), GURL(), | 110 browser_->OpenURL(extension->GetHomepageURL(), GURL(), |
| 111 NEW_FOREGROUND_TAB, PageTransition::LINK); | 111 NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 112 break; | 112 break; |
| 113 } | 113 } |
| 114 case CONFIGURE: | 114 case CONFIGURE: |
| 115 DCHECK(!extension->options_url().is_empty()); | 115 DCHECK(!extension->options_url().is_empty()); |
| 116 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension, | 116 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension, |
| 117 browser_); | 117 browser_); |
| 118 break; | 118 break; |
| 119 case HIDE: { | 119 case HIDE: { |
| 120 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 120 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 121 extension_service->SetBrowserActionVisibility(extension, false); | 121 extension_service->SetBrowserActionVisibility(extension, false); |
| 122 break; | 122 break; |
| 123 } | 123 } |
| 124 case DISABLE: { | 124 case DISABLE: { |
| 125 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 125 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 126 extension_service->DisableExtension(extension_id_); | 126 extension_service->DisableExtension(extension_id_); |
| 127 break; | 127 break; |
| 128 } | 128 } |
| 129 case UNINSTALL: { | 129 case UNINSTALL: { |
| 130 AddRef(); // Balanced in InstallUIProceed and InstallUIAbort. | 130 AddRef(); // Balanced in InstallUIProceed and InstallUIAbort. |
| 131 install_ui_.reset(new ExtensionInstallUI(profile_)); | 131 install_ui_.reset(new ExtensionInstallUI(profile_)); |
| 132 install_ui_->ConfirmUninstall(this, extension); | 132 install_ui_->ConfirmUninstall(this, extension); |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 case MANAGE: { | 135 case MANAGE: { |
| 136 browser_->OpenURL(GURL(chrome::kChromeUIExtensionsURL), GURL(), | 136 browser_->OpenURL(GURL(chrome::kChromeUIExtensionsURL), GURL(), |
| 137 SINGLETON_TAB, PageTransition::LINK); | 137 SINGLETON_TAB, PageTransition::LINK); |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 case INSPECT_POPUP: { | 140 case INSPECT_POPUP: { |
| 141 delegate_->InspectPopup(extension_action_); | 141 delegate_->InspectPopup(extension_action_); |
| 142 break; | 142 break; |
| 143 } | 143 } |
| 144 default: | 144 default: |
| 145 NOTREACHED() << "Unknown option"; | 145 NOTREACHED() << "Unknown option"; |
| 146 break; | 146 break; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ExtensionContextMenuModel::InstallUIProceed() { | 150 void ExtensionContextMenuModel::InstallUIProceed() { |
| 151 if (GetExtension()) | 151 if (GetExtension()) |
| 152 profile_->GetExtensionsService()->UninstallExtension(extension_id_, false); | 152 profile_->GetExtensionService()->UninstallExtension(extension_id_, false); |
| 153 | 153 |
| 154 Release(); | 154 Release(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ExtensionContextMenuModel::InstallUIAbort() { | 157 void ExtensionContextMenuModel::InstallUIAbort() { |
| 158 Release(); | 158 Release(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 const Extension* ExtensionContextMenuModel::GetExtension() const { | 161 const Extension* ExtensionContextMenuModel::GetExtension() const { |
| 162 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 162 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 163 return extension_service->GetExtensionById(extension_id_, false); | 163 return extension_service->GetExtensionById(extension_id_, false); |
| 164 } | 164 } |
| OLD | NEW |