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_->GalleryUrl().is_valid(); | 77 return extension_->update_url().DomainIs("google.com"); |
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 browser_->OpenURL(extension_->GalleryUrl(), GURL(), | 96 GURL url(std::string(extension_urls::kGalleryBrowsePrefix) + |
97 NEW_FOREGROUND_TAB, PageTransition::LINK); | 97 std::string("/detail/") + extension_->id()); |
| 98 browser_->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
98 break; | 99 break; |
99 } | 100 } |
100 case CONFIGURE: | 101 case CONFIGURE: |
101 DCHECK(!extension_->options_url().is_empty()); | 102 DCHECK(!extension_->options_url().is_empty()); |
102 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension_, | 103 profile_->GetExtensionProcessManager()->OpenOptionsPage(extension_, |
103 browser_); | 104 browser_); |
104 break; | 105 break; |
105 case DISABLE: { | 106 case DISABLE: { |
106 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 107 ExtensionsService* extension_service = profile_->GetExtensionsService(); |
107 extension_service->DisableExtension(extension_->id()); | 108 extension_service->DisableExtension(extension_->id()); |
(...skipping 25 matching lines...) Expand all Loading... |
133 | 134 |
134 std::string id = extension_->id(); | 135 std::string id = extension_->id(); |
135 profile_->GetExtensionsService()->UninstallExtension(id, false); | 136 profile_->GetExtensionsService()->UninstallExtension(id, false); |
136 | 137 |
137 Release(); | 138 Release(); |
138 } | 139 } |
139 | 140 |
140 void ExtensionContextMenuModel::InstallUIAbort() { | 141 void ExtensionContextMenuModel::InstallUIAbort() { |
141 Release(); | 142 Release(); |
142 } | 143 } |
OLD | NEW |