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

Side by Side Diff: chrome/browser/notifications/notification_options_menu_model.cc

Issue 8827013: Move/replace/rename URL-based extension getters from ExtensionService to/in ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: extent Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/notifications/notification_options_menu_model.h" 5 #include "chrome/browser/notifications/notification_options_menu_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 NotificationOptionsMenuModel::NotificationOptionsMenuModel(Balloon* balloon) 113 NotificationOptionsMenuModel::NotificationOptionsMenuModel(Balloon* balloon)
114 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 114 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
115 balloon_(balloon) { 115 balloon_(balloon) {
116 const Notification& notification = balloon->notification(); 116 const Notification& notification = balloon->notification();
117 const GURL& origin = notification.origin_url(); 117 const GURL& origin = notification.origin_url();
118 118
119 if (origin.SchemeIs(chrome::kExtensionScheme)) { 119 if (origin.SchemeIs(chrome::kExtensionScheme)) {
120 ExtensionService* ext_service = 120 ExtensionService* ext_service =
121 balloon_->profile()->GetExtensionService(); 121 balloon_->profile()->GetExtensionService();
122 const Extension* extension = ext_service->GetExtensionByURL(origin); 122 const Extension* extension =
123 ext_service->extensions()->GetByURL(ExtensionURLInfo(origin));
123 // We get back no extension here when we show the notification after 124 // We get back no extension here when we show the notification after
124 // the extension has crashed. 125 // the extension has crashed.
125 if (extension) { 126 if (extension) {
126 const string16 disable_label = l10n_util::GetStringUTF16( 127 const string16 disable_label = l10n_util::GetStringUTF16(
127 IDS_EXTENSIONS_DISABLE); 128 IDS_EXTENSIONS_DISABLE);
128 AddItem(kToggleExtensionCommand, disable_label); 129 AddItem(kToggleExtensionCommand, disable_label);
129 } 130 }
130 } else { 131 } else {
131 const string16 disable_label = l10n_util::GetStringFUTF16( 132 const string16 disable_label = l10n_util::GetStringFUTF16(
132 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE, 133 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE,
(...skipping 27 matching lines...) Expand all
160 if (command_id == kTogglePermissionCommand || 161 if (command_id == kTogglePermissionCommand ||
161 command_id == kToggleExtensionCommand) { 162 command_id == kToggleExtensionCommand) {
162 const Notification& notification = balloon_->notification(); 163 const Notification& notification = balloon_->notification();
163 const GURL& origin = notification.origin_url(); 164 const GURL& origin = notification.origin_url();
164 165
165 DesktopNotificationService* service = 166 DesktopNotificationService* service =
166 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); 167 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile());
167 if (origin.SchemeIs(chrome::kExtensionScheme)) { 168 if (origin.SchemeIs(chrome::kExtensionScheme)) {
168 ExtensionService* ext_service = 169 ExtensionService* ext_service =
169 balloon_->profile()->GetExtensionService(); 170 balloon_->profile()->GetExtensionService();
170 const Extension* extension = ext_service->GetExtensionByURL(origin); 171 const Extension* extension =
172 ext_service->extensions()->GetByURL(ExtensionURLInfo(origin));
171 if (extension) { 173 if (extension) {
172 return l10n_util::GetStringUTF16( 174 return l10n_util::GetStringUTF16(
173 ext_service->IsExtensionEnabled(extension->id()) ? 175 ext_service->IsExtensionEnabled(extension->id()) ?
174 IDS_EXTENSIONS_DISABLE : 176 IDS_EXTENSIONS_DISABLE :
175 IDS_EXTENSIONS_ENABLE); 177 IDS_EXTENSIONS_ENABLE);
176 } 178 }
177 } else { 179 } else {
178 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) { 180 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) {
179 return l10n_util::GetStringFUTF16( 181 return l10n_util::GetStringFUTF16(
180 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE, 182 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 balloon_->profile()->GetExtensionService(); 218 balloon_->profile()->GetExtensionService();
217 const GURL& origin = balloon_->notification().origin_url(); 219 const GURL& origin = balloon_->notification().origin_url();
218 switch (command_id) { 220 switch (command_id) {
219 case kTogglePermissionCommand: 221 case kTogglePermissionCommand:
220 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) 222 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW)
221 service->DenyPermission(origin); 223 service->DenyPermission(origin);
222 else 224 else
223 service->GrantPermission(origin); 225 service->GrantPermission(origin);
224 break; 226 break;
225 case kToggleExtensionCommand: { 227 case kToggleExtensionCommand: {
226 const Extension* extension = ext_service->GetExtensionByURL(origin); 228 const Extension* extension =
229 ext_service->extensions()->GetByURL(ExtensionURLInfo(origin));
227 if (extension) { 230 if (extension) {
228 const std::string& id = extension->id(); 231 const std::string& id = extension->id();
229 if (ext_service->IsExtensionEnabled(id)) 232 if (ext_service->IsExtensionEnabled(id))
230 ext_service->DisableExtension(id); 233 ext_service->DisableExtension(id);
231 else 234 else
232 ext_service->EnableExtension(id); 235 ext_service->EnableExtension(id);
233 } 236 }
234 break; 237 break;
235 } 238 }
236 case kOpenContentSettingsCommand: { 239 case kOpenContentSettingsCommand: {
237 Browser* browser = 240 Browser* browser =
238 BrowserList::GetLastActiveWithProfile(balloon_->profile()); 241 BrowserList::GetLastActiveWithProfile(balloon_->profile());
239 if (!browser) { 242 if (!browser) {
240 // It is possible that there is no browser window (e.g. when there are 243 // It is possible that there is no browser window (e.g. when there are
241 // background pages, or for a chrome frame process on windows). 244 // background pages, or for a chrome frame process on windows).
242 browser = Browser::Create(balloon_->profile()); 245 browser = Browser::Create(balloon_->profile());
243 } 246 }
244 browser->ShowContentSettingsPage(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 247 browser->ShowContentSettingsPage(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
245 break; 248 break;
246 } 249 }
247 default: 250 default:
248 NOTREACHED(); 251 NOTREACHED();
249 break; 252 break;
250 } 253 }
251 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698