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

Side by Side Diff: chrome/browser/api/infobars/infobar_delegate.cc

Issue 11748012: Minor cleanup to how infobars handle expiry: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
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/api/infobars/infobar_delegate.h" 5 #include "chrome/browser/api/infobars/infobar_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { 93 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
94 return NULL; 94 return NULL;
95 } 95 }
96 96
97 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service) 97 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service)
98 : contents_unique_id_(0), 98 : contents_unique_id_(0),
99 owner_(infobar_service) { 99 owner_(infobar_service) {
100 if (infobar_service) 100 if (infobar_service)
101 StoreActiveEntryUniqueID(infobar_service); 101 StoreActiveEntryUniqueID();
102 } 102 }
103 103
104 void InfoBarDelegate::StoreActiveEntryUniqueID( 104 void InfoBarDelegate::StoreActiveEntryUniqueID() {
105 InfoBarService* infobar_service) { 105 content::WebContents* web_contents = owner_->GetWebContents();
106 DCHECK(web_contents);
106 NavigationEntry* active_entry = 107 NavigationEntry* active_entry =
107 infobar_service->GetWebContents()->GetController().GetActiveEntry(); 108 web_contents->GetController().GetActiveEntry();
108 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; 109 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
109 } 110 }
110 111
111 bool InfoBarDelegate::ShouldExpireInternal( 112 bool InfoBarDelegate::ShouldExpireInternal(
112 const content::LoadCommittedDetails& details) const { 113 const content::LoadCommittedDetails& details) const {
114 // NOTE: If you change this, be sure to check and adjust the behavior of
115 // anyone who overrides this as necessary!
113 return (contents_unique_id_ != details.entry->GetUniqueID()) || 116 return (contents_unique_id_ != details.entry->GetUniqueID()) ||
114 (content::PageTransitionStripQualifier( 117 (content::PageTransitionStripQualifier(
115 details.entry->GetTransitionType()) == 118 details.entry->GetTransitionType()) ==
116 content::PAGE_TRANSITION_RELOAD); 119 content::PAGE_TRANSITION_RELOAD);
117 } 120 }
118 121
119 void InfoBarDelegate::RemoveSelf() { 122 void InfoBarDelegate::RemoveSelf() {
120 if (owner_) 123 if (owner_)
121 owner_->RemoveInfoBar(this); // Clears |owner_|. 124 owner_->RemoveInfoBar(this); // Clears |owner_|.
122 } 125 }
OLDNEW
« no previous file with comments | « chrome/browser/api/infobars/infobar_delegate.h ('k') | chrome/browser/autofill/autofill_cc_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698