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

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

Issue 10911300: Move ExtensionAction from common/ to browser/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: proof of concept 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_action.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/chrome_pages.h" 16 #include "chrome/browser/ui/chrome_pages.h"
16 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_action.h"
18 #include "chrome/common/extensions/extension_constants.h" 18 #include "chrome/common/extensions/extension_constants.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 25
26 using content::OpenURLParams; 26 using content::OpenURLParams;
27 using content::Referrer; 27 using content::Referrer;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { 153 void ExtensionContextMenuModel::ExtensionUninstallCanceled() {
154 Release(); 154 Release();
155 } 155 }
156 156
157 ExtensionContextMenuModel::~ExtensionContextMenuModel() {} 157 ExtensionContextMenuModel::~ExtensionContextMenuModel() {}
158 158
159 void ExtensionContextMenuModel::InitMenu(const Extension* extension) { 159 void ExtensionContextMenuModel::InitMenu(const Extension* extension) {
160 DCHECK(extension); 160 DCHECK(extension);
161 161
162 extension_action_ = extension->browser_action(); 162 extension_action_ = extensions::GetBrowserAction(profile_, *extension);
163 if (!extension_action_) 163 if (!extension_action_)
164 extension_action_ = extension->page_action(); 164 extension_action_ = extensions::GetPageAction(profile_, *extension);
165 165
166 AddItem(NAME, UTF8ToUTF16(extension->name())); 166 AddItem(NAME, UTF8ToUTF16(extension->name()));
167 AddSeparator(ui::NORMAL_SEPARATOR); 167 AddSeparator(ui::NORMAL_SEPARATOR);
168 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM); 168 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM);
169 AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE); 169 AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE);
170 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); 170 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
171 if (extension->browser_action()) 171 if (extension->browser_action())
172 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); 172 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
173 AddSeparator(ui::NORMAL_SEPARATOR); 173 AddSeparator(ui::NORMAL_SEPARATOR);
174 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); 174 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
175 } 175 }
176 176
177 const Extension* ExtensionContextMenuModel::GetExtension() const { 177 const Extension* ExtensionContextMenuModel::GetExtension() const {
178 ExtensionService* extension_service = profile_->GetExtensionService(); 178 ExtensionService* extension_service = profile_->GetExtensionService();
179 return extension_service->GetExtensionById(extension_id_, false); 179 return extension_service->GetExtensionById(extension_id_, false);
180 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698