| 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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.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/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_details.h" | 18 #include "content/public/browser/navigation_details.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
| 23 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 23 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 24 | 24 |
| 25 #if defined(OS_ANDROID) | 25 #if defined(ANDROID_JAVA_UI) |
| 26 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 26 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 using blink::WebWindowFeatures; | 29 using blink::WebWindowFeatures; |
| 30 | 30 |
| 31 const size_t kMaximumNumberOfPopups = 25; | 31 const size_t kMaximumNumberOfPopups = 25; |
| 32 | 32 |
| 33 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PopupBlockerTabHelper); | 33 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PopupBlockerTabHelper); |
| 34 | 34 |
| 35 struct PopupBlockerTabHelper::BlockedRequest { | 35 struct PopupBlockerTabHelper::BlockedRequest { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); | 113 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PopupBlockerTabHelper::ShowBlockedPopup(int32 id) { | 117 void PopupBlockerTabHelper::ShowBlockedPopup(int32 id) { |
| 118 BlockedRequest* popup = blocked_popups_.Lookup(id); | 118 BlockedRequest* popup = blocked_popups_.Lookup(id); |
| 119 if (!popup) | 119 if (!popup) |
| 120 return; | 120 return; |
| 121 // We set user_gesture to true here, so the new popup gets correctly focused. | 121 // We set user_gesture to true here, so the new popup gets correctly focused. |
| 122 popup->params.user_gesture = true; | 122 popup->params.user_gesture = true; |
| 123 #if defined(OS_ANDROID) | 123 #if defined(ANDROID_JAVA_UI) |
| 124 TabModelList::HandlePopupNavigation(&popup->params); | 124 TabModelList::HandlePopupNavigation(&popup->params); |
| 125 #else | 125 #else |
| 126 chrome::Navigate(&popup->params); | 126 chrome::Navigate(&popup->params); |
| 127 #endif | 127 #endif |
| 128 if (popup->params.target_contents) { | 128 if (popup->params.target_contents) { |
| 129 popup->params.target_contents->Send(new ChromeViewMsg_SetWindowFeatures( | 129 popup->params.target_contents->Send(new ChromeViewMsg_SetWindowFeatures( |
| 130 popup->params.target_contents->GetRoutingID(), popup->window_features)); | 130 popup->params.target_contents->GetRoutingID(), popup->window_features)); |
| 131 } | 131 } |
| 132 blocked_popups_.Remove(id); | 132 blocked_popups_.Remove(id); |
| 133 if (blocked_popups_.IsEmpty()) | 133 if (blocked_popups_.IsEmpty()) |
| 134 PopupNotificationVisibilityChanged(false); | 134 PopupNotificationVisibilityChanged(false); |
| 135 } | 135 } |
| 136 | 136 |
| 137 size_t PopupBlockerTabHelper::GetBlockedPopupsCount() const { | 137 size_t PopupBlockerTabHelper::GetBlockedPopupsCount() const { |
| 138 return blocked_popups_.size(); | 138 return blocked_popups_.size(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 PopupBlockerTabHelper::PopupIdMap | 141 PopupBlockerTabHelper::PopupIdMap |
| 142 PopupBlockerTabHelper::GetBlockedPopupRequests() { | 142 PopupBlockerTabHelper::GetBlockedPopupRequests() { |
| 143 PopupIdMap result; | 143 PopupIdMap result; |
| 144 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( | 144 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( |
| 145 &blocked_popups_); | 145 &blocked_popups_); |
| 146 !iter.IsAtEnd(); | 146 !iter.IsAtEnd(); |
| 147 iter.Advance()) { | 147 iter.Advance()) { |
| 148 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; | 148 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; |
| 149 } | 149 } |
| 150 return result; | 150 return result; |
| 151 } | 151 } |
| OLD | NEW |