Chromium Code Reviews| 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_controller.h" | 9 #include "content/browser/tab_contents/navigation_controller.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 NavigationController::LoadCommittedDetails& details) const { | 23 const NavigationController::LoadCommittedDetails& details) const { |
| 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()) | |
| 28 return false; | |
|
MAD
2011/05/17 16:25:55
Too much indent...
| |
| 29 | |
| 30 return ShouldExpireInternal(details); | |
| 31 } | |
| 32 | |
| 33 bool InfoBarDelegate::ShouldExpireInternal( | |
| 34 const NavigationController::LoadCommittedDetails& details) const { | |
| 24 return (contents_unique_id_ != details.entry->unique_id()) || | 35 return (contents_unique_id_ != details.entry->unique_id()) || |
| 25 (PageTransition::StripQualifier(details.entry->transition_type()) == | 36 (PageTransition::StripQualifier(details.entry->transition_type()) == |
| 26 PageTransition::RELOAD); | 37 PageTransition::RELOAD); |
| 27 } | 38 } |
| 28 | 39 |
| 29 void InfoBarDelegate::InfoBarDismissed() { | 40 void InfoBarDelegate::InfoBarDismissed() { |
| 30 } | 41 } |
| 31 | 42 |
| 32 void InfoBarDelegate::InfoBarClosed() { | 43 void InfoBarDelegate::InfoBarClosed() { |
| 33 delete this; | 44 delete this; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 InfoBarDelegate::InfoBarDelegate(TabContents* contents) | 81 InfoBarDelegate::InfoBarDelegate(TabContents* contents) |
| 71 : contents_unique_id_(0) { | 82 : contents_unique_id_(0) { |
| 72 if (contents) | 83 if (contents) |
| 73 StoreActiveEntryUniqueID(contents); | 84 StoreActiveEntryUniqueID(contents); |
| 74 } | 85 } |
| 75 | 86 |
| 76 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { | 87 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { |
| 77 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); | 88 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); |
| 78 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; | 89 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; |
| 79 } | 90 } |
| OLD | NEW |