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

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

Issue 10912156: Move SessionID, CaptureVisibleTabFunction to WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase atop the extension tab helper change Created 8 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 | Annotate | Revision Log
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_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/chrome_pages.h" 15 #include "chrome/browser/ui/chrome_pages.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
19 #include "chrome/common/extensions/extension_constants.h" 18 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
22 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
23 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
24 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
26 25
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (!extension) 66 if (!extension)
68 return false; 67 return false;
69 68
70 if (command_id == CONFIGURE) { 69 if (command_id == CONFIGURE) {
71 return extension->options_url().spec().length() > 0; 70 return extension->options_url().spec().length() > 0;
72 } else if (command_id == NAME) { 71 } else if (command_id == NAME) {
73 // The NAME links to the Homepage URL. If the extension doesn't have a 72 // The NAME links to the Homepage URL. If the extension doesn't have a
74 // homepage, we just disable this menu item. 73 // homepage, we just disable this menu item.
75 return extension->GetHomepageURL().is_valid(); 74 return extension->GetHomepageURL().is_valid();
76 } else if (command_id == INSPECT_POPUP) { 75 } else if (command_id == INSPECT_POPUP) {
77 TabContents* tab_contents = chrome::GetActiveTabContents(browser_); 76 WebContents* web_contents = chrome::GetActiveWebContents(browser_);
78 if (!tab_contents) 77 if (!web_contents)
79 return false; 78 return false;
80 79
81 return extension_action_->HasPopup(SessionID::IdForTab(tab_contents)); 80 return extension_action_->HasPopup(SessionID::IdForTab(web_contents));
82 } else if (command_id == DISABLE || command_id == UNINSTALL) { 81 } else if (command_id == DISABLE || command_id == UNINSTALL) {
83 // Some extension types can not be disabled or uninstalled. 82 // Some extension types can not be disabled or uninstalled.
84 return extensions::ExtensionSystem::Get( 83 return extensions::ExtensionSystem::Get(
85 profile_)->management_policy()->UserMayModifySettings(extension, NULL); 84 profile_)->management_policy()->UserMayModifySettings(extension, NULL);
86 } 85 }
87 return true; 86 return true;
88 } 87 }
89 88
90 bool ExtensionContextMenuModel::GetAcceleratorForCommandId( 89 bool ExtensionContextMenuModel::GetAcceleratorForCommandId(
91 int command_id, ui::Accelerator* accelerator) { 90 int command_id, ui::Accelerator* accelerator) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (extension->browser_action()) 171 if (extension->browser_action())
173 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); 172 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
174 AddSeparator(ui::NORMAL_SEPARATOR); 173 AddSeparator(ui::NORMAL_SEPARATOR);
175 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); 174 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
176 } 175 }
177 176
178 const Extension* ExtensionContextMenuModel::GetExtension() const { 177 const Extension* ExtensionContextMenuModel::GetExtension() const {
179 ExtensionService* extension_service = profile_->GetExtensionService(); 178 ExtensionService* extension_service = profile_->GetExtensionService();
180 return extension_service->GetExtensionById(extension_id_, false); 179 return extension_service->GetExtensionById(extension_id_, false);
181 } 180 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698