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

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

Powered by Google App Engine
This is Rietveld 408576698