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/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> |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 size_animation_->Reset(1); | 388 size_animation_->Reset(1); |
389 } | 389 } |
390 | 390 |
391 BookmarkBarView::~BookmarkBarView() { | 391 BookmarkBarView::~BookmarkBarView() { |
392 if (model_) | 392 if (model_) |
393 model_->RemoveObserver(this); | 393 model_->RemoveObserver(this); |
394 | 394 |
395 // It's possible for the menu to outlive us, reset the observer to make sure | 395 // It's possible for the menu to outlive us, reset the observer to make sure |
396 // it doesn't have a reference to us. | 396 // it doesn't have a reference to us. |
397 if (bookmark_menu_) | 397 if (bookmark_menu_) { |
398 bookmark_menu_->set_observer(NULL); | 398 bookmark_menu_->set_observer(NULL); |
| 399 bookmark_menu_->SetPageNavigator(NULL); |
| 400 } |
| 401 if (context_menu_.get()) |
| 402 context_menu_->SetPageNavigator(NULL); |
399 | 403 |
400 StopShowFolderDropMenuTimer(); | 404 StopShowFolderDropMenuTimer(); |
401 | 405 |
402 if (sync_service_) | 406 if (sync_service_) |
403 sync_service_->RemoveObserver(this); | 407 sync_service_->RemoveObserver(this); |
404 } | 408 } |
405 | 409 |
406 void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { | 410 void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { |
407 page_navigator_ = navigator; | 411 page_navigator_ = navigator; |
| 412 if (bookmark_menu_) |
| 413 bookmark_menu_->SetPageNavigator(navigator); |
| 414 if (context_menu_.get()) |
| 415 context_menu_->SetPageNavigator(navigator); |
408 } | 416 } |
409 | 417 |
410 void BookmarkBarView::SetBookmarkBarState( | 418 void BookmarkBarView::SetBookmarkBarState( |
411 BookmarkBar::State state, | 419 BookmarkBar::State state, |
412 BookmarkBar::AnimateChangeType animate_type) { | 420 BookmarkBar::AnimateChangeType animate_type) { |
413 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE) { | 421 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE) { |
414 animating_detached_ = (state == BookmarkBar::DETACHED || | 422 animating_detached_ = (state == BookmarkBar::DETACHED || |
415 bookmark_bar_state_ == BookmarkBar::DETACHED); | 423 bookmark_bar_state_ == BookmarkBar::DETACHED); |
416 if (state == BookmarkBar::SHOW) | 424 if (state == BookmarkBar::SHOW) |
417 size_animation_->Show(); | 425 size_animation_->Show(); |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 nodes.push_back(node); | 1098 nodes.push_back(node); |
1091 parent = node->parent(); | 1099 parent = node->parent(); |
1092 } else { | 1100 } else { |
1093 parent = model_->bookmark_bar_node(); | 1101 parent = model_->bookmark_bar_node(); |
1094 nodes.push_back(parent); | 1102 nodes.push_back(parent); |
1095 } | 1103 } |
1096 Profile* profile = browser_->profile(); | 1104 Profile* profile = browser_->profile(); |
1097 bool close_on_remove = | 1105 bool close_on_remove = |
1098 (parent == profile->GetBookmarkModel()->other_node()) && | 1106 (parent == profile->GetBookmarkModel()->other_node()) && |
1099 (parent->child_count() == 1); | 1107 (parent->child_count() == 1); |
1100 BookmarkContextMenu controller(GetWidget(), profile, | 1108 context_menu_.reset(new BookmarkContextMenu(GetWidget(), profile, |
1101 browser_->GetSelectedTabContents(), parent, nodes, close_on_remove); | 1109 browser_->GetSelectedTabContents(), parent, nodes, close_on_remove)); |
1102 controller.RunMenuAt(p); | 1110 context_menu_->RunMenuAt(p); |
1103 } | 1111 } |
1104 | 1112 |
1105 void BookmarkBarView::Observe(int type, | 1113 void BookmarkBarView::Observe(int type, |
1106 const NotificationSource& source, | 1114 const NotificationSource& source, |
1107 const NotificationDetails& details) { | 1115 const NotificationDetails& details) { |
1108 DCHECK(browser_->profile()); | 1116 DCHECK(browser_->profile()); |
1109 switch (type) { | 1117 switch (type) { |
1110 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { | 1118 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
1111 StopThrobbing(true); | 1119 StopThrobbing(true); |
1112 GURL url = *(Details<GURL>(details).ptr()); | 1120 GURL url = *(Details<GURL>(details).ptr()); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 (1 - size_animation_->GetCurrentValue()))); | 1732 (1 - size_animation_->GetCurrentValue()))); |
1725 } else { | 1733 } else { |
1726 prefsize.set_height( | 1734 prefsize.set_height( |
1727 static_cast<int>( | 1735 static_cast<int>( |
1728 browser_defaults::kBookmarkBarHeight * | 1736 browser_defaults::kBookmarkBarHeight * |
1729 size_animation_->GetCurrentValue())); | 1737 size_animation_->GetCurrentValue())); |
1730 } | 1738 } |
1731 } | 1739 } |
1732 return prefsize; | 1740 return prefsize; |
1733 } | 1741 } |
OLD | NEW |