Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 2357353003: Remove pre-MD code from bookmark bar (Views). (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
17 #include "base/macros.h" 16 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
19 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
20 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
23 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
24 #include "build/build_config.h" 23 #include "build/build_config.h"
25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
26 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 25 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
27 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/defaults.h" 27 #include "chrome/browser/defaults.h"
30 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/search/search.h" 29 #include "chrome/browser/search/search.h"
32 #include "chrome/browser/sync/profile_sync_service_factory.h" 30 #include "chrome/browser/sync/profile_sync_service_factory.h"
33 #include "chrome/browser/themes/theme_properties.h" 31 #include "chrome/browser/themes/theme_properties.h"
34 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 32 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
35 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" 33 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
36 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 34 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
37 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 35 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
38 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" 36 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
(...skipping 18 matching lines...) Expand all
57 #include "components/bookmarks/browser/bookmark_model.h" 55 #include "components/bookmarks/browser/bookmark_model.h"
58 #include "components/bookmarks/browser/bookmark_utils.h" 56 #include "components/bookmarks/browser/bookmark_utils.h"
59 #include "components/bookmarks/common/bookmark_pref_names.h" 57 #include "components/bookmarks/common/bookmark_pref_names.h"
60 #include "components/bookmarks/managed/managed_bookmark_service.h" 58 #include "components/bookmarks/managed/managed_bookmark_service.h"
61 #include "components/browser_sync/profile_sync_service.h" 59 #include "components/browser_sync/profile_sync_service.h"
62 #include "components/metrics/metrics_service.h" 60 #include "components/metrics/metrics_service.h"
63 #include "components/omnibox/browser/omnibox_popup_model.h" 61 #include "components/omnibox/browser/omnibox_popup_model.h"
64 #include "components/omnibox/browser/omnibox_view.h" 62 #include "components/omnibox/browser/omnibox_view.h"
65 #include "components/prefs/pref_service.h" 63 #include "components/prefs/pref_service.h"
66 #include "components/url_formatter/elide_url.h" 64 #include "components/url_formatter/elide_url.h"
67 #include "content/public/browser/notification_details.h"
68 #include "content/public/browser/notification_source.h"
69 #include "content/public/browser/page_navigator.h"
70 #include "content/public/browser/render_view_host.h"
71 #include "content/public/browser/render_widget_host_view.h"
72 #include "content/public/browser/user_metrics.h" 65 #include "content/public/browser/user_metrics.h"
73 #include "content/public/browser/web_contents.h"
74 #include "extensions/browser/extension_registry.h" 66 #include "extensions/browser/extension_registry.h"
75 #include "extensions/common/extension.h" 67 #include "extensions/common/extension.h"
76 #include "extensions/common/extension_set.h" 68 #include "extensions/common/extension_set.h"
77 #include "ui/accessibility/ax_view_state.h" 69 #include "ui/accessibility/ax_view_state.h"
78 #include "ui/base/dragdrop/drag_utils.h" 70 #include "ui/base/dragdrop/drag_utils.h"
79 #include "ui/base/dragdrop/os_exchange_data.h" 71 #include "ui/base/dragdrop/os_exchange_data.h"
80 #include "ui/base/l10n/l10n_util.h" 72 #include "ui/base/l10n/l10n_util.h"
81 #include "ui/base/material_design/material_design_controller.h"
82 #include "ui/base/page_transition_types.h" 73 #include "ui/base/page_transition_types.h"
83 #include "ui/base/resource/resource_bundle.h" 74 #include "ui/base/resource/resource_bundle.h"
84 #include "ui/base/theme_provider.h" 75 #include "ui/base/theme_provider.h"
85 #include "ui/base/window_open_disposition.h" 76 #include "ui/base/window_open_disposition.h"
86 #include "ui/compositor/paint_recorder.h" 77 #include "ui/compositor/paint_recorder.h"
87 #include "ui/gfx/animation/slide_animation.h" 78 #include "ui/gfx/animation/slide_animation.h"
88 #include "ui/gfx/canvas.h" 79 #include "ui/gfx/canvas.h"
89 #include "ui/gfx/color_utils.h" 80 #include "ui/gfx/color_utils.h"
90 #include "ui/gfx/favicon_size.h" 81 #include "ui/gfx/favicon_size.h"
91 #include "ui/gfx/geometry/rect.h" 82 #include "ui/gfx/geometry/rect.h"
(...skipping 30 matching lines...) Expand all
122 using views::LabelButtonBorder; 113 using views::LabelButtonBorder;
123 using views::MenuButton; 114 using views::MenuButton;
124 using views::View; 115 using views::View;
125 116
126 // How inset the bookmarks bar is when displayed on the new tab page. 117 // How inset the bookmarks bar is when displayed on the new tab page.
127 static const int kNewTabHorizontalPadding = 2; 118 static const int kNewTabHorizontalPadding = 2;
128 119
129 // Maximum size of buttons on the bookmark bar. 120 // Maximum size of buttons on the bookmark bar.
130 static const int kMaxButtonWidth = 150; 121 static const int kMaxButtonWidth = 150;
131 122
132 // The color gradient start value close to the edge of the divider.
133 static const SkColor kEdgeDividerColor = SkColorSetRGB(222, 234, 248);
134
135 // The color gradient value for the middle of the divider.
136 static const SkColor kMiddleDividerColor = SkColorSetRGB(194, 205, 212);
137
138 // Number of pixels the attached bookmark bar overlaps with the toolbar. 123 // Number of pixels the attached bookmark bar overlaps with the toolbar.
139 static const int kToolbarAttachedBookmarkBarOverlap = 3; 124 static const int kToolbarAttachedBookmarkBarOverlap = 3;
140 125
141 // Margins around the content. 126 // Margins around the content.
142 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the 127 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the
143 // toolbar above serve as the margin. 128 // toolbar above serve as the margin.
144 static const int kBottomMargin = 2; 129 static const int kBottomMargin = 2;
145 // The margin at the start and end of the bar, in dp, indexed by MD mode. 130 static const int kHorizontalMargin = 4;
146 static const int kHorizontalMargin[] = {1, 4, 4};
147 131
148 // Padding between buttons. 132 // Padding between buttons.
149 static const int kButtonPadding = 0; 133 static const int kButtonPadding = 0;
150 134
151 // Color of the drop indicator.
152 static const SkColor kDropIndicatorColor = SK_ColorBLACK;
153
154 // Width of the drop indicator. 135 // Width of the drop indicator.
155 static const int kDropIndicatorWidth = 2; 136 static const int kDropIndicatorWidth = 2;
156 137
157 // Distance between the bottom of the bar and the separator. 138 // Distance between the bottom of the bar and the separator.
158 static const int kSeparatorMargin = 1; 139 static const int kSeparatorMargin = 1;
159 140
160 // Width of the separator between the recently bookmarked button and the 141 // Width of the separator between the recently bookmarked button and the
161 // overflow indicator, indexed by MD mode. 142 // overflow indicator.
162 static const int kSeparatorWidth[] = {4, 9, 9}; 143 static const int kSeparatorWidth = 9;
163
164 // Starting x-coordinate of the separator line within a separator.
165 static const int kSeparatorStartX = 2;
166 144
167 // Left-padding for the instructional text. 145 // Left-padding for the instructional text.
168 static const int kInstructionsPadding = 6; 146 static const int kInstructionsPadding = 6;
169 147
170 // Tag for the 'Apps Shortcut' button. 148 // Tag for the 'Apps Shortcut' button.
171 static const int kAppsShortcutButtonTag = 2; 149 static const int kAppsShortcutButtonTag = 2;
172 150
173 // Preferred padding between text and edge. 151 // Preferred padding between text and edge.
174 static const int kButtonPaddingHorizontal = 6; 152 static const int kButtonPaddingHorizontal = 6;
175 static const int kButtonPaddingVertical = 5; 153 static const int kButtonPaddingVertical = 5;
176 154
177 static const gfx::ElideBehavior kElideBehavior = gfx::FADE_TAIL; 155 static const gfx::ElideBehavior kElideBehavior = gfx::FADE_TAIL;
178 156
179 namespace { 157 namespace {
180 158
181 // To enable/disable BookmarkBar animations during testing. In production 159 // To enable/disable BookmarkBar animations during testing. In production
182 // animations are enabled by default. 160 // animations are enabled by default.
183 bool animations_enabled = true; 161 bool animations_enabled = true;
184 162
185 gfx::ImageSkia* GetImageSkiaNamed(int id) { 163 gfx::ImageSkia* GetImageSkiaNamed(int id) {
186 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); 164 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
187 } 165 }
188 166
189 int GetHorizontalMargin() {
190 return kHorizontalMargin[ui::MaterialDesignController::GetMode()];
191 }
192
193 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { 167 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) {
194 gfx::Rect ink_drop_bounds(size); 168 gfx::Rect ink_drop_bounds(size);
195 ink_drop_bounds.Inset(0, 1); 169 ink_drop_bounds.Inset(0, 1);
196 return ink_drop_bounds; 170 return ink_drop_bounds;
197 } 171 }
198 172
199 // BookmarkButtonBase ----------------------------------------------- 173 // BookmarkButtonBase -----------------------------------------------
200 174
201 // Base class for non-menu hosting buttons used on the bookmark bar. 175 // Base class for non-menu hosting buttons used on the bookmark bar.
202 176
203 class BookmarkButtonBase : public views::LabelButton { 177 class BookmarkButtonBase : public views::LabelButton {
204 public: 178 public:
205 BookmarkButtonBase(views::ButtonListener* listener, 179 BookmarkButtonBase(views::ButtonListener* listener,
206 const base::string16& title) 180 const base::string16& title)
207 : LabelButton(listener, title) { 181 : LabelButton(listener, title) {
208 SetElideBehavior(kElideBehavior); 182 SetElideBehavior(kElideBehavior);
209 if (ui::MaterialDesignController::IsModeMaterial()) { 183 SetInkDropMode(InkDropMode::ON);
210 SetInkDropMode(InkDropMode::ON); 184 set_has_ink_drop_action_on_click(true);
211 set_has_ink_drop_action_on_click(true); 185 SetFocusPainter(nullptr);
212 SetFocusPainter(nullptr);
213 }
214 show_animation_.reset(new gfx::SlideAnimation(this)); 186 show_animation_.reset(new gfx::SlideAnimation(this));
215 if (!animations_enabled) { 187 if (!animations_enabled) {
216 // For some reason during testing the events generated by animating 188 // For some reason during testing the events generated by animating
217 // throw off the test. So, don't animate while testing. 189 // throw off the test. So, don't animate while testing.
218 show_animation_->Reset(1); 190 show_animation_->Reset(1);
219 } else { 191 } else {
220 show_animation_->Show(); 192 show_animation_->Show();
221 } 193 }
222 } 194 }
223 195
224 View* GetTooltipHandlerForPoint(const gfx::Point& point) override { 196 View* GetTooltipHandlerForPoint(const gfx::Point& point) override {
225 return HitTestPoint(point) && CanProcessEventsWithinSubtree() ? this : NULL; 197 return HitTestPoint(point) && CanProcessEventsWithinSubtree() ? this
198 : nullptr;
226 } 199 }
227 200
228 std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override { 201 std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override {
229 std::unique_ptr<LabelButtonBorder> border = 202 std::unique_ptr<LabelButtonBorder> border =
230 LabelButton::CreateDefaultBorder(); 203 LabelButton::CreateDefaultBorder();
231 border->set_insets(gfx::Insets(kButtonPaddingVertical, 204 border->set_insets(gfx::Insets(kButtonPaddingVertical,
232 kButtonPaddingHorizontal, 205 kButtonPaddingHorizontal,
233 kButtonPaddingVertical, 206 kButtonPaddingVertical,
234 kButtonPaddingHorizontal)); 207 kButtonPaddingHorizontal));
235 return border; 208 return border;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 302
330 // BookmarkMenuButtonBase ----------------------------------------------------- 303 // BookmarkMenuButtonBase -----------------------------------------------------
331 304
332 // Base class for menu hosting buttons used on the bookmark bar. 305 // Base class for menu hosting buttons used on the bookmark bar.
333 class BookmarkMenuButtonBase : public views::MenuButton { 306 class BookmarkMenuButtonBase : public views::MenuButton {
334 public: 307 public:
335 BookmarkMenuButtonBase(const base::string16& title, 308 BookmarkMenuButtonBase(const base::string16& title,
336 views::MenuButtonListener* menu_button_listener, 309 views::MenuButtonListener* menu_button_listener,
337 bool show_menu_marker) 310 bool show_menu_marker)
338 : MenuButton(title, menu_button_listener, show_menu_marker) { 311 : MenuButton(title, menu_button_listener, show_menu_marker) {
339 if (ui::MaterialDesignController::IsModeMaterial()) { 312 SetInkDropMode(InkDropMode::ON);
340 SetInkDropMode(InkDropMode::ON); 313 SetFocusPainter(nullptr);
341 SetFocusPainter(nullptr);
342 }
343 } 314 }
344 315
345 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 316 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
346 return base::MakeUnique<views::FloodFillInkDropRipple>( 317 return base::MakeUnique<views::FloodFillInkDropRipple>(
347 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(), 318 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(),
348 GetInkDropBaseColor(), ink_drop_visible_opacity()); 319 GetInkDropBaseColor(), ink_drop_visible_opacity());
349 } 320 }
350 321
351 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 322 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
352 const override { 323 const override {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 int y; 475 int y;
505 476
506 // DropData for the drop. 477 // DropData for the drop.
507 BookmarkNodeData data; 478 BookmarkNodeData data;
508 479
509 DropLocation location; 480 DropLocation location;
510 }; 481 };
511 482
512 // ButtonSeparatorView -------------------------------------------------------- 483 // ButtonSeparatorView --------------------------------------------------------
513 484
514 // Paints a themed gradient divider at location |x|. |height| is the full
515 // height of the view you want to paint the divider into, not the height of
516 // the divider. The height of the divider will become:
517 // |height| - 2 * |vertical_padding|.
518 // The color of the divider is a gradient starting with |top_color| at the
519 // top, and changing into |middle_color| and then over to |bottom_color| as
520 // you go further down.
521 void PaintVerticalDivider(gfx::Canvas* canvas,
522 int x,
523 int height,
524 int vertical_padding,
525 SkColor top_color,
526 SkColor middle_color,
527 SkColor bottom_color) {
528 // Draw the upper half of the divider.
529 SkPaint paint;
530 paint.setShader(gfx::CreateGradientShader(
531 vertical_padding + 1, height / 2, top_color, middle_color));
532 SkRect rc = { SkIntToScalar(x),
533 SkIntToScalar(vertical_padding + 1),
534 SkIntToScalar(x + 1),
535 SkIntToScalar(height / 2) };
536 canvas->sk_canvas()->drawRect(rc, paint);
537
538 // Draw the lower half of the divider.
539 SkPaint paint_down;
540 paint_down.setShader(gfx::CreateGradientShader(
541 height / 2, height - vertical_padding, middle_color, bottom_color));
542 SkRect rc_down = { SkIntToScalar(x),
543 SkIntToScalar(height / 2),
544 SkIntToScalar(x + 1),
545 SkIntToScalar(height - vertical_padding) };
546 canvas->sk_canvas()->drawRect(rc_down, paint_down);
547 }
548
549 class BookmarkBarView::ButtonSeparatorView : public views::View { 485 class BookmarkBarView::ButtonSeparatorView : public views::View {
550 public: 486 public:
551 ButtonSeparatorView() {} 487 ButtonSeparatorView() {}
552 ~ButtonSeparatorView() override {} 488 ~ButtonSeparatorView() override {}
553 489
554 void OnPaint(gfx::Canvas* canvas) override { 490 void OnPaint(gfx::Canvas* canvas) override {
555 if (ui::MaterialDesignController::IsModeMaterial()) { 491 gfx::ScopedCanvas scoped_canvas(canvas);
556 gfx::ScopedCanvas scoped_canvas(canvas); 492 // 1px wide at all scale factors. If there is an uneven amount of padding
557 // 1px wide at all scale factors. If there is an uneven amount of padding 493 // left over, place the extra pixel on the outside, i.e. away from the
558 // left over, place the extra pixel on the outside, i.e. away from the 494 // "Other bookmarks" folder.
559 // "Other bookmarks" folder. 495 const float scale = canvas->UndoDeviceScaleFactor();
560 const float scale = canvas->UndoDeviceScaleFactor(); 496 const gfx::RectF scaled_bounds =
561 const gfx::RectF scaled_bounds = 497 gfx::ScaleRect(gfx::RectF(bounds()), scale);
562 gfx::ScaleRect(gfx::RectF(bounds()), scale);
563 498
564 const int kLineThickness = 1; 499 const int kLineThickness = 1;
565 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f; 500 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f;
566 const int x = base::i18n::IsRTL() ? std::floor(fractional_x) 501 const int x = base::i18n::IsRTL() ? std::floor(fractional_x)
567 : std::ceil(fractional_x); 502 : std::ceil(fractional_x);
568 503
569 const int height = gfx::kFaviconSize * scale; 504 const int height = gfx::kFaviconSize * scale;
570 const int top_y = (scaled_bounds.height() - height) / 2; 505 const int top_y = (scaled_bounds.height() - height) / 2;
571 canvas->DrawLine(gfx::Point(x, top_y), gfx::Point(x, top_y + height), 506 canvas->DrawLine(gfx::Point(x, top_y), gfx::Point(x, top_y + height),
572 GetThemeProvider()->GetColor( 507 GetThemeProvider()->GetColor(
573 ThemeProperties::COLOR_TOOLBAR_VERTICAL_SEPARATOR)); 508 ThemeProperties::COLOR_TOOLBAR_VERTICAL_SEPARATOR));
574 } else {
575 PaintVerticalDivider(
576 canvas, kSeparatorStartX, height(), 1, kEdgeDividerColor,
577 kMiddleDividerColor,
578 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR));
579 }
580 } 509 }
581 510
582 gfx::Size GetPreferredSize() const override { 511 gfx::Size GetPreferredSize() const override {
583 // We get the full height of the bookmark bar, so that the height returned 512 // We get the full height of the bookmark bar, so that the height returned
584 // here doesn't matter. 513 // here doesn't matter.
585 return gfx::Size(kSeparatorWidth[ui::MaterialDesignController::GetMode()], 514 return gfx::Size(kSeparatorWidth, 1);
586 1);
587 } 515 }
588 516
589 void GetAccessibleState(ui::AXViewState* state) override { 517 void GetAccessibleState(ui::AXViewState* state) override {
590 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_SEPARATOR); 518 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_SEPARATOR);
591 state->role = ui::AX_ROLE_SPLITTER; 519 state->role = ui::AX_ROLE_SPLITTER;
592 } 520 }
593 521
594 private: 522 private:
595 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView); 523 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView);
596 }; 524 };
597 525
598 // BookmarkBarView ------------------------------------------------------------ 526 // BookmarkBarView ------------------------------------------------------------
599 527
600 // static 528 // static
601 const char BookmarkBarView::kViewClassName[] = "BookmarkBarView"; 529 const char BookmarkBarView::kViewClassName[] = "BookmarkBarView";
602 530
603 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view) 531 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view)
604 : page_navigator_(NULL), 532 : page_navigator_(nullptr),
605 managed_(NULL), 533 managed_(nullptr),
606 bookmark_menu_(NULL), 534 bookmark_menu_(nullptr),
607 bookmark_drop_menu_(NULL), 535 bookmark_drop_menu_(nullptr),
608 other_bookmarks_button_(NULL), 536 other_bookmarks_button_(nullptr),
609 managed_bookmarks_button_(NULL), 537 managed_bookmarks_button_(nullptr),
610 supervised_bookmarks_button_(NULL), 538 supervised_bookmarks_button_(nullptr),
611 apps_page_shortcut_(NULL), 539 apps_page_shortcut_(nullptr),
612 overflow_button_(NULL), 540 overflow_button_(nullptr),
613 instructions_(NULL), 541 instructions_(nullptr),
614 bookmarks_separator_view_(NULL), 542 bookmarks_separator_view_(nullptr),
615 browser_(browser), 543 browser_(browser),
616 browser_view_(browser_view), 544 browser_view_(browser_view),
617 infobar_visible_(false), 545 infobar_visible_(false),
618 size_animation_(this), 546 size_animation_(this),
619 throbbing_view_(NULL), 547 throbbing_view_(nullptr),
620 bookmark_bar_state_(BookmarkBar::SHOW), 548 bookmark_bar_state_(BookmarkBar::SHOW),
621 animating_detached_(false), 549 animating_detached_(false),
622 show_folder_method_factory_(this) { 550 show_folder_method_factory_(this) {
623 set_id(VIEW_ID_BOOKMARK_BAR); 551 set_id(VIEW_ID_BOOKMARK_BAR);
624 Init(); 552 Init();
625 553
626 if (ui::MaterialDesignController::IsModeMaterial()) { 554 // Don't let the bookmarks show on top of the location bar while animating.
627 // Don't let the bookmarks show on top of the location bar while animating. 555 SetPaintToLayer(true);
628 SetPaintToLayer(true); 556 layer()->SetMasksToBounds(true);
629 layer()->SetMasksToBounds(true); 557 layer()->SetFillsBoundsOpaquely(false);
630 layer()->SetFillsBoundsOpaquely(false);
631 }
632 558
633 size_animation_.Reset(1); 559 size_animation_.Reset(1);
634 } 560 }
635 561
636 BookmarkBarView::~BookmarkBarView() { 562 BookmarkBarView::~BookmarkBarView() {
637 if (model_) 563 if (model_)
638 model_->RemoveObserver(this); 564 model_->RemoveObserver(this);
639 565
640 // It's possible for the menu to outlive us, reset the observer to make sure 566 // It's possible for the menu to outlive us, reset the observer to make sure
641 // it doesn't have a reference to us. 567 // it doesn't have a reference to us.
642 if (bookmark_menu_) { 568 if (bookmark_menu_) {
643 bookmark_menu_->set_observer(NULL); 569 bookmark_menu_->set_observer(nullptr);
644 bookmark_menu_->SetPageNavigator(NULL); 570 bookmark_menu_->SetPageNavigator(nullptr);
645 bookmark_menu_->clear_bookmark_bar(); 571 bookmark_menu_->clear_bookmark_bar();
646 } 572 }
647 if (context_menu_.get()) 573 if (context_menu_.get())
648 context_menu_->SetPageNavigator(NULL); 574 context_menu_->SetPageNavigator(nullptr);
649 575
650 StopShowFolderDropMenuTimer(); 576 StopShowFolderDropMenuTimer();
651 } 577 }
652 578
653 // static 579 // static
654 void BookmarkBarView::DisableAnimationsForTesting(bool disabled) { 580 void BookmarkBarView::DisableAnimationsForTesting(bool disabled) {
655 animations_enabled = !disabled; 581 animations_enabled = !disabled;
656 } 582 }
657 583
658 void BookmarkBarView::AddObserver(BookmarkBarViewObserver* observer) { 584 void BookmarkBarView::AddObserver(BookmarkBarViewObserver* observer) {
(...skipping 28 matching lines...) Expand all
687 } 613 }
688 bookmark_bar_state_ = state; 614 bookmark_bar_state_ = state;
689 } 615 }
690 616
691 const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex( 617 const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex(
692 const gfx::Point& loc, 618 const gfx::Point& loc,
693 int* model_start_index) { 619 int* model_start_index) {
694 *model_start_index = 0; 620 *model_start_index = 0;
695 621
696 if (loc.x() < 0 || loc.x() >= width() || loc.y() < 0 || loc.y() >= height()) 622 if (loc.x() < 0 || loc.x() >= width() || loc.y() < 0 || loc.y() >= height())
697 return NULL; 623 return nullptr;
698 624
699 gfx::Point adjusted_loc(GetMirroredXInView(loc.x()), loc.y()); 625 gfx::Point adjusted_loc(GetMirroredXInView(loc.x()), loc.y());
700 626
701 // Check the managed button first. 627 // Check the managed button first.
702 if (managed_bookmarks_button_->visible() && 628 if (managed_bookmarks_button_->visible() &&
703 managed_bookmarks_button_->bounds().Contains(adjusted_loc)) { 629 managed_bookmarks_button_->bounds().Contains(adjusted_loc)) {
704 return managed_->managed_node(); 630 return managed_->managed_node();
705 } 631 }
706 632
707 // Then check the supervised button. 633 // Then check the supervised button.
(...skipping 17 matching lines...) Expand all
725 *model_start_index = GetFirstHiddenNodeIndex(); 651 *model_start_index = GetFirstHiddenNodeIndex();
726 return model_->bookmark_bar_node(); 652 return model_->bookmark_bar_node();
727 } 653 }
728 654
729 // And finally the other folder. 655 // And finally the other folder.
730 if (other_bookmarks_button_->visible() && 656 if (other_bookmarks_button_->visible() &&
731 other_bookmarks_button_->bounds().Contains(adjusted_loc)) { 657 other_bookmarks_button_->bounds().Contains(adjusted_loc)) {
732 return model_->other_node(); 658 return model_->other_node();
733 } 659 }
734 660
735 return NULL; 661 return nullptr;
736 } 662 }
737 663
738 views::MenuButton* BookmarkBarView::GetMenuButtonForNode( 664 views::MenuButton* BookmarkBarView::GetMenuButtonForNode(
739 const BookmarkNode* node) { 665 const BookmarkNode* node) {
740 if (node == managed_->managed_node()) 666 if (node == managed_->managed_node())
741 return managed_bookmarks_button_; 667 return managed_bookmarks_button_;
742 if (node == managed_->supervised_node()) 668 if (node == managed_->supervised_node())
743 return supervised_bookmarks_button_; 669 return supervised_bookmarks_button_;
744 if (node == model_->other_node()) 670 if (node == model_->other_node())
745 return other_bookmarks_button_; 671 return other_bookmarks_button_;
746 if (node == model_->bookmark_bar_node()) 672 if (node == model_->bookmark_bar_node())
747 return overflow_button_; 673 return overflow_button_;
748 int index = model_->bookmark_bar_node()->GetIndexOf(node); 674 int index = model_->bookmark_bar_node()->GetIndexOf(node);
749 if (index == -1 || !node->is_folder()) 675 if (index == -1 || !node->is_folder())
750 return NULL; 676 return nullptr;
751 return static_cast<views::MenuButton*>(child_at(index)); 677 return static_cast<views::MenuButton*>(child_at(index));
752 } 678 }
753 679
754 void BookmarkBarView::GetAnchorPositionForButton( 680 void BookmarkBarView::GetAnchorPositionForButton(
755 views::MenuButton* button, 681 views::MenuButton* button,
756 views::MenuAnchorPosition* anchor) { 682 views::MenuAnchorPosition* anchor) {
757 if (button == other_bookmarks_button_ || button == overflow_button_) 683 if (button == other_bookmarks_button_ || button == overflow_button_)
758 *anchor = views::MENU_ANCHOR_TOPRIGHT; 684 *anchor = views::MENU_ANCHOR_TOPRIGHT;
759 else 685 else
760 *anchor = views::MENU_ANCHOR_TOPLEFT; 686 *anchor = views::MENU_ANCHOR_TOPLEFT;
761 } 687 }
762 688
763 views::MenuItemView* BookmarkBarView::GetMenu() { 689 views::MenuItemView* BookmarkBarView::GetMenu() {
764 return bookmark_menu_ ? bookmark_menu_->menu() : NULL; 690 return bookmark_menu_ ? bookmark_menu_->menu() : nullptr;
765 } 691 }
766 692
767 views::MenuItemView* BookmarkBarView::GetContextMenu() { 693 views::MenuItemView* BookmarkBarView::GetContextMenu() {
768 return bookmark_menu_ ? bookmark_menu_->context_menu() : NULL; 694 return bookmark_menu_ ? bookmark_menu_->context_menu() : nullptr;
769 } 695 }
770 696
771 views::MenuItemView* BookmarkBarView::GetDropMenu() { 697 views::MenuItemView* BookmarkBarView::GetDropMenu() {
772 return bookmark_drop_menu_ ? bookmark_drop_menu_->menu() : NULL; 698 return bookmark_drop_menu_ ? bookmark_drop_menu_->menu() : nullptr;
773 } 699 }
774 700
775 void BookmarkBarView::StopThrobbing(bool immediate) { 701 void BookmarkBarView::StopThrobbing(bool immediate) {
776 if (!throbbing_view_) 702 if (!throbbing_view_)
777 return; 703 return;
778 704
779 // If not immediate, cycle through 2 more complete cycles. 705 // If not immediate, cycle through 2 more complete cycles.
780 throbbing_view_->StartThrobbing(immediate ? 0 : 4); 706 throbbing_view_->StartThrobbing(immediate ? 0 : 4);
781 throbbing_view_ = NULL; 707 throbbing_view_ = nullptr;
782 } 708 }
783 709
784 // static 710 // static
785 base::string16 BookmarkBarView::CreateToolTipForURLAndTitle( 711 base::string16 BookmarkBarView::CreateToolTipForURLAndTitle(
786 const views::Widget* widget, 712 const views::Widget* widget,
787 const gfx::Point& screen_loc, 713 const gfx::Point& screen_loc,
788 const GURL& url, 714 const GURL& url,
789 const base::string16& title) { 715 const base::string16& title) {
790 const views::TooltipManager* tooltip_manager = widget->GetTooltipManager(); 716 const views::TooltipManager* tooltip_manager = widget->GetTooltipManager();
791 int max_width = tooltip_manager->GetMaxWidth(screen_loc); 717 int max_width = tooltip_manager->GetMaxWidth(screen_loc);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 807 }
882 return true; 808 return true;
883 } 809 }
884 810
885 gfx::Size BookmarkBarView::GetMinimumSize() const { 811 gfx::Size BookmarkBarView::GetMinimumSize() const {
886 // The minimum width of the bookmark bar should at least contain the overflow 812 // The minimum width of the bookmark bar should at least contain the overflow
887 // button, by which one can access all the Bookmark Bar items, and the "Other 813 // button, by which one can access all the Bookmark Bar items, and the "Other
888 // Bookmarks" folder, along with appropriate margins and button padding. 814 // Bookmarks" folder, along with appropriate margins and button padding.
889 // It should also contain the Managed and/or Supervised Bookmarks folders, 815 // It should also contain the Managed and/or Supervised Bookmarks folders,
890 // if they are visible. 816 // if they are visible.
891 int width = GetHorizontalMargin(); 817 int width = kHorizontalMargin;
892 818
893 int height = GetPreferredHeight(); 819 int height = GetPreferredHeight();
894 if (IsDetached()) { 820 if (IsDetached()) {
895 double current_state = 1 - size_animation_.GetCurrentValue(); 821 double current_state = 1 - size_animation_.GetCurrentValue();
896 width += 2 * static_cast<int>(kNewTabHorizontalPadding * current_state); 822 width += 2 * static_cast<int>(kNewTabHorizontalPadding * current_state);
897 height += static_cast<int>((chrome::kNTPBookmarkBarHeight - height) * 823 height += static_cast<int>((chrome::kNTPBookmarkBarHeight - height) *
898 current_state); 824 current_state);
899 } 825 }
900 826
901 if (managed_bookmarks_button_->visible()) { 827 if (managed_bookmarks_button_->visible()) {
(...skipping 22 matching lines...) Expand all
924 } 850 }
925 851
926 return gfx::Size(width, height); 852 return gfx::Size(width, height);
927 } 853 }
928 854
929 void BookmarkBarView::Layout() { 855 void BookmarkBarView::Layout() {
930 // Skip layout during destruction, when no model exists. 856 // Skip layout during destruction, when no model exists.
931 if (!model_) 857 if (!model_)
932 return; 858 return;
933 859
934 int x = GetHorizontalMargin(); 860 int x = kHorizontalMargin;
935 int top_margin = IsDetached() ? kDetachedTopMargin : 0; 861 int top_margin = IsDetached() ? kDetachedTopMargin : 0;
936 int y = top_margin; 862 int y = top_margin;
937 int width = View::width() - 2 * GetHorizontalMargin(); 863 int width = View::width() - 2 * kHorizontalMargin;
938 int preferred_height = GetPreferredHeight(); 864 int preferred_height = GetPreferredHeight();
939 int height = preferred_height - kBottomMargin; 865 int height = preferred_height - kBottomMargin;
940 int separator_margin = kSeparatorMargin; 866 int separator_margin = kSeparatorMargin;
941 867
942 if (IsDetached()) { 868 if (IsDetached()) {
943 double current_state = 1 - size_animation_.GetCurrentValue(); 869 double current_state = 1 - size_animation_.GetCurrentValue();
944 x += static_cast<int>(kNewTabHorizontalPadding * current_state); 870 x += static_cast<int>(kNewTabHorizontalPadding * current_state);
945 y += (View::height() - preferred_height) / 2; 871 y += (View::height() - preferred_height) / 2;
946 width -= static_cast<int>(kNewTabHorizontalPadding * current_state); 872 width -= static_cast<int>(kNewTabHorizontalPadding * current_state);
947 separator_margin -= static_cast<int>(kSeparatorMargin * current_state); 873 separator_margin -= static_cast<int>(kSeparatorMargin * current_state);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 drop_info_->location.operation != 0 && drop_info_->location.index != -1 && 1009 drop_info_->location.operation != 0 && drop_info_->location.index != -1 &&
1084 drop_info_->location.button_type != DROP_OVERFLOW && 1010 drop_info_->location.button_type != DROP_OVERFLOW &&
1085 !drop_info_->location.on) { 1011 !drop_info_->location.on) {
1086 int index = drop_info_->location.index; 1012 int index = drop_info_->location.index;
1087 DCHECK(index <= GetBookmarkButtonCount()); 1013 DCHECK(index <= GetBookmarkButtonCount());
1088 int x = 0; 1014 int x = 0;
1089 int y = 0; 1015 int y = 0;
1090 int h = height(); 1016 int h = height();
1091 if (index == GetBookmarkButtonCount()) { 1017 if (index == GetBookmarkButtonCount()) {
1092 if (index == 0) { 1018 if (index == 0) {
1093 x = GetHorizontalMargin(); 1019 x = kHorizontalMargin;
1094 } else { 1020 } else {
1095 x = GetBookmarkButton(index - 1)->x() + 1021 x = GetBookmarkButton(index - 1)->x() +
1096 GetBookmarkButton(index - 1)->width(); 1022 GetBookmarkButton(index - 1)->width();
1097 } 1023 }
1098 } else { 1024 } else {
1099 x = GetBookmarkButton(index)->x(); 1025 x = GetBookmarkButton(index)->x();
1100 } 1026 }
1101 if (GetBookmarkButtonCount() > 0 && GetBookmarkButton(0)->visible()) { 1027 if (GetBookmarkButtonCount() > 0 && GetBookmarkButton(0)->visible()) {
1102 y = GetBookmarkButton(0)->y(); 1028 y = GetBookmarkButton(0)->y();
1103 h = GetBookmarkButton(0)->height(); 1029 h = GetBookmarkButton(0)->height();
1104 } 1030 }
1105 1031
1106 // Since the drop indicator is painted directly onto the canvas, we must 1032 // Since the drop indicator is painted directly onto the canvas, we must
1107 // make sure it is painted in the right location if the locale is RTL. 1033 // make sure it is painted in the right location if the locale is RTL.
1108 gfx::Rect indicator_bounds(x - kDropIndicatorWidth / 2, 1034 gfx::Rect indicator_bounds(x - kDropIndicatorWidth / 2,
1109 y, 1035 y,
1110 kDropIndicatorWidth, 1036 kDropIndicatorWidth,
1111 h); 1037 h);
1112 indicator_bounds.set_x(GetMirroredXForRect(indicator_bounds)); 1038 indicator_bounds.set_x(GetMirroredXForRect(indicator_bounds));
1113 1039
1114 ui::PaintRecorder recorder(context, size()); 1040 ui::PaintRecorder recorder(context, size());
1115 // TODO(sky/glen): make me pretty! 1041 // TODO(sky/glen): make me pretty!
1116 recorder.canvas()->FillRect(indicator_bounds, kDropIndicatorColor); 1042 recorder.canvas()->FillRect(
1043 indicator_bounds,
1044 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT));
1117 } 1045 }
1118 } 1046 }
1119 1047
1120 bool BookmarkBarView::GetDropFormats( 1048 bool BookmarkBarView::GetDropFormats(
1121 int* formats, 1049 int* formats,
1122 std::set<ui::Clipboard::FormatType>* format_types) { 1050 std::set<ui::Clipboard::FormatType>* format_types) {
1123 if (!model_ || !model_->loaded()) 1051 if (!model_ || !model_->loaded())
1124 return false; 1052 return false;
1125 *formats = ui::OSExchangeData::URL; 1053 *formats = ui::OSExchangeData::URL;
1126 format_types->insert(BookmarkNodeData::GetBookmarkFormatType()); 1054 format_types->insert(BookmarkNodeData::GetBookmarkFormatType());
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 OnBookmarkBarVisibilityChanged()); 1195 OnBookmarkBarVisibilityChanged());
1268 } 1196 }
1269 } 1197 }
1270 1198
1271 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) { 1199 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) {
1272 state->role = ui::AX_ROLE_TOOLBAR; 1200 state->role = ui::AX_ROLE_TOOLBAR;
1273 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS); 1201 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS);
1274 } 1202 }
1275 1203
1276 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) { 1204 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) {
1277 // |browser_view_| can be NULL during tests. 1205 // |browser_view_| can be nullptr during tests.
Peter Kasting 2016/09/22 03:23:27 Nit: Prefer "null" to "nullptr" in comments, it ju
Evan Stade 2016/09/22 14:35:27 Done.
1278 if (browser_view_) 1206 if (browser_view_)
1279 browser_view_->ToolbarSizeChanged(true); 1207 browser_view_->ToolbarSizeChanged(true);
1280 } 1208 }
1281 1209
1282 void BookmarkBarView::AnimationEnded(const gfx::Animation* animation) { 1210 void BookmarkBarView::AnimationEnded(const gfx::Animation* animation) {
1283 // |browser_view_| can be NULL during tests. 1211 // |browser_view_| can be nullptr during tests.
1284 if (browser_view_) { 1212 if (browser_view_) {
1285 browser_view_->ToolbarSizeChanged(false); 1213 browser_view_->ToolbarSizeChanged(false);
1286 SchedulePaint(); 1214 SchedulePaint();
1287 } 1215 }
1288 } 1216 }
1289 1217
1290 void BookmarkBarView::BookmarkMenuControllerDeleted( 1218 void BookmarkBarView::BookmarkMenuControllerDeleted(
1291 BookmarkMenuController* controller) { 1219 BookmarkMenuController* controller) {
1292 if (controller == bookmark_menu_) 1220 if (controller == bookmark_menu_)
1293 bookmark_menu_ = NULL; 1221 bookmark_menu_ = nullptr;
1294 else if (controller == bookmark_drop_menu_) 1222 else if (controller == bookmark_drop_menu_)
1295 bookmark_drop_menu_ = NULL; 1223 bookmark_drop_menu_ = nullptr;
1296 } 1224 }
1297 1225
1298 void BookmarkBarView::OnImportBookmarks() { 1226 void BookmarkBarView::OnImportBookmarks() {
1299 int64_t install_time = g_browser_process->metrics_service()->GetInstallDate(); 1227 int64_t install_time = g_browser_process->metrics_service()->GetInstallDate();
1300 int64_t time_from_install = base::Time::Now().ToTimeT() - install_time; 1228 int64_t time_from_install = base::Time::Now().ToTimeT() - install_time;
1301 if (bookmark_bar_state_ == BookmarkBar::SHOW) { 1229 if (bookmark_bar_state_ == BookmarkBar::SHOW) {
1302 UMA_HISTOGRAM_COUNTS("Import.ShowDialog.FromBookmarkBarView", 1230 UMA_HISTOGRAM_COUNTS("Import.ShowDialog.FromBookmarkBarView",
1303 time_from_install); 1231 time_from_install);
1304 } else if (bookmark_bar_state_ == BookmarkBar::DETACHED) { 1232 } else if (bookmark_bar_state_ == BookmarkBar::DETACHED) {
1305 UMA_HISTOGRAM_COUNTS("Import.ShowDialog.FromFloatingBookmarkBarView", 1233 UMA_HISTOGRAM_COUNTS("Import.ShowDialog.FromFloatingBookmarkBarView",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 other_bookmarks_button_->SetEnabled(true); 1269 other_bookmarks_button_->SetEnabled(true);
1342 managed_bookmarks_button_->SetEnabled(true); 1270 managed_bookmarks_button_->SetEnabled(true);
1343 supervised_bookmarks_button_->SetEnabled(true); 1271 supervised_bookmarks_button_->SetEnabled(true);
1344 LayoutAndPaint(); 1272 LayoutAndPaint();
1345 } 1273 }
1346 1274
1347 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) { 1275 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) {
1348 NOTREACHED(); 1276 NOTREACHED();
1349 // Do minimal cleanup, presumably we'll be deleted shortly. 1277 // Do minimal cleanup, presumably we'll be deleted shortly.
1350 model_->RemoveObserver(this); 1278 model_->RemoveObserver(this);
1351 model_ = NULL; 1279 model_ = nullptr;
1352 } 1280 }
1353 1281
1354 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, 1282 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model,
1355 const BookmarkNode* old_parent, 1283 const BookmarkNode* old_parent,
1356 int old_index, 1284 int old_index,
1357 const BookmarkNode* new_parent, 1285 const BookmarkNode* new_parent,
1358 int new_index) { 1286 int new_index) {
1359 bool was_throbbing = throbbing_view_ && 1287 bool was_throbbing = throbbing_view_ &&
1360 throbbing_view_ == DetermineViewToThrobFromRemove(old_parent, old_index); 1288 throbbing_view_ == DetermineViewToThrobFromRemove(old_parent, old_index);
1361 if (was_throbbing) 1289 if (was_throbbing)
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 1545
1618 context_menu_.reset(new BookmarkContextMenu( 1546 context_menu_.reset(new BookmarkContextMenu(
1619 GetWidget(), browser_, browser_->profile(), 1547 GetWidget(), browser_, browser_->profile(),
1620 browser_->tab_strip_model()->GetActiveWebContents(), 1548 browser_->tab_strip_model()->GetActiveWebContents(),
1621 parent, nodes, close_on_remove)); 1549 parent, nodes, close_on_remove));
1622 context_menu_->RunMenuAt(point, source_type); 1550 context_menu_->RunMenuAt(point, source_type);
1623 } 1551 }
1624 1552
1625 void BookmarkBarView::Init() { 1553 void BookmarkBarView::Init() {
1626 // Note that at this point we're not in a hierarchy so GetThemeProvider() will 1554 // Note that at this point we're not in a hierarchy so GetThemeProvider() will
1627 // return NULL. When we're inserted into a hierarchy, we'll call 1555 // return nullptr. When we're inserted into a hierarchy, we'll call
1628 // UpdateAppearanceForTheme(), which will set the appropriate colors for all 1556 // UpdateAppearanceForTheme(), which will set the appropriate colors for all
1629 // the objects 1557 // the objects added in this function.
1630 // added in this function.
1631 1558
1632 // Child views are traversed in the order they are added. Make sure the order 1559 // Child views are traversed in the order they are added. Make sure the order
1633 // they are added matches the visual order. 1560 // they are added matches the visual order.
1634 overflow_button_ = CreateOverflowButton(); 1561 overflow_button_ = CreateOverflowButton();
1635 AddChildView(overflow_button_); 1562 AddChildView(overflow_button_);
1636 1563
1637 other_bookmarks_button_ = CreateOtherBookmarksButton(); 1564 other_bookmarks_button_ = CreateOtherBookmarksButton();
1638 // We'll re-enable when the model is loaded. 1565 // We'll re-enable when the model is loaded.
1639 other_bookmarks_button_->SetEnabled(false); 1566 other_bookmarks_button_->SetEnabled(false);
1640 AddChildView(other_bookmarks_button_); 1567 AddChildView(other_bookmarks_button_);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 return; 2114 return;
2188 apps_page_shortcut_->SetVisible(visible); 2115 apps_page_shortcut_->SetVisible(visible);
2189 UpdateBookmarksSeparatorVisibility(); 2116 UpdateBookmarksSeparatorVisibility();
2190 LayoutAndPaint(); 2117 LayoutAndPaint();
2191 } 2118 }
2192 2119
2193 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2120 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2194 if (UpdateOtherAndManagedButtonsVisibility()) 2121 if (UpdateOtherAndManagedButtonsVisibility())
2195 LayoutAndPaint(); 2122 LayoutAndPaint();
2196 } 2123 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698