| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/bookmarks/bookmark_tab_helper.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 8 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 BookmarkTabHelper::~BookmarkTabHelper() { | 42 BookmarkTabHelper::~BookmarkTabHelper() { |
| 43 // We don't want any notifications while we're running our destructor. | 43 // We don't want any notifications while we're running our destructor. |
| 44 registrar_.RemoveAll(); | 44 registrar_.RemoveAll(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool BookmarkTabHelper::ShouldShowBookmarkBar() { | 47 bool BookmarkTabHelper::ShouldShowBookmarkBar() { |
| 48 if (web_contents()->ShowingInterstitialPage()) | 48 if (web_contents()->ShowingInterstitialPage()) |
| 49 return false; | 49 return false; |
| 50 | 50 |
| 51 // See TabContents::GetWebUIForCurrentState() comment for more info. This case | 51 // See WebContents::GetWebUIForCurrentState() comment for more info. This case |
| 52 // is very similar, but for non-first loads, we want to use the committed | 52 // is very similar, but for non-first loads, we want to use the committed |
| 53 // entry. This is so the bookmarks bar disappears at the same time the page | 53 // entry. This is so the bookmarks bar disappears at the same time the page |
| 54 // does. | 54 // does. |
| 55 if (web_contents()->GetController().GetLastCommittedEntry()) { | 55 if (web_contents()->GetController().GetLastCommittedEntry()) { |
| 56 // Not the first load, always use the committed Web UI. | 56 // Not the first load, always use the committed Web UI. |
| 57 return CanShowBookmarkBar(web_contents()->GetCommittedWebUI()); | 57 return CanShowBookmarkBar(web_contents()->GetCommittedWebUI()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // When it's the first load, we know either the pending one or the committed | 60 // When it's the first load, we know either the pending one or the committed |
| 61 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one | 61 // one will have the Web UI in it (see GetWebUIForCurrentState), and only one |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { | 105 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { |
| 106 Profile* profile = | 106 Profile* profile = |
| 107 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 107 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 108 BookmarkModel* model = profile->GetBookmarkModel(); | 108 BookmarkModel* model = profile->GetBookmarkModel(); |
| 109 const bool old_state = is_starred_; | 109 const bool old_state = is_starred_; |
| 110 is_starred_ = (model && model->IsBookmarked(web_contents()->GetURL())); | 110 is_starred_ = (model && model->IsBookmarked(web_contents()->GetURL())); |
| 111 | 111 |
| 112 if (is_starred_ != old_state && delegate()) | 112 if (is_starred_ != old_state && delegate()) |
| 113 delegate()->URLStarredChanged(tab_contents_wrapper_, is_starred_); | 113 delegate()->URLStarredChanged(tab_contents_wrapper_, is_starred_); |
| 114 } | 114 } |
| OLD | NEW |