| 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/content_settings/tab_specific_content_settings.h" | 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 645 } |
| 646 | 646 |
| 647 void TabSpecificContentSettings::Observe( | 647 void TabSpecificContentSettings::Observe( |
| 648 int type, | 648 int type, |
| 649 const content::NotificationSource& source, | 649 const content::NotificationSource& source, |
| 650 const content::NotificationDetails& details) { | 650 const content::NotificationDetails& details) { |
| 651 DCHECK(type == chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED); | 651 DCHECK(type == chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED); |
| 652 | 652 |
| 653 content::Details<const ContentSettingsDetails> settings_details(details); | 653 content::Details<const ContentSettingsDetails> settings_details(details); |
| 654 const NavigationController& controller = web_contents()->GetController(); | 654 const NavigationController& controller = web_contents()->GetController(); |
| 655 NavigationEntry* entry = controller.GetActiveEntry(); | 655 NavigationEntry* entry = controller.GetVisibleEntry(); |
| 656 GURL entry_url; | 656 GURL entry_url; |
| 657 if (entry) | 657 if (entry) |
| 658 entry_url = entry->GetURL(); | 658 entry_url = entry->GetURL(); |
| 659 if (settings_details.ptr()->update_all() || | 659 if (settings_details.ptr()->update_all() || |
| 660 // The active NavigationEntry is the URL in the URL field of a tab. | 660 // The visible NavigationEntry is the URL in the URL field of a tab. |
| 661 // Currently this should be matched by the |primary_pattern|. | 661 // Currently this should be matched by the |primary_pattern|. |
| 662 settings_details.ptr()->primary_pattern().Matches(entry_url)) { | 662 settings_details.ptr()->primary_pattern().Matches(entry_url)) { |
| 663 Profile* profile = | 663 Profile* profile = |
| 664 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 664 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 665 RendererContentSettingRules rules; | 665 RendererContentSettingRules rules; |
| 666 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), | 666 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), |
| 667 &rules); | 667 &rules); |
| 668 Send(new ChromeViewMsg_SetContentSettingRules(rules)); | 668 Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 | 671 |
| 672 void TabSpecificContentSettings::AddSiteDataObserver( | 672 void TabSpecificContentSettings::AddSiteDataObserver( |
| 673 SiteDataObserver* observer) { | 673 SiteDataObserver* observer) { |
| 674 observer_list_.AddObserver(observer); | 674 observer_list_.AddObserver(observer); |
| 675 } | 675 } |
| 676 | 676 |
| 677 void TabSpecificContentSettings::RemoveSiteDataObserver( | 677 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 678 SiteDataObserver* observer) { | 678 SiteDataObserver* observer) { |
| 679 observer_list_.RemoveObserver(observer); | 679 observer_list_.RemoveObserver(observer); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void TabSpecificContentSettings::NotifySiteDataObservers() { | 682 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 683 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 683 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 684 } | 684 } |
| OLD | NEW |