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/browser_tabstrip.h" |
30 #include "chrome/browser/ui/chrome_pages.h" | 31 #include "chrome/browser/ui/chrome_pages.h" |
31 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 32 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
32 #include "chrome/browser/ui/view_ids.h" | 33 #include "chrome/browser/ui/view_ids.h" |
33 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" | 34 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
34 #include "chrome/browser/ui/views/event_utils.h" | 35 #include "chrome/browser/ui/views/event_utils.h" |
35 #include "chrome/browser/ui/views/frame/browser_view.h" | 36 #include "chrome/browser/ui/views/frame/browser_view.h" |
36 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 37 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
37 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 38 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
38 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
39 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 parent = node->parent(); | 1086 parent = node->parent(); |
1086 } else { | 1087 } else { |
1087 parent = model_->bookmark_bar_node(); | 1088 parent = model_->bookmark_bar_node(); |
1088 nodes.push_back(parent); | 1089 nodes.push_back(parent); |
1089 } | 1090 } |
1090 Profile* profile = browser_->profile(); | 1091 Profile* profile = browser_->profile(); |
1091 bool close_on_remove = | 1092 bool close_on_remove = |
1092 (parent == profile->GetBookmarkModel()->other_node()) && | 1093 (parent == profile->GetBookmarkModel()->other_node()) && |
1093 (parent->child_count() == 1); | 1094 (parent->child_count() == 1); |
1094 context_menu_.reset(new BookmarkContextMenu(GetWidget(), browser_, profile, | 1095 context_menu_.reset(new BookmarkContextMenu(GetWidget(), browser_, profile, |
1095 browser_->GetActiveWebContents(), parent, nodes, close_on_remove)); | 1096 chrome::GetActiveWebContents(browser_), parent, nodes, close_on_remove)); |
1096 context_menu_->RunMenuAt(point); | 1097 context_menu_->RunMenuAt(point); |
1097 } | 1098 } |
1098 | 1099 |
1099 void BookmarkBarView::Observe(int type, | 1100 void BookmarkBarView::Observe(int type, |
1100 const content::NotificationSource& source, | 1101 const content::NotificationSource& source, |
1101 const content::NotificationDetails& details) { | 1102 const content::NotificationDetails& details) { |
1102 DCHECK(browser_->profile()); | 1103 DCHECK(browser_->profile()); |
1103 switch (type) { | 1104 switch (type) { |
1104 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { | 1105 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
1105 StopThrobbing(true); | 1106 StopThrobbing(true); |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 (1 - size_animation_->GetCurrentValue()))); | 1681 (1 - size_animation_->GetCurrentValue()))); |
1681 } else { | 1682 } else { |
1682 prefsize.set_height( | 1683 prefsize.set_height( |
1683 static_cast<int>( | 1684 static_cast<int>( |
1684 browser_defaults::kBookmarkBarHeight * | 1685 browser_defaults::kBookmarkBarHeight * |
1685 size_animation_->GetCurrentValue())); | 1686 size_animation_->GetCurrentValue())); |
1686 } | 1687 } |
1687 } | 1688 } |
1688 return prefsize; | 1689 return prefsize; |
1689 } | 1690 } |
OLD | NEW |