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

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: 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::GetOptionsPage(extension)
145 extensions::ManifestURL::GetOptionsPage(extension).spec().length() > 0; 146 .spec()
147 .length() > 0;
not at google - send to devlin 2014/08/29 05:39:23 Weird. You can write (url.spec().length() > 0) as
ericzeng 2014/08/29 22:08:49 Done.
146 } else if (command_id == NAME) { 148 } else if (command_id == NAME) {
147 // The NAME links to the Homepage URL. If the extension doesn't have a 149 // The NAME links to the Homepage URL. If the extension doesn't have a
148 // homepage, we just disable this menu item. 150 // homepage, we just disable this menu item.
149 return extensions::ManifestURL::GetHomepageURL(extension).is_valid(); 151 return extensions::ManifestURL::GetHomepageURL(extension).is_valid();
150 } else if (command_id == INSPECT_POPUP) { 152 } else if (command_id == INSPECT_POPUP) {
151 WebContents* web_contents = GetActiveWebContents(); 153 WebContents* web_contents = GetActiveWebContents();
152 if (!web_contents) 154 if (!web_contents)
153 return false; 155 return false;
154 156
155 return extension_action_ && 157 return extension_action_ &&
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 195 }
194 case ALWAYS_RUN: { 196 case ALWAYS_RUN: {
195 WebContents* web_contents = GetActiveWebContents(); 197 WebContents* web_contents = GetActiveWebContents();
196 if (web_contents) { 198 if (web_contents) {
197 extensions::ActiveScriptController::GetForWebContents(web_contents) 199 extensions::ActiveScriptController::GetForWebContents(web_contents)
198 ->AlwaysRunOnVisibleOrigin(extension); 200 ->AlwaysRunOnVisibleOrigin(extension);
199 } 201 }
200 break; 202 break;
201 } 203 }
202 case CONFIGURE: 204 case CONFIGURE:
203 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); 205 DCHECK(
206 !extensions::OptionsPageInfo::GetOptionsPage(extension).is_empty());
204 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_); 207 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_);
205 break; 208 break;
206 case TOGGLE_VISIBILITY: { 209 case TOGGLE_VISIBILITY: {
207 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); 210 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
208 bool visible = ExtensionActionAPI::GetBrowserActionVisibility( 211 bool visible = ExtensionActionAPI::GetBrowserActionVisibility(
209 prefs, extension->id()); 212 prefs, extension->id());
210 ExtensionActionAPI::SetBrowserActionVisibility( 213 ExtensionActionAPI::SetBrowserActionVisibility(
211 prefs, extension->id(), !visible); 214 prefs, extension->id(), !visible);
212 break; 215 break;
213 } 216 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 extension_items_count_ = 0; 322 extension_items_count_ = 0;
320 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_), 323 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_),
321 base::string16(), 324 base::string16(),
322 &extension_items_count_, 325 &extension_items_count_,
323 true); // is_action_menu 326 true); // is_action_menu
324 } 327 }
325 328
326 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { 329 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const {
327 return browser_->tab_strip_model()->GetActiveWebContents(); 330 return browser_->tab_strip_model()->GetActiveWebContents();
328 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698