OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" | 5 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" |
6 | 6 |
7 #import "ui/base/cocoa/menu_controller.h" | 7 #import "ui/base/cocoa/menu_controller.h" |
8 #include "ui/base/models/menu_model.h" | 8 #include "ui/base/models/menu_model.h" |
9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 [anchor_view setHidden:YES]; | 75 [anchor_view setHidden:YES]; |
76 [[window contentView] addSubview:anchor_view]; | 76 [[window contentView] addSubview:anchor_view]; |
77 return anchor_view; | 77 return anchor_view; |
78 } | 78 } |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 // static | 82 // static |
83 MenuRunnerImplInterface* MenuRunnerImplInterface::Create( | 83 MenuRunnerImplInterface* MenuRunnerImplInterface::Create( |
84 ui::MenuModel* menu_model, | 84 ui::MenuModel* menu_model, |
85 int32 run_types) { | 85 int32_t run_types) { |
86 if ((run_types & kNativeRunTypes) != 0 && | 86 if ((run_types & kNativeRunTypes) != 0 && |
87 (run_types & MenuRunner::IS_NESTED) == 0) { | 87 (run_types & MenuRunner::IS_NESTED) == 0) { |
88 return new MenuRunnerImplCocoa(menu_model); | 88 return new MenuRunnerImplCocoa(menu_model); |
89 } | 89 } |
90 | 90 |
91 return new MenuRunnerImplAdapter(menu_model); | 91 return new MenuRunnerImplAdapter(menu_model); |
92 } | 92 } |
93 | 93 |
94 MenuRunnerImplCocoa::MenuRunnerImplCocoa(ui::MenuModel* menu) | 94 MenuRunnerImplCocoa::MenuRunnerImplCocoa(ui::MenuModel* menu) |
95 : delete_after_run_(false), closing_event_time_(base::TimeDelta()) { | 95 : delete_after_run_(false), closing_event_time_(base::TimeDelta()) { |
(...skipping 14 matching lines...) Expand all Loading... |
110 [menu_controller_ cancel]; | 110 [menu_controller_ cancel]; |
111 } else { | 111 } else { |
112 delete this; | 112 delete this; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 MenuRunner::RunResult MenuRunnerImplCocoa::RunMenuAt(Widget* parent, | 116 MenuRunner::RunResult MenuRunnerImplCocoa::RunMenuAt(Widget* parent, |
117 MenuButton* button, | 117 MenuButton* button, |
118 const gfx::Rect& bounds, | 118 const gfx::Rect& bounds, |
119 MenuAnchorPosition anchor, | 119 MenuAnchorPosition anchor, |
120 int32 run_types) { | 120 int32_t run_types) { |
121 DCHECK(run_types & kNativeRunTypes); | 121 DCHECK(run_types & kNativeRunTypes); |
122 DCHECK(!IsRunning()); | 122 DCHECK(!IsRunning()); |
123 DCHECK(parent); | 123 DCHECK(parent); |
124 closing_event_time_ = base::TimeDelta(); | 124 closing_event_time_ = base::TimeDelta(); |
125 | 125 |
126 if (run_types & MenuRunner::CONTEXT_MENU) { | 126 if (run_types & MenuRunner::CONTEXT_MENU) { |
127 [NSMenu popUpContextMenu:[menu_controller_ menu] | 127 [NSMenu popUpContextMenu:[menu_controller_ menu] |
128 withEvent:[NSApp currentEvent] | 128 withEvent:[NSApp currentEvent] |
129 forView:parent->GetNativeView()]; | 129 forView:parent->GetNativeView()]; |
130 } else if (run_types & MenuRunner::COMBOBOX) { | 130 } else if (run_types & MenuRunner::COMBOBOX) { |
(...skipping 26 matching lines...) Expand all Loading... |
157 | 157 |
158 base::TimeDelta MenuRunnerImplCocoa::GetClosingEventTime() const { | 158 base::TimeDelta MenuRunnerImplCocoa::GetClosingEventTime() const { |
159 return closing_event_time_; | 159 return closing_event_time_; |
160 } | 160 } |
161 | 161 |
162 MenuRunnerImplCocoa::~MenuRunnerImplCocoa() { | 162 MenuRunnerImplCocoa::~MenuRunnerImplCocoa() { |
163 } | 163 } |
164 | 164 |
165 } // namespace internal | 165 } // namespace internal |
166 } // namespace views | 166 } // namespace views |
OLD | NEW |