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

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

Issue 10071035: RefCounted types should not have public destructors, chrome/browser/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 7 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_tab_util.h" 9 #include "chrome/browser/extensions/extension_tab_util.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 29 matching lines...) Expand all
40 extension_id_(extension->id()), 40 extension_id_(extension->id()),
41 browser_(browser), 41 browser_(browser),
42 profile_(browser->profile()) { 42 profile_(browser->profile()) {
43 extension_action_ = extension->browser_action(); 43 extension_action_ = extension->browser_action();
44 if (!extension_action_) 44 if (!extension_action_)
45 extension_action_ = extension->page_action(); 45 extension_action_ = extension->page_action();
46 46
47 InitCommonCommands(); 47 InitCommonCommands();
48 } 48 }
49 49
50 ExtensionContextMenuModel::~ExtensionContextMenuModel() {
51 }
52
53 void ExtensionContextMenuModel::InitCommonCommands() {
54 const Extension* extension = GetExtension();
55
56 // The extension pointer should only be null if the extension was uninstalled,
57 // and since the menu just opened, it should still be installed.
58 DCHECK(extension);
59
60 AddItem(NAME, UTF8ToUTF16(extension->name()));
61 AddSeparator();
62 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM);
63 AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE);
64 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
65 if (extension->browser_action())
66 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
67 AddSeparator();
68 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
69 }
70
71 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { 50 bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const {
72 return false; 51 return false;
73 } 52 }
74 53
75 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { 54 bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const {
76 const Extension* extension = this->GetExtension(); 55 const Extension* extension = this->GetExtension();
77 if (!extension) 56 if (!extension)
78 return false; 57 return false;
79 58
80 if (command_id == CONFIGURE) { 59 if (command_id == CONFIGURE) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 profile_->GetExtensionService()->UninstallExtension(extension_id_, false, 125 profile_->GetExtensionService()->UninstallExtension(extension_id_, false,
147 NULL); 126 NULL);
148 127
149 Release(); 128 Release();
150 } 129 }
151 130
152 void ExtensionContextMenuModel::ExtensionUninstallCanceled() { 131 void ExtensionContextMenuModel::ExtensionUninstallCanceled() {
153 Release(); 132 Release();
154 } 133 }
155 134
135 ExtensionContextMenuModel::~ExtensionContextMenuModel() {}
136
137 void ExtensionContextMenuModel::InitCommonCommands() {
138 const Extension* extension = GetExtension();
139
140 // The extension pointer should only be null if the extension was uninstalled,
141 // and since the menu just opened, it should still be installed.
142 DCHECK(extension);
143
144 AddItem(NAME, UTF8ToUTF16(extension->name()));
145 AddSeparator();
146 AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM);
147 AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE);
148 AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
149 if (extension->browser_action())
150 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON);
151 AddSeparator();
152 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
153 }
154
156 const Extension* ExtensionContextMenuModel::GetExtension() const { 155 const Extension* ExtensionContextMenuModel::GetExtension() const {
157 ExtensionService* extension_service = profile_->GetExtensionService(); 156 ExtensionService* extension_service = profile_->GetExtensionService();
158 return extension_service->GetExtensionById(extension_id_, false); 157 return extension_service->GetExtensionById(extension_id_, false);
159 } 158 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_context_menu_model.h ('k') | chrome/browser/extensions/extension_cookies_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698