| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" |
| 18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 25 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 26 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 26 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 show_animation_->Reset(1); | 208 show_animation_->Reset(1); |
| 208 } else { | 209 } else { |
| 209 show_animation_->Show(); | 210 show_animation_->Show(); |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 | 213 |
| 213 View* GetTooltipHandlerForPoint(const gfx::Point& point) override { | 214 View* GetTooltipHandlerForPoint(const gfx::Point& point) override { |
| 214 return HitTestPoint(point) && CanProcessEventsWithinSubtree() ? this : NULL; | 215 return HitTestPoint(point) && CanProcessEventsWithinSubtree() ? this : NULL; |
| 215 } | 216 } |
| 216 | 217 |
| 217 scoped_ptr<LabelButtonBorder> CreateDefaultBorder() const override { | 218 std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override { |
| 218 scoped_ptr<LabelButtonBorder> border = LabelButton::CreateDefaultBorder(); | 219 std::unique_ptr<LabelButtonBorder> border = |
| 220 LabelButton::CreateDefaultBorder(); |
| 219 border->set_insets(gfx::Insets(kButtonPaddingVertical, | 221 border->set_insets(gfx::Insets(kButtonPaddingVertical, |
| 220 kButtonPaddingHorizontal, | 222 kButtonPaddingHorizontal, |
| 221 kButtonPaddingVertical, | 223 kButtonPaddingVertical, |
| 222 kButtonPaddingHorizontal)); | 224 kButtonPaddingHorizontal)); |
| 223 return border; | 225 return border; |
| 224 } | 226 } |
| 225 | 227 |
| 226 bool IsTriggerableEvent(const ui::Event& e) override { | 228 bool IsTriggerableEvent(const ui::Event& e) override { |
| 227 return e.type() == ui::ET_GESTURE_TAP || | 229 return e.type() == ui::ET_GESTURE_TAP || |
| 228 e.type() == ui::ET_GESTURE_TAP_DOWN || | 230 e.type() == ui::ET_GESTURE_TAP_DOWN || |
| 229 event_utils::IsPossibleDispositionEvent(e); | 231 event_utils::IsPossibleDispositionEvent(e); |
| 230 } | 232 } |
| 231 | 233 |
| 232 scoped_ptr<views::InkDropAnimation> CreateInkDropAnimation() const override { | 234 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 233 return make_scoped_ptr(new views::FloodFillInkDropAnimation( | 235 const override { |
| 236 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 234 size(), GetInkDropCenter(), GetInkDropBaseColor())); | 237 size(), GetInkDropCenter(), GetInkDropBaseColor())); |
| 235 } | 238 } |
| 236 | 239 |
| 237 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override { | 240 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 238 if (!ShouldShowInkDropHover()) | 241 if (!ShouldShowInkDropHover()) |
| 239 return nullptr; | 242 return nullptr; |
| 240 return make_scoped_ptr(new views::InkDropHover( | 243 return base::WrapUnique(new views::InkDropHover( |
| 241 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); | 244 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); |
| 242 } | 245 } |
| 243 | 246 |
| 244 SkColor GetInkDropBaseColor() const override { | 247 SkColor GetInkDropBaseColor() const override { |
| 245 return GetThemeProvider()->GetColor( | 248 return GetThemeProvider()->GetColor( |
| 246 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 249 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 247 } | 250 } |
| 248 | 251 |
| 249 private: | 252 private: |
| 250 scoped_ptr<gfx::SlideAnimation> show_animation_; | 253 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 251 | 254 |
| 252 // Controls the visual feedback for the button state. | 255 // Controls the visual feedback for the button state. |
| 253 views::ButtonInkDropDelegate ink_drop_delegate_; | 256 views::ButtonInkDropDelegate ink_drop_delegate_; |
| 254 | 257 |
| 255 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); | 258 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); |
| 256 }; | 259 }; |
| 257 | 260 |
| 258 // BookmarkButton ------------------------------------------------------------- | 261 // BookmarkButton ------------------------------------------------------------- |
| 259 | 262 |
| 260 // Buttons used for the bookmarks on the bookmark bar. | 263 // Buttons used for the bookmarks on the bookmark bar. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 class BookmarkMenuButtonBase : public views::MenuButton { | 323 class BookmarkMenuButtonBase : public views::MenuButton { |
| 321 public: | 324 public: |
| 322 BookmarkMenuButtonBase(const base::string16& title, | 325 BookmarkMenuButtonBase(const base::string16& title, |
| 323 views::MenuButtonListener* menu_button_listener, | 326 views::MenuButtonListener* menu_button_listener, |
| 324 bool show_menu_marker) | 327 bool show_menu_marker) |
| 325 : MenuButton(title, menu_button_listener, show_menu_marker), | 328 : MenuButton(title, menu_button_listener, show_menu_marker), |
| 326 ink_drop_delegate_(this, this) { | 329 ink_drop_delegate_(this, this) { |
| 327 set_ink_drop_delegate(&ink_drop_delegate_); | 330 set_ink_drop_delegate(&ink_drop_delegate_); |
| 328 } | 331 } |
| 329 | 332 |
| 330 scoped_ptr<views::InkDropAnimation> CreateInkDropAnimation() const override { | 333 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 331 return make_scoped_ptr(new views::FloodFillInkDropAnimation( | 334 const override { |
| 335 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 332 size(), GetInkDropCenter(), GetInkDropBaseColor())); | 336 size(), GetInkDropCenter(), GetInkDropBaseColor())); |
| 333 } | 337 } |
| 334 | 338 |
| 335 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override { | 339 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 336 if (!ShouldShowInkDropHover()) | 340 if (!ShouldShowInkDropHover()) |
| 337 return nullptr; | 341 return nullptr; |
| 338 return make_scoped_ptr(new views::InkDropHover( | 342 return base::WrapUnique(new views::InkDropHover( |
| 339 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); | 343 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); |
| 340 } | 344 } |
| 341 | 345 |
| 342 SkColor GetInkDropBaseColor() const override { | 346 SkColor GetInkDropBaseColor() const override { |
| 343 return GetThemeProvider()->GetColor( | 347 return GetThemeProvider()->GetColor( |
| 344 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 348 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 345 } | 349 } |
| 346 | 350 |
| 347 private: | 351 private: |
| 348 // Controls the visual feedback for the button state. | 352 // Controls the visual feedback for the button state. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 bool IsTriggerableEventType(const ui::Event& e) override { | 396 bool IsTriggerableEventType(const ui::Event& e) override { |
| 393 // Bookmark folders handle normal menu button events (i.e., left click) as | 397 // Bookmark folders handle normal menu button events (i.e., left click) as |
| 394 // well as clicks to open bookmarks in new tabs that would otherwise be | 398 // well as clicks to open bookmarks in new tabs that would otherwise be |
| 395 // ignored. | 399 // ignored. |
| 396 return BookmarkMenuButtonBase::IsTriggerableEventType(e) || | 400 return BookmarkMenuButtonBase::IsTriggerableEventType(e) || |
| 397 (e.IsMouseEvent() && | 401 (e.IsMouseEvent() && |
| 398 ui::DispositionFromEventFlags(e.flags()) != CURRENT_TAB); | 402 ui::DispositionFromEventFlags(e.flags()) != CURRENT_TAB); |
| 399 } | 403 } |
| 400 | 404 |
| 401 private: | 405 private: |
| 402 scoped_ptr<gfx::SlideAnimation> show_animation_; | 406 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 403 | 407 |
| 404 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton); | 408 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton); |
| 405 }; | 409 }; |
| 406 | 410 |
| 407 // OverflowButton (chevron) -------------------------------------------------- | 411 // OverflowButton (chevron) -------------------------------------------------- |
| 408 | 412 |
| 409 class OverflowButton : public BookmarkMenuButtonBase { | 413 class OverflowButton : public BookmarkMenuButtonBase { |
| 410 public: | 414 public: |
| 411 explicit OverflowButton(BookmarkBarView* owner) | 415 explicit OverflowButton(BookmarkBarView* owner) |
| 412 : BookmarkMenuButtonBase(base::string16(), owner, false), owner_(owner) {} | 416 : BookmarkMenuButtonBase(base::string16(), owner, false), owner_(owner) {} |
| (...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 return; | 2151 return; |
| 2148 apps_page_shortcut_->SetVisible(visible); | 2152 apps_page_shortcut_->SetVisible(visible); |
| 2149 UpdateBookmarksSeparatorVisibility(); | 2153 UpdateBookmarksSeparatorVisibility(); |
| 2150 LayoutAndPaint(); | 2154 LayoutAndPaint(); |
| 2151 } | 2155 } |
| 2152 | 2156 |
| 2153 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2157 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2154 if (UpdateOtherAndManagedButtonsVisibility()) | 2158 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2155 LayoutAndPaint(); | 2159 LayoutAndPaint(); |
| 2156 } | 2160 } |
| OLD | NEW |