| 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/android/content_settings/popup_blocked_infobar_deleg
ate.h" | 5 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 14 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 16 #include "components/content_settings/core/common/content_settings.h" | 17 #include "components/content_settings/core/common/content_settings.h" |
| 17 #include "components/content_settings/core/common/content_settings_types.h" | 18 #include "components/content_settings/core/common/content_settings_types.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 url, | 35 url, |
| 35 HostContentSettingsMapFactory::GetForProfile(profile))))); | 36 HostContentSettingsMapFactory::GetForProfile(profile))))); |
| 36 | 37 |
| 37 // See if there is an existing popup infobar already. | 38 // See if there is an existing popup infobar already. |
| 38 // TODO(dfalcantara) When triggering more than one popup the infobar | 39 // TODO(dfalcantara) When triggering more than one popup the infobar |
| 39 // will be shown once, then hide then be shown again. | 40 // will be shown once, then hide then be shown again. |
| 40 // This will be fixed once we have an in place replace infobar mechanism. | 41 // This will be fixed once we have an in place replace infobar mechanism. |
| 41 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 42 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 42 infobars::InfoBar* existing_infobar = infobar_service->infobar_at(i); | 43 infobars::InfoBar* existing_infobar = infobar_service->infobar_at(i); |
| 43 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) { | 44 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) { |
| 44 infobar_service->ReplaceInfoBar(existing_infobar, infobar.Pass()); | 45 infobar_service->ReplaceInfoBar(existing_infobar, std::move(infobar)); |
| 45 return; | 46 return; |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 | 49 |
| 49 infobar_service->AddInfoBar(infobar.Pass()); | 50 infobar_service->AddInfoBar(std::move(infobar)); |
| 50 } | 51 } |
| 51 | 52 |
| 52 PopupBlockedInfoBarDelegate::~PopupBlockedInfoBarDelegate() { | 53 PopupBlockedInfoBarDelegate::~PopupBlockedInfoBarDelegate() { |
| 53 } | 54 } |
| 54 | 55 |
| 55 int PopupBlockedInfoBarDelegate::GetIconId() const { | 56 int PopupBlockedInfoBarDelegate::GetIconId() const { |
| 56 return IDR_BLOCKED_POPUPS; | 57 return IDR_BLOCKED_POPUPS; |
| 57 } | 58 } |
| 58 | 59 |
| 59 PopupBlockedInfoBarDelegate* | 60 PopupBlockedInfoBarDelegate* |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 PopupBlockerTabHelper::FromWebContents(web_contents); | 105 PopupBlockerTabHelper::FromWebContents(web_contents); |
| 105 DCHECK(popup_blocker_helper); | 106 DCHECK(popup_blocker_helper); |
| 106 PopupBlockerTabHelper::PopupIdMap blocked_popups = | 107 PopupBlockerTabHelper::PopupIdMap blocked_popups = |
| 107 popup_blocker_helper->GetBlockedPopupRequests(); | 108 popup_blocker_helper->GetBlockedPopupRequests(); |
| 108 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin(); | 109 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin(); |
| 109 it != blocked_popups.end(); ++it) | 110 it != blocked_popups.end(); ++it) |
| 110 popup_blocker_helper->ShowBlockedPopup(it->first); | 111 popup_blocker_helper->ShowBlockedPopup(it->first); |
| 111 | 112 |
| 112 return true; | 113 return true; |
| 113 } | 114 } |
| OLD | NEW |