| 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/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" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 12 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 12 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 13 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 13 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 bool CanShowBookmarkBar(WebUI* ui) { | 21 bool CanShowBookmarkBar(WebUI* ui) { |
| 22 if (!ui) | 22 if (!ui) |
| 23 return false; | 23 return false; |
| 24 NewTabUI* new_tab = NewTabUI::FromWebUI(ui); | 24 NewTabUI* new_tab = NewTabUI::FromWebUIController(ui->GetController()); |
| 25 return new_tab && new_tab->CanShowBookmarkBar(); | 25 return new_tab && new_tab->CanShowBookmarkBar(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 BookmarkTabHelper::BookmarkTabHelper(TabContentsWrapper* tab_contents) | 30 BookmarkTabHelper::BookmarkTabHelper(TabContentsWrapper* tab_contents) |
| 31 : content::WebContentsObserver(tab_contents->web_contents()), | 31 : content::WebContentsObserver(tab_contents->web_contents()), |
| 32 is_starred_(false), | 32 is_starred_(false), |
| 33 tab_contents_wrapper_(tab_contents), | 33 tab_contents_wrapper_(tab_contents), |
| 34 delegate_(NULL), | 34 delegate_(NULL), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { | 106 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { |
| 107 Profile* profile = | 107 Profile* profile = |
| 108 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 108 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 109 BookmarkModel* model = profile->GetBookmarkModel(); | 109 BookmarkModel* model = profile->GetBookmarkModel(); |
| 110 const bool old_state = is_starred_; | 110 const bool old_state = is_starred_; |
| 111 is_starred_ = (model && model->IsBookmarked(web_contents()->GetURL())); | 111 is_starred_ = (model && model->IsBookmarked(web_contents()->GetURL())); |
| 112 | 112 |
| 113 if (is_starred_ != old_state && delegate()) | 113 if (is_starred_ != old_state && delegate()) |
| 114 delegate()->URLStarredChanged(tab_contents_wrapper_, is_starred_); | 114 delegate()->URLStarredChanged(tab_contents_wrapper_, is_starred_); |
| 115 } | 115 } |
| OLD | NEW |