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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.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, 5 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
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_menu_controller_views.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/bookmarks/bookmark_node_data.h" 11 #include "chrome/browser/bookmarks/bookmark_node_data.h"
11 #include "chrome/browser/bookmarks/bookmark_utils.h" 12 #include "chrome/browser/bookmarks/bookmark_utils.h"
12 #include "chrome/browser/event_disposition.h" 13 #include "chrome/browser/event_disposition.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 16 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
16 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" 17 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "content/public/browser/page_navigator.h" 19 #include "content/public/browser/page_navigator.h"
19 #include "content/public/browser/user_metrics.h" 20 #include "content/public/browser/user_metrics.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 views::MenuButton* menu_button = bookmark_bar_->GetMenuButtonForNode(node_); 54 views::MenuButton* menu_button = bookmark_bar_->GetMenuButtonForNode(node_);
54 DCHECK(menu_button); 55 DCHECK(menu_button);
55 MenuItemView::AnchorPosition anchor; 56 MenuItemView::AnchorPosition anchor;
56 bookmark_bar_->GetAnchorPositionForButton(menu_button, &anchor); 57 bookmark_bar_->GetAnchorPositionForButton(menu_button, &anchor);
57 gfx::Point screen_loc; 58 gfx::Point screen_loc;
58 views::View::ConvertPointToScreen(menu_button, &screen_loc); 59 views::View::ConvertPointToScreen(menu_button, &screen_loc);
59 // Subtract 1 from the height to make the popup flush with the button border. 60 // Subtract 1 from the height to make the popup flush with the button border.
60 gfx::Rect bounds(screen_loc.x(), screen_loc.y(), menu_button->width(), 61 gfx::Rect bounds(screen_loc.x(), screen_loc.y(), menu_button->width(),
61 menu_button->height() - 1); 62 menu_button->height() - 1);
62 for_drop_ = for_drop; 63 for_drop_ = for_drop;
63 menu_delegate_->profile()->GetBookmarkModel()->AddObserver(this); 64 BookmarkModelFactory::GetForProfile(
65 menu_delegate_->profile())->AddObserver(this);
64 // We only delete ourself after the menu completes, so we can safely ignore 66 // We only delete ourself after the menu completes, so we can safely ignore
65 // the return value. 67 // the return value.
66 ignore_result(menu_runner_->RunMenuAt(menu_delegate_->parent(), menu_button, 68 ignore_result(menu_runner_->RunMenuAt(menu_delegate_->parent(), menu_button,
67 bounds, anchor, for_drop ? views::MenuRunner::FOR_DROP : 0)); 69 bounds, anchor, for_drop ? views::MenuRunner::FOR_DROP : 0));
68 if (!for_drop) 70 if (!for_drop)
69 delete this; 71 delete this;
70 } 72 }
71 73
72 void BookmarkMenuController::Cancel() { 74 void BookmarkMenuController::Cancel() {
73 menu_delegate_->menu()->Cancel(); 75 menu_delegate_->menu()->Cancel();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int BookmarkMenuController::GetMaxWidthForMenu(MenuItemView* view) { 183 int BookmarkMenuController::GetMaxWidthForMenu(MenuItemView* view) {
182 return menu_delegate_->GetMaxWidthForMenu(view); 184 return menu_delegate_->GetMaxWidthForMenu(view);
183 } 185 }
184 186
185 void BookmarkMenuController::BookmarkModelChanged() { 187 void BookmarkMenuController::BookmarkModelChanged() {
186 if (!menu_delegate_->is_mutating_model()) 188 if (!menu_delegate_->is_mutating_model())
187 menu()->Cancel(); 189 menu()->Cancel();
188 } 190 }
189 191
190 BookmarkMenuController::~BookmarkMenuController() { 192 BookmarkMenuController::~BookmarkMenuController() {
191 menu_delegate_->profile()->GetBookmarkModel()->RemoveObserver(this); 193 BookmarkModelFactory::GetForProfile(
194 menu_delegate_->profile())->RemoveObserver(this);
192 if (observer_) 195 if (observer_)
193 observer_->BookmarkMenuDeleted(this); 196 observer_->BookmarkMenuDeleted(this);
194 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698