| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/extension_tabs_module.h" | 10 #include "chrome/browser/extensions/extension_tabs_module.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { | 69 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { |
| 70 if (command_id == CONFIGURE) { | 70 if (command_id == CONFIGURE) { |
| 71 return extension_->options_url().spec().length() > 0; | 71 return extension_->options_url().spec().length() > 0; |
| 72 } else if (command_id == NAME) { | 72 } else if (command_id == NAME) { |
| 73 // The NAME links to the gallery page, which only makes sense if Google is | 73 // The NAME links to the gallery page, which only makes sense if Google is |
| 74 // hosting the extension. For other 3rd party extensions we don't have a | 74 // hosting the extension. For other 3rd party extensions we don't have a |
| 75 // homepage url, so we just disable this menu item on those cases, at least | 75 // homepage url, so we just disable this menu item on those cases, at least |
| 76 // for now. | 76 // for now. |
| 77 return extension_->update_url().DomainIs("google.com"); | 77 return extension_->GalleryUrl().is_valid(); |
| 78 } else if (command_id == INSPECT_POPUP) { | 78 } else if (command_id == INSPECT_POPUP) { |
| 79 TabContents* contents = browser_->GetSelectedTabContents(); | 79 TabContents* contents = browser_->GetSelectedTabContents(); |
| 80 if (!contents) | 80 if (!contents) |
| 81 return false; | 81 return false; |
| 82 | 82 |
| 83 return extension_action_->HasPopup(ExtensionTabUtil::GetTabId(contents)); | 83 return extension_action_->HasPopup(ExtensionTabUtil::GetTabId(contents)); |
| 84 } | 84 } |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool ExtensionContextMenuModel::GetAcceleratorForCommandId( | 88 bool ExtensionContextMenuModel::GetAcceleratorForCommandId( |
| 89 int command_id, menus::Accelerator* accelerator) { | 89 int command_id, menus::Accelerator* accelerator) { |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ExtensionContextMenuModel::ExecuteCommand(int command_id) { | 93 void ExtensionContextMenuModel::ExecuteCommand(int command_id) { |
| 94 switch (command_id) { | 94 switch (command_id) { |
| 95 case NAME: { | 95 case NAME: { |
| 96 GURL url(std::string(extension_urls::kGalleryBrowsePrefix) + | 96 browser_->OpenURL(extension_->GalleryUrl(), GURL(), |
| 97 std::string("/detail/") + extension_->id()); | 97 NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 98 browser_->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | |
| 99 break; | 98 break; |
| 100 } | 99 } |
| 101 case CONFIGURE: | 100 case CONFIGURE: |
| 102 DCHECK(!extension_->options_url().is_empty()); | 101 DCHECK(!extension_->options_url().is_empty()); |
| 103 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension_, | 102 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension_, |
| 104 browser_); | 103 browser_); |
| 105 break; | 104 break; |
| 106 case DISABLE: { | 105 case DISABLE: { |
| 107 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 106 ExtensionsService* extension_service = profile_->GetExtensionsService(); |
| 108 extension_service->DisableExtension(extension_->id()); | 107 extension_service->DisableExtension(extension_->id()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 134 | 133 |
| 135 std::string id = extension_->id(); | 134 std::string id = extension_->id(); |
| 136 profile_->GetExtensionsService()->UninstallExtension(id, false); | 135 profile_->GetExtensionsService()->UninstallExtension(id, false); |
| 137 | 136 |
| 138 Release(); | 137 Release(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void ExtensionContextMenuModel::InstallUIAbort() { | 140 void ExtensionContextMenuModel::InstallUIAbort() { |
| 142 Release(); | 141 Release(); |
| 143 } | 142 } |
| OLD | NEW |