Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 10827047: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 17 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
18 #include "chrome/browser/bookmarks/bookmark_utils.h" 19 #include "chrome/browser/bookmarks/bookmark_utils.h"
19 #include "chrome/browser/browser_shutdown.h" 20 #include "chrome/browser/browser_shutdown.h"
20 #include "chrome/browser/defaults.h" 21 #include "chrome/browser/defaults.h"
21 #include "chrome/browser/event_disposition.h" 22 #include "chrome/browser/event_disposition.h"
22 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/prefs/pref_service.h" 24 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/sync/profile_sync_service.h" 26 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h" 27 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/browser/themes/theme_service.h" 28 #include "chrome/browser/themes/theme_service.h"
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const BookmarkNode* node = 1084 const BookmarkNode* node =
1084 model_->bookmark_bar_node()->GetChild(bookmark_button_index); 1085 model_->bookmark_bar_node()->GetChild(bookmark_button_index);
1085 nodes.push_back(node); 1086 nodes.push_back(node);
1086 parent = node->parent(); 1087 parent = node->parent();
1087 } else { 1088 } else {
1088 parent = model_->bookmark_bar_node(); 1089 parent = model_->bookmark_bar_node();
1089 nodes.push_back(parent); 1090 nodes.push_back(parent);
1090 } 1091 }
1091 Profile* profile = browser_->profile(); 1092 Profile* profile = browser_->profile();
1092 bool close_on_remove = 1093 bool close_on_remove =
1093 (parent == profile->GetBookmarkModel()->other_node()) && 1094 (parent == BookmarkModelFactory::GetForProfile(profile)->other_node()) &&
1094 (parent->child_count() == 1); 1095 (parent->child_count() == 1);
1095 context_menu_.reset(new BookmarkContextMenu(GetWidget(), browser_, profile, 1096 context_menu_.reset(new BookmarkContextMenu(GetWidget(), browser_, profile,
1096 chrome::GetActiveWebContents(browser_), parent, nodes, close_on_remove)); 1097 chrome::GetActiveWebContents(browser_), parent, nodes, close_on_remove));
1097 context_menu_->RunMenuAt(point); 1098 context_menu_->RunMenuAt(point);
1098 } 1099 }
1099 1100
1100 void BookmarkBarView::Observe(int type, 1101 void BookmarkBarView::Observe(int type,
1101 const content::NotificationSource& source, 1102 const content::NotificationSource& source,
1102 const content::NotificationDetails& details) { 1103 const content::NotificationDetails& details) {
1103 DCHECK(browser_->profile()); 1104 DCHECK(browser_->profile());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1156
1156 set_context_menu_controller(this); 1157 set_context_menu_controller(this);
1157 1158
1158 size_animation_.reset(new ui::SlideAnimation(this)); 1159 size_animation_.reset(new ui::SlideAnimation(this));
1159 1160
1160 Profile* profile = browser_->profile(); 1161 Profile* profile = browser_->profile();
1161 content::Source<Profile> ns_source(profile->GetOriginalProfile()); 1162 content::Source<Profile> ns_source(profile->GetOriginalProfile());
1162 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source); 1163 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source);
1163 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source); 1164 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source);
1164 1165
1165 model_ = profile->GetBookmarkModel(); 1166 model_ = BookmarkModelFactory::GetForProfile(profile);
1166 if (model_) { 1167 if (model_) {
1167 model_->AddObserver(this); 1168 model_->AddObserver(this);
1168 if (model_->IsLoaded()) 1169 if (model_->IsLoaded())
1169 Loaded(model_, false); 1170 Loaded(model_, false);
1170 // else case: we'll receive notification back from the BookmarkModel when 1171 // else case: we'll receive notification back from the BookmarkModel when
1171 // done loading, then we'll populate the bar. 1172 // done loading, then we'll populate the bar.
1172 } 1173 }
1173 } 1174 }
1174 1175
1175 int BookmarkBarView::GetBookmarkButtonCount() { 1176 int BookmarkBarView::GetBookmarkButtonCount() {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 (1 - size_animation_->GetCurrentValue()))); 1682 (1 - size_animation_->GetCurrentValue())));
1682 } else { 1683 } else {
1683 prefsize.set_height( 1684 prefsize.set_height(
1684 static_cast<int>( 1685 static_cast<int>(
1685 browser_defaults::kBookmarkBarHeight * 1686 browser_defaults::kBookmarkBarHeight *
1686 size_animation_->GetCurrentValue())); 1687 size_animation_->GetCurrentValue()));
1687 } 1688 }
1688 } 1689 }
1689 return prefsize; 1690 return prefsize;
1690 } 1691 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698