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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 *formats = ui::OSExchangeData::URL; | 532 *formats = ui::OSExchangeData::URL; |
533 custom_formats->insert(BookmarkNodeData::GetBookmarkCustomFormat()); | 533 custom_formats->insert(BookmarkNodeData::GetBookmarkCustomFormat()); |
534 return true; | 534 return true; |
535 } | 535 } |
536 | 536 |
537 bool BookmarkBarView::AreDropTypesRequired() { | 537 bool BookmarkBarView::AreDropTypesRequired() { |
538 return true; | 538 return true; |
539 } | 539 } |
540 | 540 |
541 bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) { | 541 bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) { |
542 if (!model_ || !model_->IsLoaded()) | 542 if (!model_ || !model_->IsLoaded() || |
| 543 !profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled)) |
543 return false; | 544 return false; |
544 | 545 |
545 if (!drop_info_.get()) | 546 if (!drop_info_.get()) |
546 drop_info_.reset(new DropInfo()); | 547 drop_info_.reset(new DropInfo()); |
547 | 548 |
548 // Only accept drops of 1 node, which is the case for all data dragged from | 549 // Only accept drops of 1 node, which is the case for all data dragged from |
549 // bookmark bar and menus. | 550 // bookmark bar and menus. |
550 return drop_info_->data.Read(data) && drop_info_->data.size() == 1; | 551 return drop_info_->data.Read(data) && drop_info_->data.size() == 1; |
551 } | 552 } |
552 | 553 |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 // Don't let the user drag while animating open or we're closed (and not on | 1108 // Don't let the user drag while animating open or we're closed (and not on |
1108 // the new tab page, on the new tab page size_animation_ is always 0). This | 1109 // the new tab page, on the new tab page size_animation_ is always 0). This |
1109 // typically is only hit if the user does something to inadvertanty trigger | 1110 // typically is only hit if the user does something to inadvertanty trigger |
1110 // dnd, such as pressing the mouse and hitting control-b. | 1111 // dnd, such as pressing the mouse and hitting control-b. |
1111 return ui::DragDropTypes::DRAG_NONE; | 1112 return ui::DragDropTypes::DRAG_NONE; |
1112 } | 1113 } |
1113 | 1114 |
1114 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1115 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
1115 if (sender == GetBookmarkButton(i)) { | 1116 if (sender == GetBookmarkButton(i)) { |
1116 return bookmark_utils::BookmarkDragOperation( | 1117 return bookmark_utils::BookmarkDragOperation( |
1117 model_->GetBookmarkBarNode()->GetChild(i)); | 1118 profile_, model_->GetBookmarkBarNode()->GetChild(i)); |
1118 } | 1119 } |
1119 } | 1120 } |
1120 NOTREACHED(); | 1121 NOTREACHED(); |
1121 return ui::DragDropTypes::DRAG_NONE; | 1122 return ui::DragDropTypes::DRAG_NONE; |
1122 } | 1123 } |
1123 | 1124 |
1124 bool BookmarkBarView::CanStartDragForView(views::View* sender, | 1125 bool BookmarkBarView::CanStartDragForView(views::View* sender, |
1125 const gfx::Point& press_pt, | 1126 const gfx::Point& press_pt, |
1126 const gfx::Point& p) { | 1127 const gfx::Point& p) { |
1127 // Check if we have not moved enough horizontally but we have moved downward | 1128 // Check if we have not moved enough horizontally but we have moved downward |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 // The tooltip is the only way we have to display text explaining the error | 1783 // The tooltip is the only way we have to display text explaining the error |
1783 // to the user. | 1784 // to the user. |
1784 sync_error_button->SetTooltipText( | 1785 sync_error_button->SetTooltipText( |
1785 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); | 1786 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); |
1786 sync_error_button->SetAccessibleName( | 1787 sync_error_button->SetAccessibleName( |
1787 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); | 1788 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); |
1788 sync_error_button->SetIcon( | 1789 sync_error_button->SetIcon( |
1789 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); | 1790 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); |
1790 return sync_error_button; | 1791 return sync_error_button; |
1791 } | 1792 } |
OLD | NEW |