| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/toolbar_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void ToolbarActionView::DecorateWantsToRunBorder( | 79 void ToolbarActionView::DecorateWantsToRunBorder( |
| 80 views::LabelButtonBorder* border) { | 80 views::LabelButtonBorder* border) { |
| 81 // Create a special border for when the action wants to run, which gives the | 81 // Create a special border for when the action wants to run, which gives the |
| 82 // button a "popped out" state. | 82 // button a "popped out" state. |
| 83 static const int kRaisedImages[] = IMAGE_GRID(IDR_TEXTBUTTON_RAISED); | 83 static const int kRaisedImages[] = IMAGE_GRID(IDR_TEXTBUTTON_RAISED); |
| 84 border->SetPainter(false, | 84 border->SetPainter(false, |
| 85 views::Button::STATE_NORMAL, | 85 views::Button::STATE_NORMAL, |
| 86 views::Painter::CreateImageGridPainter(kRaisedImages)); | 86 views::Painter::CreateImageGridPainter(kRaisedImages)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void ToolbarActionView::ViewHierarchyChanged( | 89 gfx::Size ToolbarActionView::GetPreferredSize() const { |
| 90 const ViewHierarchyChangedDetails& details) { | 90 return gfx::Size(ToolbarActionsBar::IconWidth(false), |
| 91 if (details.is_add && !called_register_command_ && GetFocusManager()) { | 91 ToolbarActionsBar::IconHeight()); |
| 92 view_controller_->RegisterCommand(); | 92 } |
| 93 called_register_command_ = true; | |
| 94 } | |
| 95 | 93 |
| 96 MenuButton::ViewHierarchyChanged(details); | 94 const char* ToolbarActionView::GetClassName() const { |
| 95 return "ToolbarActionView"; |
| 97 } | 96 } |
| 98 | 97 |
| 99 void ToolbarActionView::OnDragDone() { | 98 void ToolbarActionView::OnDragDone() { |
| 100 views::MenuButton::OnDragDone(); | 99 views::MenuButton::OnDragDone(); |
| 101 delegate_->OnToolbarActionViewDragDone(); | 100 delegate_->OnToolbarActionViewDragDone(); |
| 102 } | 101 } |
| 103 | 102 |
| 104 gfx::Size ToolbarActionView::GetPreferredSize() const { | 103 void ToolbarActionView::ViewHierarchyChanged( |
| 105 return gfx::Size(ToolbarActionsBar::IconWidth(false), | 104 const ViewHierarchyChangedDetails& details) { |
| 106 ToolbarActionsBar::IconHeight()); | 105 if (details.is_add && !called_register_command_ && GetFocusManager()) { |
| 106 view_controller_->RegisterCommand(); |
| 107 called_register_command_ = true; |
| 108 } |
| 109 |
| 110 MenuButton::ViewHierarchyChanged(details); |
| 107 } | 111 } |
| 108 | 112 |
| 109 void ToolbarActionView::PaintChildren(gfx::Canvas* canvas, | 113 void ToolbarActionView::PaintChildren(gfx::Canvas* canvas, |
| 110 const views::CullSet& cull_set) { | 114 const views::CullSet& cull_set) { |
| 111 View::PaintChildren(canvas, cull_set); | 115 View::PaintChildren(canvas, cull_set); |
| 112 view_controller_->PaintExtra( | 116 view_controller_->PaintExtra( |
| 113 canvas, GetLocalBounds(), GetCurrentWebContents()); | 117 canvas, GetLocalBounds(), GetCurrentWebContents()); |
| 114 } | 118 } |
| 115 | 119 |
| 116 void ToolbarActionView::OnPaintBorder(gfx::Canvas* canvas) { | 120 void ToolbarActionView::OnPaintBorder(gfx::Canvas* canvas) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 300 } |
| 297 | 301 |
| 298 void ToolbarActionView::CleanupPopup() { | 302 void ToolbarActionView::CleanupPopup() { |
| 299 // We need to do these actions synchronously (instead of closing and then | 303 // We need to do these actions synchronously (instead of closing and then |
| 300 // performing the rest of the cleanup in OnWidgetDestroyed()) because | 304 // performing the rest of the cleanup in OnWidgetDestroyed()) because |
| 301 // OnWidgetDestroyed() can be called asynchronously from Close(), and we need | 305 // OnWidgetDestroyed() can be called asynchronously from Close(), and we need |
| 302 // to keep the delegate's popup owner up-to-date. | 306 // to keep the delegate's popup owner up-to-date. |
| 303 delegate_->SetPopupOwner(NULL); | 307 delegate_->SetPopupOwner(NULL); |
| 304 pressed_lock_.reset(); // Unpress the menu button if it was pressed. | 308 pressed_lock_.reset(); // Unpress the menu button if it was pressed. |
| 305 } | 309 } |
| OLD | NEW |