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 "chrome/browser/infobars/infobar_tab_helper.h" | |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 10 #include "content/browser/tab_contents/navigation_details.h" | 11 #include "content/browser/tab_contents/navigation_details.h" |
| 11 #include "content/browser/tab_contents/navigation_entry.h" | 12 #include "content/browser/tab_contents/navigation_entry.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 13 | 14 |
| 14 // InfoBarDelegate ------------------------------------------------------------ | 15 // InfoBarDelegate ------------------------------------------------------------ |
| 15 | 16 |
| 16 InfoBarDelegate::~InfoBarDelegate() { | 17 InfoBarDelegate::~InfoBarDelegate() { |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 InfoBarDelegate::AsThemePreviewInfobarDelegate() { | 70 InfoBarDelegate::AsThemePreviewInfobarDelegate() { |
| 70 return NULL; | 71 return NULL; |
| 71 } | 72 } |
| 72 | 73 |
| 73 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { | 74 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { |
| 74 return NULL; | 75 return NULL; |
| 75 } | 76 } |
| 76 | 77 |
| 77 InfoBarDelegate::InfoBarDelegate(TabContents* contents) | 78 InfoBarDelegate::InfoBarDelegate(TabContents* contents) |
| 78 : contents_unique_id_(0), | 79 : contents_unique_id_(0), |
| 79 owner_(contents) { | 80 owner_(contents) { |
|
Peter Kasting
2011/08/31 18:47:32
This |owner_| should also change to being an InfoB
| |
| 80 if (contents) | 81 if (contents) |
| 81 StoreActiveEntryUniqueID(contents); | 82 StoreActiveEntryUniqueID(contents); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { | 85 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { |
| 85 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); | 86 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); |
| 86 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; | 87 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; |
| 87 } | 88 } |
| 88 | 89 |
| 89 bool InfoBarDelegate::ShouldExpireInternal( | 90 bool InfoBarDelegate::ShouldExpireInternal( |
| 90 const content::LoadCommittedDetails& details) const { | 91 const content::LoadCommittedDetails& details) const { |
| 91 return (contents_unique_id_ != details.entry->unique_id()) || | 92 return (contents_unique_id_ != details.entry->unique_id()) || |
| 92 (PageTransition::StripQualifier(details.entry->transition_type()) == | 93 (PageTransition::StripQualifier(details.entry->transition_type()) == |
| 93 PageTransition::RELOAD); | 94 PageTransition::RELOAD); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void InfoBarDelegate::RemoveSelf() { | 97 void InfoBarDelegate::RemoveSelf() { |
| 97 if (owner_) { | 98 if (owner_) { |
| 98 TabContentsWrapper::GetCurrentWrapperForContents(owner_)-> | 99 TabContentsWrapper::GetCurrentWrapperForContents(owner_)-> |
| 99 RemoveInfoBar(this); // Clears |owner_|. | 100 infobar_tab_helper()->RemoveInfoBar(this); // Clears |owner_|. |
| 100 } | 101 } |
| 101 } | 102 } |
| OLD | NEW |