| 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 "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.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/infobars/infobar.h" | 9 #include "chrome/browser/infobars/infobar.h" |
| 10 #include "chrome/browser/infobars/infobar_manager.h" | |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 12 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 14 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
| 15 #include "chrome/common/content_settings_types.h" | 14 #include "chrome/common/content_settings_types.h" |
| 16 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 17 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 | 18 |
| 20 | 19 |
| 21 // static | 20 // static |
| 22 void PopupBlockedInfoBarDelegate::Create(content::WebContents* web_contents, | 21 void PopupBlockedInfoBarDelegate::Create(content::WebContents* web_contents, |
| 23 int num_popups) { | 22 int num_popups) { |
| 24 const GURL& url = web_contents->GetURL(); | 23 const GURL& url = web_contents->GetURL(); |
| 25 Profile* profile = | 24 Profile* profile = |
| 26 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 25 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 27 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( | 26 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 28 scoped_ptr<ConfirmInfoBarDelegate>( | 27 scoped_ptr<ConfirmInfoBarDelegate>( |
| 29 new PopupBlockedInfoBarDelegate( | 28 new PopupBlockedInfoBarDelegate( |
| 30 num_popups, url, profile->GetHostContentSettingsMap())))); | 29 num_popups, url, profile->GetHostContentSettingsMap())))); |
| 31 | 30 |
| 32 InfoBarManager* infobar_manager = | 31 InfoBarService* infobar_service = |
| 33 InfoBarService::FromWebContents(web_contents)->infobar_manager(); | 32 InfoBarService::FromWebContents(web_contents); |
| 34 // See if there is an existing popup infobar already. | 33 // See if there is an existing popup infobar already. |
| 35 // TODO(dfalcantara) When triggering more than one popup the infobar | 34 // TODO(dfalcantara) When triggering more than one popup the infobar |
| 36 // will be shown once, then hide then be shown again. | 35 // will be shown once, then hide then be shown again. |
| 37 // This will be fixed once we have an in place replace infobar mechanism. | 36 // This will be fixed once we have an in place replace infobar mechanism. |
| 38 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { | 37 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 39 InfoBar* existing_infobar = infobar_manager->infobar_at(i); | 38 InfoBar* existing_infobar = infobar_service->infobar_at(i); |
| 40 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) { | 39 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) { |
| 41 infobar_manager->ReplaceInfoBar(existing_infobar, infobar.Pass()); | 40 infobar_service->ReplaceInfoBar(existing_infobar, infobar.Pass()); |
| 42 return; | 41 return; |
| 43 } | 42 } |
| 44 } | 43 } |
| 45 | 44 |
| 46 infobar_manager->AddInfoBar(infobar.Pass()); | 45 infobar_service->AddInfoBar(infobar.Pass()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 PopupBlockedInfoBarDelegate::~PopupBlockedInfoBarDelegate() { | 48 PopupBlockedInfoBarDelegate::~PopupBlockedInfoBarDelegate() { |
| 50 } | 49 } |
| 51 | 50 |
| 52 int PopupBlockedInfoBarDelegate::GetIconID() const { | 51 int PopupBlockedInfoBarDelegate::GetIconID() const { |
| 53 return IDR_BLOCKED_POPUPS; | 52 return IDR_BLOCKED_POPUPS; |
| 54 } | 53 } |
| 55 | 54 |
| 56 PopupBlockedInfoBarDelegate* | 55 PopupBlockedInfoBarDelegate* |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 DCHECK(popup_blocker_helper); | 104 DCHECK(popup_blocker_helper); |
| 106 PopupBlockerTabHelper::PopupIdMap blocked_popups = | 105 PopupBlockerTabHelper::PopupIdMap blocked_popups = |
| 107 popup_blocker_helper->GetBlockedPopupRequests(); | 106 popup_blocker_helper->GetBlockedPopupRequests(); |
| 108 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin(); | 107 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin(); |
| 109 it != blocked_popups.end(); ++it) | 108 it != blocked_popups.end(); ++it) |
| 110 popup_blocker_helper->ShowBlockedPopup(it->first); | 109 popup_blocker_helper->ShowBlockedPopup(it->first); |
| 111 | 110 |
| 112 return true; | 111 return true; |
| 113 } | 112 } |
| 114 | 113 |
| OLD | NEW |