Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: chrome/browser/extensions/extension_context_menu_model.cc

Issue 11624036: Move the parsing of homepage_url" and "devtools_page" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch-rebased- 2 Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/extensions/extension_tab_util.h" 12 #include "chrome/browser/extensions/extension_tab_util.h"
13 #include "chrome/browser/extensions/management_policy.h" 13 #include "chrome/browser/extensions/management_policy.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/browser/ui/chrome_pages.h" 18 #include "chrome/browser/ui/chrome_pages.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_constants.h" 20 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/extensions/manifest_url_handler.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "grit/chromium_strings.h" 25 #include "grit/chromium_strings.h"
25 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
27 28
28 using content::OpenURLParams; 29 using content::OpenURLParams;
29 using content::Referrer; 30 using content::Referrer;
30 using content::WebContents; 31 using content::WebContents;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { 67 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const {
67 const Extension* extension = this->GetExtension(); 68 const Extension* extension = this->GetExtension();
68 if (!extension) 69 if (!extension)
69 return false; 70 return false;
70 71
71 if (command_id == CONFIGURE) { 72 if (command_id == CONFIGURE) {
72 return extension->options_url().spec().length() > 0; 73 return extension->options_url().spec().length() > 0;
73 } else if (command_id == NAME) { 74 } else if (command_id == NAME) {
74 // The NAME links to the Homepage URL. If the extension doesn't have a 75 // The NAME links to the Homepage URL. If the extension doesn't have a
75 // homepage, we just disable this menu item. 76 // homepage, we just disable this menu item.
76 return extension->GetHomepageURL().is_valid(); 77 return extensions::ManifestURL::GetHomepageURL(extension).is_valid();
77 } else if (command_id == INSPECT_POPUP) { 78 } else if (command_id == INSPECT_POPUP) {
78 WebContents* web_contents = chrome::GetActiveWebContents(browser_); 79 WebContents* web_contents = chrome::GetActiveWebContents(browser_);
79 if (!web_contents) 80 if (!web_contents)
80 return false; 81 return false;
81 82
82 return extension_action_ && 83 return extension_action_ &&
83 extension_action_->HasPopup(SessionID::IdForTab(web_contents)); 84 extension_action_->HasPopup(SessionID::IdForTab(web_contents));
84 } else if (command_id == UNINSTALL) { 85 } else if (command_id == UNINSTALL) {
85 // Some extension types can not be uninstalled. 86 // Some extension types can not be uninstalled.
86 return extensions::ExtensionSystem::Get( 87 return extensions::ExtensionSystem::Get(
87 profile_)->management_policy()->UserMayModifySettings(extension, NULL); 88 profile_)->management_policy()->UserMayModifySettings(extension, NULL);
88 } 89 }
89 return true; 90 return true;
90 } 91 }
91 92
92 bool ExtensionContextMenuModel::GetAcceleratorForCommandId( 93 bool ExtensionContextMenuModel::GetAcceleratorForCommandId(
93 int command_id, ui::Accelerator* accelerator) { 94 int command_id, ui::Accelerator* accelerator) {
94 return false; 95 return false;
95 } 96 }
96 97
97 void ExtensionContextMenuModel::ExecuteCommand(int command_id) { 98 void ExtensionContextMenuModel::ExecuteCommand(int command_id) {
98 const Extension* extension = GetExtension(); 99 const Extension* extension = GetExtension();
99 if (!extension) 100 if (!extension)
100 return; 101 return;
101 102
102 switch (command_id) { 103 switch (command_id) {
103 case NAME: { 104 case NAME: {
104 OpenURLParams params(extension->GetHomepageURL(), Referrer(), 105 OpenURLParams params(extensions::ManifestURL::GetHomepageURL(extension),
105 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, 106 Referrer(), NEW_FOREGROUND_TAB,
106 false); 107 content::PAGE_TRANSITION_LINK, false);
107 browser_->OpenURL(params); 108 browser_->OpenURL(params);
108 break; 109 break;
109 } 110 }
110 case CONFIGURE: 111 case CONFIGURE:
111 DCHECK(!extension->options_url().is_empty()); 112 DCHECK(!extension->options_url().is_empty());
112 extensions::ExtensionSystem::Get(profile_)->process_manager()-> 113 extensions::ExtensionSystem::Get(profile_)->process_manager()->
113 OpenOptionsPage(extension, browser_); 114 OpenOptionsPage(extension, browser_);
114 break; 115 break;
115 case HIDE: { 116 case HIDE: {
116 ExtensionService* extension_service = 117 ExtensionService* extension_service =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); 177 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
177 AddSeparator(ui::NORMAL_SEPARATOR); 178 AddSeparator(ui::NORMAL_SEPARATOR);
178 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); 179 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
179 } 180 }
180 181
181 const Extension* ExtensionContextMenuModel::GetExtension() const { 182 const Extension* ExtensionContextMenuModel::GetExtension() const {
182 ExtensionService* extension_service = 183 ExtensionService* extension_service =
183 extensions::ExtensionSystem::Get(profile_)->extension_service(); 184 extensions::ExtensionSystem::Get(profile_)->extension_service();
184 return extension_service->GetExtensionById(extension_id_, false); 185 return extension_service->GetExtensionById(extension_id_, false);
185 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/management/management_api.cc ('k') | chrome/browser/extensions/manifest_url_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698