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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.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/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/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 CONTENT_SETTING_BLOCK); 263 CONTENT_SETTING_BLOCK);
264 } 264 }
265 265
266 void DesktopNotificationService::Observe( 266 void DesktopNotificationService::Observe(
267 int type, 267 int type,
268 const content::NotificationSource& source, 268 const content::NotificationSource& source,
269 const content::NotificationDetails& details) { 269 const content::NotificationDetails& details) {
270 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 270 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
271 // Remove all notifications currently shown or queued by the extension 271 // Remove all notifications currently shown or queued by the extension
272 // which was unloaded. 272 // which was unloaded.
273 const Extension* extension = 273 const extensions::Extension* extension =
274 content::Details<UnloadedExtensionInfo>(details)->extension; 274 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
275 if (extension) 275 if (extension)
276 GetUIManager()->CancelAllBySourceOrigin(extension->url()); 276 GetUIManager()->CancelAllBySourceOrigin(extension->url());
277 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { 277 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) {
278 StopObserving(); 278 StopObserving();
279 } 279 }
280 } 280 }
281 281
282 ContentSetting DesktopNotificationService::GetDefaultContentSetting( 282 ContentSetting DesktopNotificationService::GetDefaultContentSetting(
283 std::string* provider_id) { 283 std::string* provider_id) {
284 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( 284 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 401 }
402 return true; 402 return true;
403 } 403 }
404 404
405 string16 DesktopNotificationService::DisplayNameForOrigin( 405 string16 DesktopNotificationService::DisplayNameForOrigin(
406 const GURL& origin) { 406 const GURL& origin) {
407 // If the source is an extension, lookup the display name. 407 // If the source is an extension, lookup the display name.
408 if (origin.SchemeIs(chrome::kExtensionScheme)) { 408 if (origin.SchemeIs(chrome::kExtensionScheme)) {
409 ExtensionService* extension_service = profile_->GetExtensionService(); 409 ExtensionService* extension_service = profile_->GetExtensionService();
410 if (extension_service) { 410 if (extension_service) {
411 const Extension* extension = 411 const extensions::Extension* extension =
412 extension_service->extensions()->GetExtensionOrAppByURL( 412 extension_service->extensions()->GetExtensionOrAppByURL(
413 ExtensionURLInfo( 413 ExtensionURLInfo(
414 WebSecurityOrigin::createFromString( 414 WebSecurityOrigin::createFromString(
415 UTF8ToUTF16(origin.spec())), 415 UTF8ToUTF16(origin.spec())),
416 origin)); 416 origin));
417 if (extension) 417 if (extension)
418 return UTF8ToUTF16(extension->name()); 418 return UTF8ToUTF16(extension->name());
419 } 419 }
420 } 420 }
421 return UTF8ToUTF16(origin.host()); 421 return UTF8ToUTF16(origin.host());
(...skipping 27 matching lines...) Expand all
449 449
450 if (setting == CONTENT_SETTING_ALLOW) 450 if (setting == CONTENT_SETTING_ALLOW)
451 return WebKit::WebNotificationPresenter::PermissionAllowed; 451 return WebKit::WebNotificationPresenter::PermissionAllowed;
452 if (setting == CONTENT_SETTING_BLOCK) 452 if (setting == CONTENT_SETTING_BLOCK)
453 return WebKit::WebNotificationPresenter::PermissionDenied; 453 return WebKit::WebNotificationPresenter::PermissionDenied;
454 if (setting == CONTENT_SETTING_ASK) 454 if (setting == CONTENT_SETTING_ASK)
455 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 455 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
456 NOTREACHED() << "Invalid notifications settings value: " << setting; 456 NOTREACHED() << "Invalid notifications settings value: " << setting;
457 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 457 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
458 } 458 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.cc ('k') | chrome/browser/notifications/notification_options_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698