| 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/ui/blocked_content/blocked_content_tab_helper.h" | 5 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/blocked_content/blocked_content_container.h" | 11 #include "chrome/browser/ui/blocked_content/blocked_content_container.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "content/browser/renderer_host/render_view_host.h" | 13 #include "content/browser/renderer_host/render_view_host.h" |
| 14 #include "content/public/browser/navigation_details.h" | 14 #include "content/public/browser/navigation_details.h" |
| 15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 | 17 |
| 18 using content::NavigationEntry; |
| 19 |
| 18 BlockedContentTabHelper::BlockedContentTabHelper( | 20 BlockedContentTabHelper::BlockedContentTabHelper( |
| 19 TabContentsWrapper* tab_contents) | 21 TabContentsWrapper* tab_contents) |
| 20 : content::WebContentsObserver(tab_contents->web_contents()), | 22 : content::WebContentsObserver(tab_contents->web_contents()), |
| 21 blocked_contents_(new BlockedContentContainer(tab_contents)), | 23 blocked_contents_(new BlockedContentContainer(tab_contents)), |
| 22 all_contents_blocked_(false), | 24 all_contents_blocked_(false), |
| 23 tab_contents_wrapper_(tab_contents), | 25 tab_contents_wrapper_(tab_contents), |
| 24 delegate_(NULL) { | 26 delegate_(NULL) { |
| 25 } | 27 } |
| 26 | 28 |
| 27 BlockedContentTabHelper::~BlockedContentTabHelper() { | 29 BlockedContentTabHelper::~BlockedContentTabHelper() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents, | 76 void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents, |
| 75 const gfx::Rect& initial_pos, | 77 const gfx::Rect& initial_pos, |
| 76 bool user_gesture) { | 78 bool user_gesture) { |
| 77 // A page can't spawn popups (or do anything else, either) until its load | 79 // A page can't spawn popups (or do anything else, either) until its load |
| 78 // commits, so when we reach here, the popup was spawned by the | 80 // commits, so when we reach here, the popup was spawned by the |
| 79 // NavigationController's last committed entry, not the active entry. For | 81 // NavigationController's last committed entry, not the active entry. For |
| 80 // example, if a page opens a popup in an onunload() handler, then the active | 82 // example, if a page opens a popup in an onunload() handler, then the active |
| 81 // entry is the page to be loaded as we navigate away from the unloading | 83 // entry is the page to be loaded as we navigate away from the unloading |
| 82 // page. For this reason, we can't use GetURL() to get the opener URL, | 84 // page. For this reason, we can't use GetURL() to get the opener URL, |
| 83 // because it returns the active entry. | 85 // because it returns the active entry. |
| 84 content::NavigationEntry* entry = | 86 NavigationEntry* entry = |
| 85 web_contents()->GetController().GetLastCommittedEntry(); | 87 web_contents()->GetController().GetLastCommittedEntry(); |
| 86 GURL creator = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | 88 GURL creator = entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
| 87 Profile* profile = | 89 Profile* profile = |
| 88 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 90 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 89 | 91 |
| 90 if (creator.is_valid() && | 92 if (creator.is_valid() && |
| 91 profile->GetHostContentSettingsMap()->GetContentSetting( | 93 profile->GetHostContentSettingsMap()->GetContentSetting( |
| 92 creator, | 94 creator, |
| 93 creator, | 95 creator, |
| 94 CONTENT_SETTINGS_TYPE_POPUPS, | 96 CONTENT_SETTINGS_TYPE_POPUPS, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 } | 119 } |
| 118 | 120 |
| 119 size_t BlockedContentTabHelper::GetBlockedContentsCount() const { | 121 size_t BlockedContentTabHelper::GetBlockedContentsCount() const { |
| 120 return blocked_contents_->GetBlockedContentsCount(); | 122 return blocked_contents_->GetBlockedContentsCount(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void BlockedContentTabHelper::GetBlockedContents( | 125 void BlockedContentTabHelper::GetBlockedContents( |
| 124 std::vector<TabContentsWrapper*>* blocked_contents) const { | 126 std::vector<TabContentsWrapper*>* blocked_contents) const { |
| 125 blocked_contents_->GetBlockedContents(blocked_contents); | 127 blocked_contents_->GetBlockedContents(blocked_contents); |
| 126 } | 128 } |
| OLD | NEW |