| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 infobar_delegates_.erase(it); | 883 infobar_delegates_.erase(it); |
| 884 | 884 |
| 885 // Remove ourselves as an observer if we are tracking no more InfoBars. | 885 // Remove ourselves as an observer if we are tracking no more InfoBars. |
| 886 if (infobar_delegates_.empty()) { | 886 if (infobar_delegates_.empty()) { |
| 887 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, | 887 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 888 Source<NavigationController>(&controller_)); | 888 Source<NavigationController>(&controller_)); |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 } | 891 } |
| 892 | 892 |
| 893 void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate, |
| 894 InfoBarDelegate* new_delegate) { |
| 895 std::vector<InfoBarDelegate*>::iterator it = |
| 896 find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate); |
| 897 DCHECK(it != infobar_delegates_.end()); |
| 898 |
| 899 // Notify the container about the change of plans. |
| 900 scoped_ptr<std::pair<InfoBarDelegate*, InfoBarDelegate*> > details( |
| 901 new std::pair<InfoBarDelegate*, InfoBarDelegate*>( |
| 902 old_delegate, new_delegate)); |
| 903 NotificationService::current()->Notify( |
| 904 NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, |
| 905 Source<TabContents>(this), |
| 906 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get())); |
| 907 |
| 908 // Remove the old one. |
| 909 infobar_delegates_.erase(it); |
| 910 |
| 911 // Add the new one. |
| 912 infobar_delegates_.push_back(new_delegate); |
| 913 } |
| 914 |
| 893 bool TabContents::IsBookmarkBarAlwaysVisible() { | 915 bool TabContents::IsBookmarkBarAlwaysVisible() { |
| 894 // See GetDOMUIForCurrentState() comment for more info. This case is very | 916 // See GetDOMUIForCurrentState() comment for more info. This case is very |
| 895 // similar, but for non-first loads, we want to use the committed entry. This | 917 // similar, but for non-first loads, we want to use the committed entry. This |
| 896 // is so the bookmarks bar disappears at the same time the page does. | 918 // is so the bookmarks bar disappears at the same time the page does. |
| 897 if (controller_.GetLastCommittedEntry()) { | 919 if (controller_.GetLastCommittedEntry()) { |
| 898 // Not the first load, always use the committed DOM UI. | 920 // Not the first load, always use the committed DOM UI. |
| 899 if (render_manager_.dom_ui()) | 921 if (render_manager_.dom_ui()) |
| 900 return render_manager_.dom_ui()->force_bookmark_bar_visible(); | 922 return render_manager_.dom_ui()->force_bookmark_bar_visible(); |
| 901 return false; // Default. | 923 return false; // Default. |
| 902 } | 924 } |
| (...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 NavigationController::LoadCommittedDetails& committed_details = | 2403 NavigationController::LoadCommittedDetails& committed_details = |
| 2382 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 2404 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 2383 ExpireInfoBars(committed_details); | 2405 ExpireInfoBars(committed_details); |
| 2384 break; | 2406 break; |
| 2385 } | 2407 } |
| 2386 | 2408 |
| 2387 default: | 2409 default: |
| 2388 NOTREACHED(); | 2410 NOTREACHED(); |
| 2389 } | 2411 } |
| 2390 } | 2412 } |
| OLD | NEW |