| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/content_settings_utils.h" | 8 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 9 #include "chrome/browser/content_settings/cookie_settings.h" | 9 #include "chrome/browser/content_settings/cookie_settings.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 TabContents* tab_contents, | 449 TabContents* tab_contents, |
| 450 Profile* profile, | 450 Profile* profile, |
| 451 ContentSettingsType content_type) | 451 ContentSettingsType content_type) |
| 452 : ContentSettingSingleRadioGroup( | 452 : ContentSettingSingleRadioGroup( |
| 453 delegate, tab_contents, profile, content_type) { | 453 delegate, tab_contents, profile, content_type) { |
| 454 SetPopups(); | 454 SetPopups(); |
| 455 } | 455 } |
| 456 | 456 |
| 457 | 457 |
| 458 void ContentSettingPopupBubbleModel::SetPopups() { | 458 void ContentSettingPopupBubbleModel::SetPopups() { |
| 459 std::vector<TabContents*> blocked_contents; | 459 std::vector<content::WebContents*> blocked_contents; |
| 460 tab_contents()->blocked_content_tab_helper()-> | 460 BlockedContentTabHelper::FromWebContents(tab_contents()->web_contents())-> |
| 461 GetBlockedContents(&blocked_contents); | 461 GetBlockedContents(&blocked_contents); |
| 462 for (std::vector<TabContents*>::const_iterator | 462 for (std::vector<content::WebContents*>::const_iterator |
| 463 i = blocked_contents.begin(); i != blocked_contents.end(); ++i) { | 463 i = blocked_contents.begin(); i != blocked_contents.end(); ++i) { |
| 464 std::string title(UTF16ToUTF8((*i)->web_contents()->GetTitle())); | 464 std::string title(UTF16ToUTF8((*i)->GetTitle())); |
| 465 // The popup may not have committed a load yet, in which case it won't | 465 // The popup may not have committed a load yet, in which case it won't |
| 466 // have a URL or title. | 466 // have a URL or title. |
| 467 if (title.empty()) | 467 if (title.empty()) |
| 468 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); | 468 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); |
| 469 PopupItem popup_item; | 469 PopupItem popup_item; |
| 470 popup_item.title = title; | 470 popup_item.title = title; |
| 471 // TODO: Make this use gfx::Image. | 471 // TODO: Make this use gfx::Image. |
| 472 popup_item.bitmap = (*i)->favicon_tab_helper()->GetFavicon().AsBitmap(); | 472 TabContents* tab_contents = TabContents::FromWebContents(*i); |
| 473 popup_item.tab_contents = (*i); | 473 popup_item.bitmap = |
| 474 tab_contents->favicon_tab_helper()->GetFavicon().AsBitmap(); |
| 475 popup_item.tab_contents = tab_contents; |
| 474 add_popup(popup_item); | 476 add_popup(popup_item); |
| 475 } | 477 } |
| 476 } | 478 } |
| 477 | 479 |
| 478 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { | 480 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { |
| 479 if (tab_contents()) { | 481 if (tab_contents()) { |
| 480 tab_contents()->blocked_content_tab_helper()-> | 482 BlockedContentTabHelper::FromWebContents(tab_contents()->web_contents())-> |
| 481 LaunchForContents(bubble_content().popup_items[index].tab_contents); | 483 LaunchForContents( |
| 484 bubble_content().popup_items[index].tab_contents->web_contents()); |
| 482 } | 485 } |
| 483 } | 486 } |
| 484 | 487 |
| 485 class ContentSettingDomainListBubbleModel | 488 class ContentSettingDomainListBubbleModel |
| 486 : public ContentSettingTitleAndLinkModel { | 489 : public ContentSettingTitleAndLinkModel { |
| 487 public: | 490 public: |
| 488 ContentSettingDomainListBubbleModel(Delegate* delegate, | 491 ContentSettingDomainListBubbleModel(Delegate* delegate, |
| 489 TabContents* tab_contents, | 492 TabContents* tab_contents, |
| 490 Profile* profile, | 493 Profile* profile, |
| 491 ContentSettingsType content_type); | 494 ContentSettingsType content_type); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 const content::NotificationDetails& details) { | 817 const content::NotificationDetails& details) { |
| 815 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) { | 818 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) { |
| 816 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr()); | 819 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr()); |
| 817 tab_contents_ = NULL; | 820 tab_contents_ = NULL; |
| 818 } else { | 821 } else { |
| 819 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 822 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 820 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 823 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 821 profile_ = NULL; | 824 profile_ = NULL; |
| 822 } | 825 } |
| 823 } | 826 } |
| OLD | NEW |