| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/popup_blocker_tab_helper.h" | 5 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.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_window_params.h" | 11 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
| 12 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 13 #include "chrome/browser/ui/browser_navigator_params.h" | 13 #include "chrome/browser/ui/browser_navigator_params.h" |
| 14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
| 15 #include "components/content_settings/core/browser/host_content_settings_map.h" | 15 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 16 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 17 #include "content/public/browser/navigation_details.h" | |
| 18 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 18 #include "content/public/browser/navigation_handle.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 21 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 22 | 22 |
| 23 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 24 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 24 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 using blink::WebWindowFeatures; | 27 using blink::WebWindowFeatures; |
| 28 | 28 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 PopupBlockerTabHelper::PopupBlockerTabHelper( | 42 PopupBlockerTabHelper::PopupBlockerTabHelper( |
| 43 content::WebContents* web_contents) | 43 content::WebContents* web_contents) |
| 44 : content::WebContentsObserver(web_contents) { | 44 : content::WebContentsObserver(web_contents) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 PopupBlockerTabHelper::~PopupBlockerTabHelper() { | 47 PopupBlockerTabHelper::~PopupBlockerTabHelper() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void PopupBlockerTabHelper::DidNavigateMainFrame( | 50 void PopupBlockerTabHelper::DidFinishNavigation( |
| 51 const content::LoadCommittedDetails& details, | 51 content::NavigationHandle* navigation_handle) { |
| 52 const content::FrameNavigateParams& params) { | |
| 53 // Clear all page actions, blocked content notifications and browser actions | 52 // Clear all page actions, blocked content notifications and browser actions |
| 54 // for this tab, unless this is an in-page navigation. | 53 // for this tab, unless this is an in-page navigation. Also only consider |
| 55 if (details.is_in_page) | 54 // main frame navigations that successfully committed. |
| 55 if (!navigation_handle->IsInMainFrame() || |
| 56 !navigation_handle->HasCommitted() || |
| 57 navigation_handle->IsSamePage()) { |
| 56 return; | 58 return; |
| 59 } |
| 57 | 60 |
| 58 // Close blocked popups. | 61 // Close blocked popups. |
| 59 if (!blocked_popups_.IsEmpty()) { | 62 if (!blocked_popups_.IsEmpty()) { |
| 60 blocked_popups_.Clear(); | 63 blocked_popups_.Clear(); |
| 61 PopupNotificationVisibilityChanged(false); | 64 PopupNotificationVisibilityChanged(false); |
| 62 } | 65 } |
| 63 } | 66 } |
| 64 | 67 |
| 65 void PopupBlockerTabHelper::PopupNotificationVisibilityChanged( | 68 void PopupBlockerTabHelper::PopupNotificationVisibilityChanged( |
| 66 bool visible) { | 69 bool visible) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 PopupBlockerTabHelper::GetBlockedPopupRequests() { | 146 PopupBlockerTabHelper::GetBlockedPopupRequests() { |
| 144 PopupIdMap result; | 147 PopupIdMap result; |
| 145 for (IDMap<std::unique_ptr<BlockedRequest>>::const_iterator iter( | 148 for (IDMap<std::unique_ptr<BlockedRequest>>::const_iterator iter( |
| 146 &blocked_popups_); | 149 &blocked_popups_); |
| 147 !iter.IsAtEnd(); | 150 !iter.IsAtEnd(); |
| 148 iter.Advance()) { | 151 iter.Advance()) { |
| 149 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; | 152 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; |
| 150 } | 153 } |
| 151 return result; | 154 return result; |
| 152 } | 155 } |
| OLD | NEW |