| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content_settings/content_setting_bubble_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 WebContents* web_contents, | 538 WebContents* web_contents, |
| 539 Profile* profile, | 539 Profile* profile, |
| 540 ContentSettingsType content_type) | 540 ContentSettingsType content_type) |
| 541 : ContentSettingSingleRadioGroup( | 541 : ContentSettingSingleRadioGroup( |
| 542 delegate, web_contents, profile, content_type) { | 542 delegate, web_contents, profile, content_type) { |
| 543 SetPopups(); | 543 SetPopups(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 | 546 |
| 547 void ContentSettingPopupBubbleModel::SetPopups() { | 547 void ContentSettingPopupBubbleModel::SetPopups() { |
| 548 if (CommandLine::ForCurrentProcess()->HasSwitch( | 548 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 549 switches::kEnableBetterPopupBlocking)) { | 549 switches::kDisableBetterPopupBlocking)) { |
| 550 std::map<int32, GURL> blocked_popups = | 550 std::map<int32, GURL> blocked_popups = |
| 551 PopupBlockerTabHelper::FromWebContents(web_contents()) | 551 PopupBlockerTabHelper::FromWebContents(web_contents()) |
| 552 ->GetBlockedPopupRequests(); | 552 ->GetBlockedPopupRequests(); |
| 553 for (std::map<int32, GURL>::const_iterator iter = blocked_popups.begin(); | 553 for (std::map<int32, GURL>::const_iterator iter = blocked_popups.begin(); |
| 554 iter != blocked_popups.end(); | 554 iter != blocked_popups.end(); |
| 555 ++iter) { | 555 ++iter) { |
| 556 std::string title(iter->second.spec()); | 556 std::string title(iter->second.spec()); |
| 557 // The popup may not have a valid URL. | 557 // The popup may not have a valid URL. |
| 558 if (title.empty()) | 558 if (title.empty()) |
| 559 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); | 559 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 577 if (title.empty()) | 577 if (title.empty()) |
| 578 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); | 578 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); |
| 579 PopupItem popup_item( | 579 PopupItem popup_item( |
| 580 FaviconTabHelper::FromWebContents(*i)->GetFavicon(), title, *i); | 580 FaviconTabHelper::FromWebContents(*i)->GetFavicon(), title, *i); |
| 581 add_popup(popup_item); | 581 add_popup(popup_item); |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { | 585 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { |
| 586 if (web_contents()) { | 586 if (web_contents()) { |
| 587 if (CommandLine::ForCurrentProcess()->HasSwitch( | 587 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 588 switches::kEnableBetterPopupBlocking)) { | 588 switches::kDisableBetterPopupBlocking)) { |
| 589 PopupBlockerTabHelper::FromWebContents(web_contents())-> | 589 PopupBlockerTabHelper::FromWebContents(web_contents())-> |
| 590 ShowBlockedPopup(bubble_content().popup_items[index].popup_id); | 590 ShowBlockedPopup(bubble_content().popup_items[index].popup_id); |
| 591 } else { | 591 } else { |
| 592 BlockedContentTabHelper::FromWebContents(web_contents())-> | 592 BlockedContentTabHelper::FromWebContents(web_contents())-> |
| 593 LaunchForContents(bubble_content().popup_items[index].web_contents); | 593 LaunchForContents(bubble_content().popup_items[index].web_contents); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 // The model of the content settings bubble for media settings. | 598 // The model of the content settings bubble for media settings. |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1248 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1249 DCHECK_EQ(web_contents_, | 1249 DCHECK_EQ(web_contents_, |
| 1250 content::Source<WebContents>(source).ptr()); | 1250 content::Source<WebContents>(source).ptr()); |
| 1251 web_contents_ = NULL; | 1251 web_contents_ = NULL; |
| 1252 } else { | 1252 } else { |
| 1253 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1253 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1254 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1254 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1255 profile_ = NULL; | 1255 profile_ = NULL; |
| 1256 } | 1256 } |
| 1257 } | 1257 } |
| OLD | NEW |