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

Side by Side Diff: chrome/browser/ui/website_settings/website_settings_unittest.cc

Issue 10837049: Fix memory leak in WebsiteSettingsTest.ShowInfoBar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delete InfoBarDelegate via InfoBarClosed() method. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | 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/website_settings/website_settings.h" 5 #include "chrome/browser/ui/website_settings/website_settings.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/content_settings/host_content_settings_map.h" 11 #include "chrome/browser/content_settings/host_content_settings_map.h"
12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
13 #include "chrome/browser/infobars/infobar_delegate.h"
13 #include "chrome/browser/infobars/infobar_tab_helper.h" 14 #include "chrome/browser/infobars/infobar_tab_helper.h"
14 #include "chrome/browser/ui/website_settings/website_settings_ui.h" 15 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
15 #include "chrome/common/content_settings.h" 16 #include "chrome/common/content_settings.h"
16 #include "chrome/common/content_settings_types.h" 17 #include "chrome/common/content_settings_types.h"
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/browser/cert_store.h" 20 #include "content/public/browser/cert_store.h"
20 #include "content/public/common/ssl_status.h" 21 #include "content/public/common/ssl_status.h"
21 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread.h"
22 #include "net/base/cert_status_flags.h" 23 #include "net/base/cert_status_flags.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 335 }
335 336
336 TEST_F(WebsiteSettingsTest, ShowInfoBar) { 337 TEST_F(WebsiteSettingsTest, ShowInfoBar) {
337 SetDefaultUIExpectations(mock_ui()); 338 SetDefaultUIExpectations(mock_ui());
338 EXPECT_EQ(0u, infobar_tab_helper()->infobar_count()); 339 EXPECT_EQ(0u, infobar_tab_helper()->infobar_count());
339 website_settings()->OnSitePermissionChanged( 340 website_settings()->OnSitePermissionChanged(
340 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); 341 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW);
341 website_settings()->OnUIClosing(); 342 website_settings()->OnUIClosing();
342 EXPECT_EQ(1u, infobar_tab_helper()->infobar_count()); 343 EXPECT_EQ(1u, infobar_tab_helper()->infobar_count());
343 344
344 infobar_tab_helper()->RemoveInfoBar( 345 // Removing an |InfoBarDelegate| from the |InfoBarTabHelper| does not delete
346 // it. Hence the |delegate| must be cleaned up after it was removed from the
347 // |infobar_tab_helper|.
348 scoped_ptr<InfoBarDelegate> delegate(
345 infobar_tab_helper()->GetInfoBarDelegateAt(0)); 349 infobar_tab_helper()->GetInfoBarDelegateAt(0));
350 infobar_tab_helper()->RemoveInfoBar(delegate.get());
351 // Right now InfoBarDelegates delete themselves via
352 // InfoBarClosed(); once InfoBars own their delegates, this can become a
353 // simple reset() call
354 delegate.release()->InfoBarClosed();
346 } 355 }
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698