OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 | 13 |
| 14 using content::NavigationEntry; |
| 15 |
14 // InfoBarDelegate ------------------------------------------------------------ | 16 // InfoBarDelegate ------------------------------------------------------------ |
15 | 17 |
16 InfoBarDelegate::~InfoBarDelegate() { | 18 InfoBarDelegate::~InfoBarDelegate() { |
17 } | 19 } |
18 | 20 |
19 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | 21 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { |
20 return false; | 22 return false; |
21 } | 23 } |
22 | 24 |
23 bool InfoBarDelegate::ShouldExpire( | 25 bool InfoBarDelegate::ShouldExpire( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 78 |
77 InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) | 79 InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) |
78 : contents_unique_id_(0), | 80 : contents_unique_id_(0), |
79 owner_(infobar_helper) { | 81 owner_(infobar_helper) { |
80 if (infobar_helper) | 82 if (infobar_helper) |
81 StoreActiveEntryUniqueID(infobar_helper); | 83 StoreActiveEntryUniqueID(infobar_helper); |
82 } | 84 } |
83 | 85 |
84 void InfoBarDelegate::StoreActiveEntryUniqueID( | 86 void InfoBarDelegate::StoreActiveEntryUniqueID( |
85 InfoBarTabHelper* infobar_helper) { | 87 InfoBarTabHelper* infobar_helper) { |
86 content::NavigationEntry* active_entry = | 88 NavigationEntry* active_entry = |
87 infobar_helper->web_contents()->GetController().GetActiveEntry(); | 89 infobar_helper->web_contents()->GetController().GetActiveEntry(); |
88 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; | 90 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; |
89 } | 91 } |
90 | 92 |
91 bool InfoBarDelegate::ShouldExpireInternal( | 93 bool InfoBarDelegate::ShouldExpireInternal( |
92 const content::LoadCommittedDetails& details) const { | 94 const content::LoadCommittedDetails& details) const { |
93 return (contents_unique_id_ != details.entry->GetUniqueID()) || | 95 return (contents_unique_id_ != details.entry->GetUniqueID()) || |
94 (content::PageTransitionStripQualifier( | 96 (content::PageTransitionStripQualifier( |
95 details.entry->GetTransitionType()) == | 97 details.entry->GetTransitionType()) == |
96 content::PAGE_TRANSITION_RELOAD); | 98 content::PAGE_TRANSITION_RELOAD); |
97 } | 99 } |
98 | 100 |
99 void InfoBarDelegate::RemoveSelf() { | 101 void InfoBarDelegate::RemoveSelf() { |
100 if (owner_) | 102 if (owner_) |
101 owner_->RemoveInfoBar(this); // Clears |owner_|. | 103 owner_->RemoveInfoBar(this); // Clears |owner_|. |
102 } | 104 } |
OLD | NEW |