Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 14326003: Prevent Chrome from crashing if a tab is closed while the media settings bubble is opea and a setti… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/content_settings_utils.h" 9 #include "chrome/browser/content_settings/content_settings_utils.h"
10 #include "chrome/browser/content_settings/cookie_settings.h" 10 #include "chrome/browser/content_settings/cookie_settings.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 WebContents* web_contents, 439 WebContents* web_contents,
440 Profile* profile, 440 Profile* profile,
441 ContentSettingsType content_type) 441 ContentSettingsType content_type)
442 : ContentSettingSingleRadioGroup( 442 : ContentSettingSingleRadioGroup(
443 delegate, web_contents, profile, content_type) { 443 delegate, web_contents, profile, content_type) {
444 DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type); 444 DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type);
445 set_custom_link_enabled(true); 445 set_custom_link_enabled(true);
446 } 446 }
447 447
448 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() { 448 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() {
449 if (settings_changed()) { 449 // On some plattforms e.g. MacOS X it is possible to close a tab while the
450 // cookies settubgs bubble is open. This resets the web contents to NULL.
451 if (settings_changed() && web_contents()) {
450 CollectedCookiesInfoBarDelegate::Create( 452 CollectedCookiesInfoBarDelegate::Create(
451 InfoBarService::FromWebContents(web_contents())); 453 InfoBarService::FromWebContents(web_contents()));
452 } 454 }
453 } 455 }
454 456
455 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() { 457 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() {
456 if (!web_contents()) 458 if (!web_contents())
457 return; 459 return;
458 content::NotificationService::current()->Notify( 460 content::NotificationService::current()->Notify(
459 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 461 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // buttons. 605 // buttons.
604 radio_item_setting_[0] = CONTENT_SETTING_ASK; 606 radio_item_setting_[0] = CONTENT_SETTING_ASK;
605 radio_item_setting_[1] = CONTENT_SETTING_BLOCK; 607 radio_item_setting_[1] = CONTENT_SETTING_BLOCK;
606 608
607 SetTitle(); 609 SetTitle();
608 SetRadioGroup(); 610 SetRadioGroup();
609 SetMediaMenus(); 611 SetMediaMenus();
610 } 612 }
611 613
612 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { 614 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() {
615 // On some plattforms e.g. MacOS X it is possible to close a tab while the
616 // media stream bubble is open. This resets the web contents to NULL.
617 if (!web_contents())
618 return;
613 bool media_setting_changed = false; 619 bool media_setting_changed = false;
614 for (MediaMenuMap::const_iterator it = bubble_content().media_menus.begin(); 620 for (MediaMenuMap::const_iterator it = bubble_content().media_menus.begin();
615 it != bubble_content().media_menus.end(); ++it) { 621 it != bubble_content().media_menus.end(); ++it) {
616 if (it->second.selected_device.id != it->second.default_device.id) { 622 if (it->second.selected_device.id != it->second.default_device.id) {
617 UpdateDefaultDeviceForType(it->first, it->second.selected_device.id); 623 UpdateDefaultDeviceForType(it->first, it->second.selected_device.id);
618 media_setting_changed = true; 624 media_setting_changed = true;
619 } 625 }
620 } 626 }
621 627
622 // Update the media settings if the radio button selection was changed. 628 // Update the media settings if the radio button selection was changed.
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1117 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1112 DCHECK_EQ(web_contents_, 1118 DCHECK_EQ(web_contents_,
1113 content::Source<WebContents>(source).ptr()); 1119 content::Source<WebContents>(source).ptr());
1114 web_contents_ = NULL; 1120 web_contents_ = NULL;
1115 } else { 1121 } else {
1116 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1122 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1117 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1123 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1118 profile_ = NULL; 1124 profile_ = NULL;
1119 } 1125 }
1120 } 1126 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698