| 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> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 18 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
| 19 #include "chrome/browser/defaults.h" | 19 #include "chrome/browser/defaults.h" |
| 20 #include "chrome/browser/event_disposition.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sync/sync_ui_util.h" | 24 #include "chrome/browser/sync/sync_ui_util.h" |
| 24 #include "chrome/browser/themes/theme_service.h" | 25 #include "chrome/browser/themes/theme_service.h" |
| 25 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 26 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 28 #include "chrome/browser/ui/view_ids.h" | 29 #include "chrome/browser/ui/view_ids.h" |
| 29 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" | 30 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 198 } |
| 198 | 199 |
| 199 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { | 200 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { |
| 200 // Left clicks should show the menu contents and right clicks should show | 201 // Left clicks should show the menu contents and right clicks should show |
| 201 // the context menu. They should not trigger the opening of underlying urls. | 202 // the context menu. They should not trigger the opening of underlying urls. |
| 202 if (e.flags() == ui::EF_LEFT_BUTTON_DOWN || | 203 if (e.flags() == ui::EF_LEFT_BUTTON_DOWN || |
| 203 e.flags() == ui::EF_RIGHT_BUTTON_DOWN) | 204 e.flags() == ui::EF_RIGHT_BUTTON_DOWN) |
| 204 return false; | 205 return false; |
| 205 | 206 |
| 206 WindowOpenDisposition disposition( | 207 WindowOpenDisposition disposition( |
| 207 event_utils::DispositionFromEventFlags(e.flags())); | 208 browser::DispositionFromEventFlags(e.flags())); |
| 208 return disposition != CURRENT_TAB; | 209 return disposition != CURRENT_TAB; |
| 209 } | 210 } |
| 210 | 211 |
| 211 virtual void OnPaint(gfx::Canvas* canvas) { | 212 virtual void OnPaint(gfx::Canvas* canvas) { |
| 212 views::MenuButton::PaintButton(canvas, views::MenuButton::PB_NORMAL); | 213 views::MenuButton::PaintButton(canvas, views::MenuButton::PB_NORMAL); |
| 213 } | 214 } |
| 214 | 215 |
| 215 private: | 216 private: |
| 216 scoped_ptr<ui::SlideAnimation> show_animation_; | 217 scoped_ptr<ui::SlideAnimation> show_animation_; |
| 217 | 218 |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 if (sender->tag() == kOtherFolderButtonTag) { | 1082 if (sender->tag() == kOtherFolderButtonTag) { |
| 1082 node = model_->other_node(); | 1083 node = model_->other_node(); |
| 1083 } else { | 1084 } else { |
| 1084 int index = GetIndexOf(sender); | 1085 int index = GetIndexOf(sender); |
| 1085 DCHECK_NE(-1, index); | 1086 DCHECK_NE(-1, index); |
| 1086 node = model_->GetBookmarkBarNode()->GetChild(index); | 1087 node = model_->GetBookmarkBarNode()->GetChild(index); |
| 1087 } | 1088 } |
| 1088 DCHECK(page_navigator_); | 1089 DCHECK(page_navigator_); |
| 1089 | 1090 |
| 1090 WindowOpenDisposition disposition_from_event_flags = | 1091 WindowOpenDisposition disposition_from_event_flags = |
| 1091 event_utils::DispositionFromEventFlags(sender->mouse_event_flags()); | 1092 browser::DispositionFromEventFlags(sender->mouse_event_flags()); |
| 1092 | 1093 |
| 1093 if (node->is_url()) { | 1094 if (node->is_url()) { |
| 1094 RecordAppLaunch(profile_, node->GetURL()); | 1095 RecordAppLaunch(profile_, node->GetURL()); |
| 1095 page_navigator_->OpenURL(node->GetURL(), GURL(), | 1096 page_navigator_->OpenURL(node->GetURL(), GURL(), |
| 1096 disposition_from_event_flags, PageTransition::AUTO_BOOKMARK); | 1097 disposition_from_event_flags, PageTransition::AUTO_BOOKMARK); |
| 1097 } else { | 1098 } else { |
| 1098 bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile_, | 1099 bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile_, |
| 1099 page_navigator_, node, disposition_from_event_flags); | 1100 page_navigator_, node, disposition_from_event_flags); |
| 1100 } | 1101 } |
| 1101 UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); | 1102 UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 (1 - size_animation_->GetCurrentValue()))); | 1759 (1 - size_animation_->GetCurrentValue()))); |
| 1759 } else { | 1760 } else { |
| 1760 prefsize.set_height( | 1761 prefsize.set_height( |
| 1761 static_cast<int>( | 1762 static_cast<int>( |
| 1762 browser_defaults::kBookmarkBarHeight * | 1763 browser_defaults::kBookmarkBarHeight * |
| 1763 size_animation_->GetCurrentValue())); | 1764 size_animation_->GetCurrentValue())); |
| 1764 } | 1765 } |
| 1765 } | 1766 } |
| 1766 return prefsize; | 1767 return prefsize; |
| 1767 } | 1768 } |
| OLD | NEW |