OLD | NEW |
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/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/content_settings/content_settings_details.h" | 10 #include "chrome/browser/content_settings/content_settings_details.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/content_settings_pattern.h" | 26 #include "chrome/common/content_settings_pattern.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/browser/browser_child_process_host.h" | 29 #include "content/browser/browser_child_process_host.h" |
30 #include "content/browser/browser_thread.h" | 30 #include "content/browser/browser_thread.h" |
31 #include "content/browser/renderer_host/render_process_host.h" | 31 #include "content/browser/renderer_host/render_process_host.h" |
32 #include "content/browser/renderer_host/render_view_host.h" | 32 #include "content/browser/renderer_host/render_view_host.h" |
33 #include "content/browser/site_instance.h" | 33 #include "content/browser/site_instance.h" |
34 #include "content/browser/worker_host/worker_process_host.h" | 34 #include "content/browser/worker_host/worker_process_host.h" |
35 #include "content/common/desktop_notification_messages.h" | 35 #include "content/common/desktop_notification_messages.h" |
36 #include "content/common/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "grit/browser_resources.h" | 37 #include "grit/browser_resources.h" |
38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 | 44 |
45 using WebKit::WebNotificationPresenter; | 45 using WebKit::WebNotificationPresenter; |
46 using WebKit::WebTextDirection; | 46 using WebKit::WebTextDirection; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 if (ext_service) { | 408 if (ext_service) { |
409 const Extension* extension = ext_service->GetExtensionByURL(origin); | 409 const Extension* extension = ext_service->GetExtensionByURL(origin); |
410 if (extension) | 410 if (extension) |
411 return UTF8ToUTF16(extension->name()); | 411 return UTF8ToUTF16(extension->name()); |
412 } | 412 } |
413 } | 413 } |
414 return UTF8ToUTF16(origin.host()); | 414 return UTF8ToUTF16(origin.host()); |
415 } | 415 } |
416 | 416 |
417 void DesktopNotificationService::NotifySettingsChange() { | 417 void DesktopNotificationService::NotifySettingsChange() { |
418 NotificationService::current()->Notify( | 418 content::NotificationService::current()->Notify( |
419 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 419 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
420 content::Source<DesktopNotificationService>(this), | 420 content::Source<DesktopNotificationService>(this), |
421 NotificationService::NoDetails()); | 421 content::NotificationService::NoDetails()); |
422 } | 422 } |
423 | 423 |
424 WebKit::WebNotificationPresenter::Permission | 424 WebKit::WebNotificationPresenter::Permission |
425 DesktopNotificationService::HasPermission(const GURL& origin) { | 425 DesktopNotificationService::HasPermission(const GURL& origin) { |
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
427 HostContentSettingsMap* host_content_settings_map = | 427 HostContentSettingsMap* host_content_settings_map = |
428 profile_->GetHostContentSettingsMap(); | 428 profile_->GetHostContentSettingsMap(); |
429 ContentSetting setting = host_content_settings_map->GetContentSetting( | 429 ContentSetting setting = host_content_settings_map->GetContentSetting( |
430 origin, | 430 origin, |
431 origin, | 431 origin, |
432 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 432 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
433 NO_RESOURCE_IDENTIFIER); | 433 NO_RESOURCE_IDENTIFIER); |
434 | 434 |
435 if (setting == CONTENT_SETTING_ALLOW) | 435 if (setting == CONTENT_SETTING_ALLOW) |
436 return WebKit::WebNotificationPresenter::PermissionAllowed; | 436 return WebKit::WebNotificationPresenter::PermissionAllowed; |
437 if (setting == CONTENT_SETTING_BLOCK) | 437 if (setting == CONTENT_SETTING_BLOCK) |
438 return WebKit::WebNotificationPresenter::PermissionDenied; | 438 return WebKit::WebNotificationPresenter::PermissionDenied; |
439 if (setting == CONTENT_SETTING_ASK) | 439 if (setting == CONTENT_SETTING_ASK) |
440 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 440 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
441 NOTREACHED() << "Invalid notifications settings value: " << setting; | 441 NOTREACHED() << "Invalid notifications settings value: " << setting; |
442 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 442 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
443 } | 443 } |
OLD | NEW |