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

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

Issue 518653002: Add the "options_ui" extension manifest field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build issue? Created 6 years, 3 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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/extensions/active_script_controller.h" 10 #include "chrome/browser/extensions/active_script_controller.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/common/context_menu_params.h" 31 #include "content/public/common/context_menu_params.h"
32 #include "extensions/browser/extension_prefs.h" 32 #include "extensions/browser/extension_prefs.h"
33 #include "extensions/browser/extension_registry.h" 33 #include "extensions/browser/extension_registry.h"
34 #include "extensions/browser/extension_system.h" 34 #include "extensions/browser/extension_system.h"
35 #include "extensions/browser/management_policy.h" 35 #include "extensions/browser/management_policy.h"
36 #include "extensions/browser/uninstall_reason.h" 36 #include "extensions/browser/uninstall_reason.h"
37 #include "extensions/common/extension.h" 37 #include "extensions/common/extension.h"
38 #include "extensions/common/feature_switch.h" 38 #include "extensions/common/feature_switch.h"
39 #include "extensions/common/manifest_handlers/options_page_info.h"
39 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
40 41
41 using content::OpenURLParams; 42 using content::OpenURLParams;
42 using content::Referrer; 43 using content::Referrer;
43 using content::WebContents; 44 using content::WebContents;
44 using extensions::Extension; 45 using extensions::Extension;
45 using extensions::ExtensionActionAPI; 46 using extensions::ExtensionActionAPI;
46 using extensions::ExtensionPrefs; 47 using extensions::ExtensionPrefs;
47 using extensions::MenuItem; 48 using extensions::MenuItem;
48 using extensions::MenuManager; 49 using extensions::MenuManager;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 135
135 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { 136 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const {
136 const Extension* extension = GetExtension(); 137 const Extension* extension = GetExtension();
137 if (!extension) 138 if (!extension)
138 return false; 139 return false;
139 140
140 if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && 141 if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
141 command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { 142 command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) {
142 return extension_items_->IsCommandIdEnabled(command_id); 143 return extension_items_->IsCommandIdEnabled(command_id);
143 } else if (command_id == CONFIGURE) { 144 } else if (command_id == CONFIGURE) {
144 return 145 return extensions::OptionsPageInfo::HasOptionsPage(extension);
145 extensions::ManifestURL::GetOptionsPage(extension).spec().length() > 0;
146 } else if (command_id == NAME) { 146 } else if (command_id == NAME) {
147 // The NAME links to the Homepage URL. If the extension doesn't have a 147 // The NAME links to the Homepage URL. If the extension doesn't have a
148 // homepage, we just disable this menu item. 148 // homepage, we just disable this menu item.
149 return extensions::ManifestURL::GetHomepageURL(extension).is_valid(); 149 return extensions::ManifestURL::GetHomepageURL(extension).is_valid();
150 } else if (command_id == INSPECT_POPUP) { 150 } else if (command_id == INSPECT_POPUP) {
151 WebContents* web_contents = GetActiveWebContents(); 151 WebContents* web_contents = GetActiveWebContents();
152 if (!web_contents) 152 if (!web_contents)
153 return false; 153 return false;
154 154
155 return extension_action_ && 155 return extension_action_ &&
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 case ALWAYS_RUN: { 194 case ALWAYS_RUN: {
195 WebContents* web_contents = GetActiveWebContents(); 195 WebContents* web_contents = GetActiveWebContents();
196 if (web_contents) { 196 if (web_contents) {
197 extensions::ActiveScriptController::GetForWebContents(web_contents) 197 extensions::ActiveScriptController::GetForWebContents(web_contents)
198 ->AlwaysRunOnVisibleOrigin(extension); 198 ->AlwaysRunOnVisibleOrigin(extension);
199 } 199 }
200 break; 200 break;
201 } 201 }
202 case CONFIGURE: 202 case CONFIGURE:
203 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); 203 DCHECK(extensions::OptionsPageInfo::HasOptionsPage(extension));
204 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_); 204 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_);
205 break; 205 break;
206 case TOGGLE_VISIBILITY: { 206 case TOGGLE_VISIBILITY: {
207 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); 207 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
208 bool visible = ExtensionActionAPI::GetBrowserActionVisibility( 208 bool visible = ExtensionActionAPI::GetBrowserActionVisibility(
209 prefs, extension->id()); 209 prefs, extension->id());
210 ExtensionActionAPI::SetBrowserActionVisibility( 210 ExtensionActionAPI::SetBrowserActionVisibility(
211 prefs, extension->id(), !visible); 211 prefs, extension->id(), !visible);
212 break; 212 break;
213 } 213 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 extension_items_count_ = 0; 319 extension_items_count_ = 0;
320 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_), 320 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_),
321 base::string16(), 321 base::string16(),
322 &extension_items_count_, 322 &extension_items_count_,
323 true); // is_action_menu 323 true); // is_action_menu
324 } 324 }
325 325
326 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { 326 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const {
327 return browser_->tab_strip_model()->GetActiveWebContents(); 327 return browser_->tab_strip_model()->GetActiveWebContents();
328 } 328 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/management/management_api.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698