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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 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
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/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 NotificationOptionsMenuModel::NotificationOptionsMenuModel(Balloon* balloon) 117 NotificationOptionsMenuModel::NotificationOptionsMenuModel(Balloon* balloon)
118 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 118 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
119 balloon_(balloon) { 119 balloon_(balloon) {
120 const Notification& notification = balloon->notification(); 120 const Notification& notification = balloon->notification();
121 const GURL& origin = notification.origin_url(); 121 const GURL& origin = notification.origin_url();
122 122
123 if (origin.SchemeIs(chrome::kExtensionScheme)) { 123 if (origin.SchemeIs(chrome::kExtensionScheme)) {
124 ExtensionService* extension_service = 124 ExtensionService* extension_service =
125 balloon_->profile()->GetExtensionService(); 125 balloon_->profile()->GetExtensionService();
126 const Extension* extension = 126 const extensions::Extension* extension =
127 extension_service->extensions()->GetExtensionOrAppByURL( 127 extension_service->extensions()->GetExtensionOrAppByURL(
128 ExtensionURLInfo(origin)); 128 ExtensionURLInfo(origin));
129 // We get back no extension here when we show the notification after 129 // We get back no extension here when we show the notification after
130 // the extension has crashed. 130 // the extension has crashed.
131 if (extension) { 131 if (extension) {
132 const string16 disable_label = l10n_util::GetStringUTF16( 132 const string16 disable_label = l10n_util::GetStringUTF16(
133 IDS_EXTENSIONS_DISABLE); 133 IDS_EXTENSIONS_DISABLE);
134 AddItem(kToggleExtensionCommand, disable_label); 134 AddItem(kToggleExtensionCommand, disable_label);
135 } 135 }
136 } else if (!notification.display_source().empty()) { 136 } else if (!notification.display_source().empty()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (command_id == kTogglePermissionCommand || 168 if (command_id == kTogglePermissionCommand ||
169 command_id == kToggleExtensionCommand) { 169 command_id == kToggleExtensionCommand) {
170 const Notification& notification = balloon_->notification(); 170 const Notification& notification = balloon_->notification();
171 const GURL& origin = notification.origin_url(); 171 const GURL& origin = notification.origin_url();
172 172
173 DesktopNotificationService* service = 173 DesktopNotificationService* service =
174 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); 174 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile());
175 if (origin.SchemeIs(chrome::kExtensionScheme)) { 175 if (origin.SchemeIs(chrome::kExtensionScheme)) {
176 ExtensionService* extension_service = 176 ExtensionService* extension_service =
177 balloon_->profile()->GetExtensionService(); 177 balloon_->profile()->GetExtensionService();
178 const Extension* extension = 178 const extensions::Extension* extension =
179 extension_service->extensions()->GetExtensionOrAppByURL( 179 extension_service->extensions()->GetExtensionOrAppByURL(
180 ExtensionURLInfo(origin)); 180 ExtensionURLInfo(origin));
181 if (extension) { 181 if (extension) {
182 return l10n_util::GetStringUTF16( 182 return l10n_util::GetStringUTF16(
183 extension_service->IsExtensionEnabled(extension->id()) ? 183 extension_service->IsExtensionEnabled(extension->id()) ?
184 IDS_EXTENSIONS_DISABLE : 184 IDS_EXTENSIONS_DISABLE :
185 IDS_EXTENSIONS_ENABLE); 185 IDS_EXTENSIONS_ENABLE);
186 } 186 }
187 } else { 187 } else {
188 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) { 188 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 balloon_->profile()->GetExtensionService(); 226 balloon_->profile()->GetExtensionService();
227 const GURL& origin = balloon_->notification().origin_url(); 227 const GURL& origin = balloon_->notification().origin_url();
228 switch (command_id) { 228 switch (command_id) {
229 case kTogglePermissionCommand: 229 case kTogglePermissionCommand:
230 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) 230 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW)
231 service->DenyPermission(origin); 231 service->DenyPermission(origin);
232 else 232 else
233 service->GrantPermission(origin); 233 service->GrantPermission(origin);
234 break; 234 break;
235 case kToggleExtensionCommand: { 235 case kToggleExtensionCommand: {
236 const Extension* extension = 236 const extensions::Extension* extension =
237 extension_service->extensions()->GetExtensionOrAppByURL( 237 extension_service->extensions()->GetExtensionOrAppByURL(
238 ExtensionURLInfo(origin)); 238 ExtensionURLInfo(origin));
239 if (extension) { 239 if (extension) {
240 const std::string& id = extension->id(); 240 const std::string& id = extension->id();
241 if (extension_service->IsExtensionEnabled(id)) 241 if (extension_service->IsExtensionEnabled(id))
242 extension_service->DisableExtension( 242 extension_service->DisableExtension(
243 id, Extension::DISABLE_USER_ACTION); 243 id, extensions::Extension::DISABLE_USER_ACTION);
244 else 244 else
245 extension_service->EnableExtension(id); 245 extension_service->EnableExtension(id);
246 } 246 }
247 break; 247 break;
248 } 248 }
249 case kOpenContentSettingsCommand: { 249 case kOpenContentSettingsCommand: {
250 Browser* browser = 250 Browser* browser =
251 BrowserList::GetLastActiveWithProfile(balloon_->profile()); 251 BrowserList::GetLastActiveWithProfile(balloon_->profile());
252 if (!browser) { 252 if (!browser) {
253 // It is possible that there is no browser window (e.g. when there are 253 // It is possible that there is no browser window (e.g. when there are
254 // background pages, or for a chrome frame process on windows). 254 // background pages, or for a chrome frame process on windows).
255 browser = Browser::Create(balloon_->profile()); 255 browser = Browser::Create(balloon_->profile());
256 } 256 }
257 browser->ShowContentSettingsPage(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 257 browser->ShowContentSettingsPage(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
258 break; 258 break;
259 } 259 }
260 default: 260 default:
261 NOTREACHED(); 261 NOTREACHED();
262 break; 262 break;
263 } 263 }
264 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698