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