| 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/tab_contents/infobar_delegate.h" | 5 #include "chrome/browser/tab_contents/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 "content/browser/tab_contents/navigation_details.h" | 9 #include "content/browser/tab_contents/navigation_details.h" |
| 10 #include "content/browser/tab_contents/navigation_entry.h" | 10 #include "content/browser/tab_contents/navigation_entry.h" |
| 11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
| 12 | 12 |
| 13 // InfoBarDelegate ------------------------------------------------------------ | 13 // InfoBarDelegate ------------------------------------------------------------ |
| 14 | 14 |
| 15 InfoBarDelegate::~InfoBarDelegate() { | 15 InfoBarDelegate::~InfoBarDelegate() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | 18 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { |
| 19 return false; | 19 return false; |
| 20 } | 20 } |
| 21 | 21 |
| 22 bool InfoBarDelegate::ShouldExpire( | 22 bool InfoBarDelegate::ShouldExpire( |
| 23 const content::LoadCommittedDetails& details) const { | 23 const content::LoadCommittedDetails& details) const { |
| 24 if (!details.is_navigation_to_different_page()) | 24 // Only hide InfoBars when the user has done something that makes the main |
| 25 // frame load. We don't want various automatic or subframe navigations making |
| 26 // it disappear. |
| 27 if (!details.is_user_initiated_main_frame_load()) |
| 25 return false; | 28 return false; |
| 26 | 29 |
| 27 return ShouldExpireInternal(details); | 30 return ShouldExpireInternal(details); |
| 28 } | 31 } |
| 29 | 32 |
| 30 bool InfoBarDelegate::ShouldExpireInternal( | 33 bool InfoBarDelegate::ShouldExpireInternal( |
| 31 const content::LoadCommittedDetails& details) const { | 34 const content::LoadCommittedDetails& details) const { |
| 32 return (contents_unique_id_ != details.entry->unique_id()) || | 35 return (contents_unique_id_ != details.entry->unique_id()) || |
| 33 (PageTransition::StripQualifier(details.entry->transition_type()) == | 36 (PageTransition::StripQualifier(details.entry->transition_type()) == |
| 34 PageTransition::RELOAD); | 37 PageTransition::RELOAD); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 InfoBarDelegate::InfoBarDelegate(TabContents* contents) | 86 InfoBarDelegate::InfoBarDelegate(TabContents* contents) |
| 84 : contents_unique_id_(0) { | 87 : contents_unique_id_(0) { |
| 85 if (contents) | 88 if (contents) |
| 86 StoreActiveEntryUniqueID(contents); | 89 StoreActiveEntryUniqueID(contents); |
| 87 } | 90 } |
| 88 | 91 |
| 89 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { | 92 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { |
| 90 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); | 93 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); |
| 91 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; | 94 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; |
| 92 } | 95 } |
| OLD | NEW |