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/infobars/infobar_delegate.h" | 5 #include "chrome/browser/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/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service) | 94 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service) |
95 : contents_unique_id_(0), | 95 : contents_unique_id_(0), |
96 owner_(infobar_service) { | 96 owner_(infobar_service) { |
97 if (infobar_service) | 97 if (infobar_service) |
98 StoreActiveEntryUniqueID(); | 98 StoreActiveEntryUniqueID(); |
99 } | 99 } |
100 | 100 |
101 void InfoBarDelegate::StoreActiveEntryUniqueID() { | 101 void InfoBarDelegate::StoreActiveEntryUniqueID() { |
102 content::WebContents* web_contents = owner_->GetWebContents(); | 102 content::WebContents* web_contents = owner_->web_contents(); |
103 DCHECK(web_contents); | 103 DCHECK(web_contents); |
104 NavigationEntry* active_entry = | 104 NavigationEntry* active_entry = |
105 web_contents->GetController().GetActiveEntry(); | 105 web_contents->GetController().GetActiveEntry(); |
106 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; | 106 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; |
107 } | 107 } |
108 | 108 |
109 bool InfoBarDelegate::ShouldExpireInternal( | 109 bool InfoBarDelegate::ShouldExpireInternal( |
110 const content::LoadCommittedDetails& details) const { | 110 const content::LoadCommittedDetails& details) const { |
111 // NOTE: If you change this, be sure to check and adjust the behavior of | 111 // NOTE: If you change this, be sure to check and adjust the behavior of |
112 // anyone who overrides this as necessary! | 112 // anyone who overrides this as necessary! |
113 return (contents_unique_id_ != details.entry->GetUniqueID()) || | 113 return (contents_unique_id_ != details.entry->GetUniqueID()) || |
114 (content::PageTransitionStripQualifier( | 114 (content::PageTransitionStripQualifier( |
115 details.entry->GetTransitionType()) == | 115 details.entry->GetTransitionType()) == |
116 content::PAGE_TRANSITION_RELOAD); | 116 content::PAGE_TRANSITION_RELOAD); |
117 } | 117 } |
118 | 118 |
119 void InfoBarDelegate::RemoveSelf() { | 119 void InfoBarDelegate::RemoveSelf() { |
120 if (owner_) | 120 if (owner_) |
121 owner_->RemoveInfoBar(this); // Clears |owner_|. | 121 owner_->RemoveInfoBar(this); // Clears |owner_|. |
122 } | 122 } |
OLD | NEW |