Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/media_galleries/media_galleries_preferences.h" | 5 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 MediaGalleryPrefId pref_id, | 612 MediaGalleryPrefId pref_id, |
| 613 bool has_permission) { | 613 bool has_permission) { |
| 614 // The gallery may not exist anymore if the user opened a second config | 614 // The gallery may not exist anymore if the user opened a second config |
| 615 // surface concurrently and removed it. Drop the permission update if so. | 615 // surface concurrently and removed it. Drop the permission update if so. |
| 616 MediaGalleriesPrefInfoMap::const_iterator gallery_info = | 616 MediaGalleriesPrefInfoMap::const_iterator gallery_info = |
| 617 known_galleries_.find(pref_id); | 617 known_galleries_.find(pref_id); |
| 618 if (gallery_info == known_galleries_.end()) | 618 if (gallery_info == known_galleries_.end()) |
| 619 return; | 619 return; |
| 620 | 620 |
| 621 #if defined(ENABLE_EXTENSIONS) | 621 #if defined(ENABLE_EXTENSIONS) |
| 622 extensions::GalleryWatchStateTracker* state_tracker = | 622 extensions::GalleryWatchStateTracker* state_tracker = |
|
vandebo (ex-Chrome)
2013/05/17 22:19:58
Grr, this shouldn't be here... filed bug 241903
Greg Billock
2013/05/18 06:28:40
We're using at least two mechanisms: the registry
vandebo (ex-Chrome)
2013/05/20 15:45:46
Actually three - This class already implements an
| |
| 623 extensions::GalleryWatchStateTracker::GetForProfile(profile_); | 623 extensions::GalleryWatchStateTracker::GetForProfile(profile_); |
| 624 #endif | 624 #endif |
| 625 bool all_permission = HasAutoDetectedGalleryPermission(extension); | 625 bool all_permission = HasAutoDetectedGalleryPermission(extension); |
| 626 if (has_permission && all_permission) { | 626 if (has_permission && all_permission) { |
| 627 if (gallery_info->second.type == MediaGalleryPrefInfo::kAutoDetected) { | 627 if (gallery_info->second.type == MediaGalleryPrefInfo::kAutoDetected) { |
| 628 extensions::MediaGalleriesPrivateAPI::UnsetMediaGalleryPermission( | 628 extensions::MediaGalleriesPrivateAPI::UnsetMediaGalleryPermission( |
| 629 GetExtensionPrefs(), extension.id(), pref_id); | 629 GetExtensionPrefs(), extension.id(), pref_id); |
| 630 NotifyChangeObservers(extension.id()); | 630 NotifyChangeObservers(extension.id()); |
| 631 #if defined(ENABLE_EXTENSIONS) | 631 #if defined(ENABLE_EXTENSIONS) |
| 632 if (state_tracker) { | 632 if (state_tracker) { |
| 633 state_tracker->OnGalleryPermissionChanged(extension.id(), pref_id, | 633 state_tracker->OnGalleryPermissionChanged(extension.id(), pref_id, |
| 634 true); | 634 true, this); |
| 635 } | 635 } |
| 636 #endif | 636 #endif |
| 637 return; | 637 return; |
| 638 } | 638 } |
| 639 } | 639 } |
| 640 | 640 |
| 641 if (!has_permission && !all_permission) { | 641 if (!has_permission && !all_permission) { |
| 642 extensions::MediaGalleriesPrivateAPI::UnsetMediaGalleryPermission( | 642 extensions::MediaGalleriesPrivateAPI::UnsetMediaGalleryPermission( |
| 643 GetExtensionPrefs(), extension.id(), pref_id); | 643 GetExtensionPrefs(), extension.id(), pref_id); |
| 644 } else { | 644 } else { |
| 645 extensions::MediaGalleriesPrivateAPI::SetMediaGalleryPermission( | 645 extensions::MediaGalleriesPrivateAPI::SetMediaGalleryPermission( |
| 646 GetExtensionPrefs(), extension.id(), pref_id, has_permission); | 646 GetExtensionPrefs(), extension.id(), pref_id, has_permission); |
| 647 } | 647 } |
| 648 NotifyChangeObservers(extension.id()); | 648 NotifyChangeObservers(extension.id()); |
| 649 #if defined(ENABLE_EXTENSIONS) | 649 #if defined(ENABLE_EXTENSIONS) |
| 650 if (state_tracker) { | 650 if (state_tracker) { |
| 651 state_tracker->OnGalleryPermissionChanged(extension.id(), pref_id, | 651 state_tracker->OnGalleryPermissionChanged(extension.id(), pref_id, |
| 652 has_permission); | 652 has_permission, this); |
| 653 } | 653 } |
| 654 #endif | 654 #endif |
| 655 } | 655 } |
| 656 | 656 |
| 657 void MediaGalleriesPreferences::Shutdown() { | 657 void MediaGalleriesPreferences::Shutdown() { |
| 658 weak_factory_.InvalidateWeakPtrs(); | 658 weak_factory_.InvalidateWeakPtrs(); |
| 659 profile_ = NULL; | 659 profile_ = NULL; |
| 660 } | 660 } |
| 661 | 661 |
| 662 // static | 662 // static |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 678 } | 678 } |
| 679 | 679 |
| 680 extensions::ExtensionPrefs* | 680 extensions::ExtensionPrefs* |
| 681 MediaGalleriesPreferences::GetExtensionPrefs() const { | 681 MediaGalleriesPreferences::GetExtensionPrefs() const { |
| 682 ExtensionService* extension_service = | 682 ExtensionService* extension_service = |
| 683 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 683 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 684 return extension_service->extension_prefs(); | 684 return extension_service->extension_prefs(); |
| 685 } | 685 } |
| 686 | 686 |
| 687 } // namespace chrome | 687 } // namespace chrome |
| OLD | NEW |