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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view.cc

Issue 1494433003: Fixes a crash when InkDropDelegate gets destroyed after its InkDropHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes a crash when InkDropDelegate gets destroyed after its InkDropHost (delegate owned by a leaf c… Created 5 years 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
OLDNEW
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 "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ToolbarActionViewController* view_controller, 60 ToolbarActionViewController* view_controller,
61 Profile* profile, 61 Profile* profile,
62 ToolbarActionView::Delegate* delegate) 62 ToolbarActionView::Delegate* delegate)
63 : MenuButton(nullptr, base::string16(), this, false), 63 : MenuButton(nullptr, base::string16(), this, false),
64 view_controller_(view_controller), 64 view_controller_(view_controller),
65 profile_(profile), 65 profile_(profile),
66 delegate_(delegate), 66 delegate_(delegate),
67 called_register_command_(false), 67 called_register_command_(false),
68 wants_to_run_(false), 68 wants_to_run_(false),
69 menu_(nullptr), 69 menu_(nullptr),
70 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)),
70 weak_factory_(this) { 71 weak_factory_(this) {
71 scoped_ptr<views::InkDropDelegate> new_ink_drop_delegate( 72 set_ink_drop_delegate(ink_drop_delegate_.get());
72 new views::ButtonInkDropDelegate(this, this));
73 SetInkDropDelegate(new_ink_drop_delegate.Pass());
74 set_id(VIEW_ID_BROWSER_ACTION); 73 set_id(VIEW_ID_BROWSER_ACTION);
75 view_controller_->SetDelegate(this); 74 view_controller_->SetDelegate(this);
76 SetHorizontalAlignment(gfx::ALIGN_CENTER); 75 SetHorizontalAlignment(gfx::ALIGN_CENTER);
77 set_drag_controller(delegate_); 76 set_drag_controller(delegate_);
78 77
79 set_context_menu_controller(this); 78 set_context_menu_controller(this);
80 79
81 const int kInkDropLargeSize = 32; 80 const int kInkDropLargeSize = 32;
82 const int kInkDropLargeCornerRadius = 5; 81 const int kInkDropLargeCornerRadius = 5;
83 const int kInkDropSmallSize = 24; 82 const int kInkDropSmallSize = 24;
(...skipping 18 matching lines...) Expand all
102 SetFocusable(true); 101 SetFocusable(true);
103 } 102 }
104 103
105 UpdateState(); 104 UpdateState();
106 } 105 }
107 106
108 ToolbarActionView::~ToolbarActionView() { 107 ToolbarActionView::~ToolbarActionView() {
109 if (context_menu_owner == this) 108 if (context_menu_owner == this)
110 context_menu_owner = nullptr; 109 context_menu_owner = nullptr;
111 view_controller_->SetDelegate(nullptr); 110 view_controller_->SetDelegate(nullptr);
111 ink_drop_delegate_.reset();
112 set_ink_drop_delegate(nullptr);
112 } 113 }
113 114
114 void ToolbarActionView::GetAccessibleState(ui::AXViewState* state) { 115 void ToolbarActionView::GetAccessibleState(ui::AXViewState* state) {
115 views::MenuButton::GetAccessibleState(state); 116 views::MenuButton::GetAccessibleState(state);
116 state->role = ui::AX_ROLE_BUTTON; 117 state->role = ui::AX_ROLE_BUTTON;
117 } 118 }
118 119
119 scoped_ptr<LabelButtonBorder> ToolbarActionView::CreateDefaultBorder() const { 120 scoped_ptr<LabelButtonBorder> ToolbarActionView::CreateDefaultBorder() const {
120 scoped_ptr<LabelButtonBorder> border = LabelButton::CreateDefaultBorder(); 121 scoped_ptr<LabelButtonBorder> border = LabelButton::CreateDefaultBorder();
121 border->set_insets(gfx::Insets(kBorderInset, kBorderInset, 122 border->set_insets(gfx::Insets(kBorderInset, kBorderInset,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (menu_controller->in_nested_run()) { 386 if (menu_controller->in_nested_run()) {
386 // There is another menu showing. Close the outermost menu (since we are 387 // There is another menu showing. Close the outermost menu (since we are
387 // shown in the same menu, we don't want to close the whole thing). 388 // shown in the same menu, we don't want to close the whole thing).
388 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); 389 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST);
389 return true; 390 return true;
390 } 391 }
391 } 392 }
392 393
393 return false; 394 return false;
394 } 395 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_action_view.h ('k') | ui/views/animation/ink_drop_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698