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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/defaults.h" | 9 #include "chrome/browser/defaults.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 return IsNTP(web_contents()); | 70 return IsNTP(web_contents()); |
71 } | 71 } |
72 | 72 |
73 BookmarkTabHelper::BookmarkTabHelper(content::WebContents* web_contents) | 73 BookmarkTabHelper::BookmarkTabHelper(content::WebContents* web_contents) |
74 : content::WebContentsObserver(web_contents), | 74 : content::WebContentsObserver(web_contents), |
75 is_starred_(false), | 75 is_starred_(false), |
76 bookmark_model_(NULL), | 76 bookmark_model_(NULL), |
77 delegate_(NULL), | 77 delegate_(NULL), |
78 bookmark_drag_(NULL) { | 78 bookmark_drag_(NULL) { |
79 Profile* profile = | 79 bookmark_model_ = BookmarkModelFactory::GetForBrowserContext( |
80 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 80 web_contents->GetBrowserContext()); |
81 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); | |
82 if (bookmark_model_) | 81 if (bookmark_model_) |
83 bookmark_model_->AddObserver(this); | 82 bookmark_model_->AddObserver(this); |
84 } | 83 } |
85 | 84 |
86 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { | 85 void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { |
87 const bool old_state = is_starred_; | 86 const bool old_state = is_starred_; |
88 is_starred_ = (bookmark_model_ && | 87 is_starred_ = (bookmark_model_ && |
89 bookmark_model_->IsBookmarked(chrome::GetURLToBookmark(web_contents()))); | 88 bookmark_model_->IsBookmarked(chrome::GetURLToBookmark(web_contents()))); |
90 | 89 |
91 if (is_starred_ != old_state && delegate_) | 90 if (is_starred_ != old_state && delegate_) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 void BookmarkTabHelper::DidAttachInterstitialPage() { | 140 void BookmarkTabHelper::DidAttachInterstitialPage() { |
142 // Interstitials are not necessarily starred just because the page that | 141 // Interstitials are not necessarily starred just because the page that |
143 // created them is, so star state has to track interstitial attach/detach if | 142 // created them is, so star state has to track interstitial attach/detach if |
144 // necessary. | 143 // necessary. |
145 UpdateStarredStateForCurrentURL(); | 144 UpdateStarredStateForCurrentURL(); |
146 } | 145 } |
147 | 146 |
148 void BookmarkTabHelper::DidDetachInterstitialPage() { | 147 void BookmarkTabHelper::DidDetachInterstitialPage() { |
149 UpdateStarredStateForCurrentURL(); | 148 UpdateStarredStateForCurrentURL(); |
150 } | 149 } |
OLD | NEW |