| 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/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_utils.h" | 18 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 19 #include "chrome/browser/browser_shutdown.h" | 19 #include "chrome/browser/browser_shutdown.h" |
| 20 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
| 21 #include "chrome/browser/event_disposition.h" | 21 #include "chrome/browser/event_disposition.h" |
| 22 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
| 26 #include "chrome/browser/sync/profile_sync_service_factory.h" | 26 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 27 #include "chrome/browser/themes/theme_service.h" | 27 #include "chrome/browser/themes/theme_service.h" |
| 28 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 28 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 31 #include "chrome/browser/ui/view_ids.h" | 31 #include "chrome/browser/ui/view_ids.h" |
| 32 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" | 32 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
| 33 #include "chrome/browser/ui/views/event_utils.h" | 33 #include "chrome/browser/ui/views/event_utils.h" |
| 34 #include "chrome/browser/ui/views/frame/browser_view.h" | 34 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 35 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 35 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 36 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 36 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 37 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
| 38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/common/extensions/extension_constants.h" | 39 #include "chrome/common/extensions/extension_constants.h" |
| 40 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 parent = node->parent(); | 1075 parent = node->parent(); |
| 1076 } else { | 1076 } else { |
| 1077 parent = model_->bookmark_bar_node(); | 1077 parent = model_->bookmark_bar_node(); |
| 1078 nodes.push_back(parent); | 1078 nodes.push_back(parent); |
| 1079 } | 1079 } |
| 1080 Profile* profile = browser_->profile(); | 1080 Profile* profile = browser_->profile(); |
| 1081 bool close_on_remove = | 1081 bool close_on_remove = |
| 1082 (parent == profile->GetBookmarkModel()->other_node()) && | 1082 (parent == profile->GetBookmarkModel()->other_node()) && |
| 1083 (parent->child_count() == 1); | 1083 (parent->child_count() == 1); |
| 1084 context_menu_.reset(new BookmarkContextMenu(GetWidget(), profile, | 1084 context_menu_.reset(new BookmarkContextMenu(GetWidget(), profile, |
| 1085 browser_->GetSelectedWebContents(), parent, nodes, close_on_remove)); | 1085 browser_->GetActiveWebContents(), parent, nodes, close_on_remove)); |
| 1086 context_menu_->RunMenuAt(point); | 1086 context_menu_->RunMenuAt(point); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 void BookmarkBarView::Observe(int type, | 1089 void BookmarkBarView::Observe(int type, |
| 1090 const content::NotificationSource& source, | 1090 const content::NotificationSource& source, |
| 1091 const content::NotificationDetails& details) { | 1091 const content::NotificationDetails& details) { |
| 1092 DCHECK(browser_->profile()); | 1092 DCHECK(browser_->profile()); |
| 1093 switch (type) { | 1093 switch (type) { |
| 1094 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { | 1094 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
| 1095 StopThrobbing(true); | 1095 StopThrobbing(true); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 (1 - size_animation_->GetCurrentValue()))); | 1669 (1 - size_animation_->GetCurrentValue()))); |
| 1670 } else { | 1670 } else { |
| 1671 prefsize.set_height( | 1671 prefsize.set_height( |
| 1672 static_cast<int>( | 1672 static_cast<int>( |
| 1673 browser_defaults::kBookmarkBarHeight * | 1673 browser_defaults::kBookmarkBarHeight * |
| 1674 size_animation_->GetCurrentValue())); | 1674 size_animation_->GetCurrentValue())); |
| 1675 } | 1675 } |
| 1676 } | 1676 } |
| 1677 return prefsize; | 1677 return prefsize; |
| 1678 } | 1678 } |
| OLD | NEW |