| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { | 63 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { | 67 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { |
| 68 const Extension* extension = this->GetExtension(); | 68 const Extension* extension = this->GetExtension(); |
| 69 if (!extension) | 69 if (!extension) |
| 70 return false; | 70 return false; |
| 71 | 71 |
| 72 if (command_id == CONFIGURE) { | 72 if (command_id == CONFIGURE) { |
| 73 return extension->options_url().spec().length() > 0; | 73 return |
| 74 extensions::ManifestURL::GetOptionsPage(extension).spec().length() > 0; |
| 74 } else if (command_id == NAME) { | 75 } else if (command_id == NAME) { |
| 75 // The NAME links to the Homepage URL. If the extension doesn't have a | 76 // The NAME links to the Homepage URL. If the extension doesn't have a |
| 76 // homepage, we just disable this menu item. | 77 // homepage, we just disable this menu item. |
| 77 return extensions::ManifestURL::GetHomepageURL(extension).is_valid(); | 78 return extensions::ManifestURL::GetHomepageURL(extension).is_valid(); |
| 78 } else if (command_id == INSPECT_POPUP) { | 79 } else if (command_id == INSPECT_POPUP) { |
| 79 WebContents* web_contents = chrome::GetActiveWebContents(browser_); | 80 WebContents* web_contents = chrome::GetActiveWebContents(browser_); |
| 80 if (!web_contents) | 81 if (!web_contents) |
| 81 return false; | 82 return false; |
| 82 | 83 |
| 83 return extension_action_ && | 84 return extension_action_ && |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 | 103 |
| 103 switch (command_id) { | 104 switch (command_id) { |
| 104 case NAME: { | 105 case NAME: { |
| 105 OpenURLParams params(extensions::ManifestURL::GetHomepageURL(extension), | 106 OpenURLParams params(extensions::ManifestURL::GetHomepageURL(extension), |
| 106 Referrer(), NEW_FOREGROUND_TAB, | 107 Referrer(), NEW_FOREGROUND_TAB, |
| 107 content::PAGE_TRANSITION_LINK, false); | 108 content::PAGE_TRANSITION_LINK, false); |
| 108 browser_->OpenURL(params); | 109 browser_->OpenURL(params); |
| 109 break; | 110 break; |
| 110 } | 111 } |
| 111 case CONFIGURE: | 112 case CONFIGURE: |
| 112 DCHECK(!extension->options_url().is_empty()); | 113 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); |
| 113 extensions::ExtensionSystem::Get(profile_)->process_manager()-> | 114 extensions::ExtensionSystem::Get(profile_)->process_manager()-> |
| 114 OpenOptionsPage(extension, browser_); | 115 OpenOptionsPage(extension, browser_); |
| 115 break; | 116 break; |
| 116 case HIDE: { | 117 case HIDE: { |
| 117 ExtensionService* extension_service = | 118 ExtensionService* extension_service = |
| 118 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 119 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 119 extension_service->extension_prefs()-> | 120 extension_service->extension_prefs()-> |
| 120 SetBrowserActionVisibility(extension, false); | 121 SetBrowserActionVisibility(extension, false); |
| 121 break; | 122 break; |
| 122 } | 123 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); | 178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); |
| 178 AddSeparator(ui::NORMAL_SEPARATOR); | 179 AddSeparator(ui::NORMAL_SEPARATOR); |
| 179 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); | 180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); |
| 180 } | 181 } |
| 181 | 182 |
| 182 const Extension* ExtensionContextMenuModel::GetExtension() const { | 183 const Extension* ExtensionContextMenuModel::GetExtension() const { |
| 183 ExtensionService* extension_service = | 184 ExtensionService* extension_service = |
| 184 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 185 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 185 return extension_service->GetExtensionById(extension_id_, false); | 186 return extension_service->GetExtensionById(extension_id_, false); |
| 186 } | 187 } |
| OLD | NEW |