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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | 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/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
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (ext_service) { 412 if (ext_service) {
413 const Extension* extension = ext_service->GetExtensionByURL(origin); 413 const Extension* extension = ext_service->GetExtensionByURL(origin);
414 if (extension) 414 if (extension)
415 return UTF8ToUTF16(extension->name()); 415 return UTF8ToUTF16(extension->name());
416 } 416 }
417 } 417 }
418 return UTF8ToUTF16(origin.host()); 418 return UTF8ToUTF16(origin.host());
419 } 419 }
420 420
421 void DesktopNotificationService::NotifySettingsChange() { 421 void DesktopNotificationService::NotifySettingsChange() {
422 NotificationService::current()->Notify( 422 content::NotificationService::current()->Notify(
423 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, 423 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
424 content::Source<DesktopNotificationService>(this), 424 content::Source<DesktopNotificationService>(this),
425 NotificationService::NoDetails()); 425 content::NotificationService::NoDetails());
426 } 426 }
427 427
428 WebKit::WebNotificationPresenter::Permission 428 WebKit::WebNotificationPresenter::Permission
429 DesktopNotificationService::HasPermission(const GURL& origin) { 429 DesktopNotificationService::HasPermission(const GURL& origin) {
430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
431 HostContentSettingsMap* host_content_settings_map = 431 HostContentSettingsMap* host_content_settings_map =
432 profile_->GetHostContentSettingsMap(); 432 profile_->GetHostContentSettingsMap();
433 ContentSetting setting = host_content_settings_map->GetContentSetting( 433 ContentSetting setting = host_content_settings_map->GetContentSetting(
434 origin, 434 origin,
435 origin, 435 origin,
436 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 436 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
437 NO_RESOURCE_IDENTIFIER); 437 NO_RESOURCE_IDENTIFIER);
438 438
439 if (setting == CONTENT_SETTING_ALLOW) 439 if (setting == CONTENT_SETTING_ALLOW)
440 return WebKit::WebNotificationPresenter::PermissionAllowed; 440 return WebKit::WebNotificationPresenter::PermissionAllowed;
441 if (setting == CONTENT_SETTING_BLOCK) 441 if (setting == CONTENT_SETTING_BLOCK)
442 return WebKit::WebNotificationPresenter::PermissionDenied; 442 return WebKit::WebNotificationPresenter::PermissionDenied;
443 if (setting == CONTENT_SETTING_ASK) 443 if (setting == CONTENT_SETTING_ASK)
444 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 444 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
445 NOTREACHED() << "Invalid notifications settings value: " << setting; 445 NOTREACHED() << "Invalid notifications settings value: " << setting;
446 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 446 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
447 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698