| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/notifications/desktop_notification_service.h" | 12 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 13 #include "chrome/browser/notifications/notification.h" | 13 #include "chrome/browser/notifications/notification.h" |
| 14 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 14 #include "chrome/browser/notifications/notifications_prefs_cache.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/content_settings_types.h" | 16 #include "chrome/common/content_settings_types.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 | 20 |
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // TODO(tfarina,johnnyg): Removed this code if we decide to close | 65 // TODO(tfarina,johnnyg): Removed this code if we decide to close |
| 66 // notifications after permissions are revoked. | 66 // notifications after permissions are revoked. |
| 67 if (command_id == kTogglePermissionCommand || | 67 if (command_id == kTogglePermissionCommand || |
| 68 command_id == kToggleExtensionCommand) { | 68 command_id == kToggleExtensionCommand) { |
| 69 const Notification& notification = balloon_->notification(); | 69 const Notification& notification = balloon_->notification(); |
| 70 const GURL& origin = notification.origin_url(); | 70 const GURL& origin = notification.origin_url(); |
| 71 | 71 |
| 72 DesktopNotificationService* service = | 72 DesktopNotificationService* service = |
| 73 balloon_->profile()->GetDesktopNotificationService(); | 73 balloon_->profile()->GetDesktopNotificationService(); |
| 74 if (origin.SchemeIs(chrome::kExtensionScheme)) { | 74 if (origin.SchemeIs(chrome::kExtensionScheme)) { |
| 75 ExtensionsService* ext_service = | 75 ExtensionService* ext_service = |
| 76 balloon_->profile()->GetExtensionsService(); | 76 balloon_->profile()->GetExtensionService(); |
| 77 const Extension* extension = ext_service->GetExtensionByURL(origin); | 77 const Extension* extension = ext_service->GetExtensionByURL(origin); |
| 78 if (extension) { | 78 if (extension) { |
| 79 ExtensionPrefs* extension_prefs = ext_service->extension_prefs(); | 79 ExtensionPrefs* extension_prefs = ext_service->extension_prefs(); |
| 80 const std::string& id = extension->id(); | 80 const std::string& id = extension->id(); |
| 81 if (extension_prefs->GetExtensionState(id) == Extension::ENABLED) | 81 if (extension_prefs->GetExtensionState(id) == Extension::ENABLED) |
| 82 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE); | 82 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE); |
| 83 else | 83 else |
| 84 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE); | 84 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE); |
| 85 } | 85 } |
| 86 } else { | 86 } else { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 | 114 |
| 115 bool NotificationOptionsMenuModel::GetAcceleratorForCommandId( | 115 bool NotificationOptionsMenuModel::GetAcceleratorForCommandId( |
| 116 int /* command_id */, menus::Accelerator* /* accelerator */) { | 116 int /* command_id */, menus::Accelerator* /* accelerator */) { |
| 117 // Currently no accelerators. | 117 // Currently no accelerators. |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void NotificationOptionsMenuModel::ExecuteCommand(int command_id) { | 121 void NotificationOptionsMenuModel::ExecuteCommand(int command_id) { |
| 122 DesktopNotificationService* service = | 122 DesktopNotificationService* service = |
| 123 balloon_->profile()->GetDesktopNotificationService(); | 123 balloon_->profile()->GetDesktopNotificationService(); |
| 124 ExtensionsService* ext_service = | 124 ExtensionService* ext_service = |
| 125 balloon_->profile()->GetExtensionsService(); | 125 balloon_->profile()->GetExtensionService(); |
| 126 const GURL& origin = balloon_->notification().origin_url(); | 126 const GURL& origin = balloon_->notification().origin_url(); |
| 127 switch (command_id) { | 127 switch (command_id) { |
| 128 case kTogglePermissionCommand: | 128 case kTogglePermissionCommand: |
| 129 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) | 129 if (service->GetContentSetting(origin) == CONTENT_SETTING_ALLOW) |
| 130 service->DenyPermission(origin); | 130 service->DenyPermission(origin); |
| 131 else | 131 else |
| 132 service->GrantPermission(origin); | 132 service->GrantPermission(origin); |
| 133 break; | 133 break; |
| 134 case kToggleExtensionCommand: { | 134 case kToggleExtensionCommand: { |
| 135 const Extension* extension = ext_service->GetExtensionByURL(origin); | 135 const Extension* extension = ext_service->GetExtensionByURL(origin); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 158 } | 158 } |
| 159 #endif // OS_WIN | 159 #endif // OS_WIN |
| 160 } | 160 } |
| 161 break; | 161 break; |
| 162 } | 162 } |
| 163 default: | 163 default: |
| 164 NOTREACHED(); | 164 NOTREACHED(); |
| 165 break; | 165 break; |
| 166 } | 166 } |
| 167 } | 167 } |
| OLD | NEW |