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

Issue 2394123002: Views: Expose an on_closed callback via the MenuRunner constructor. (Closed)

Created:
4 years, 2 months ago by tapted
Modified:
4 years, 2 months ago
Reviewers:
jonross, sky
CC:
chromium-reviews, tfarina, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 Committed: https://crrev.com/7a7c6831b11536332403881c6619986b55f62e05 Cr-Commit-Position: refs/heads/master@{#425186}

Patch Set 1 : Test both adapters #

Patch Set 2 : Self review #

Patch Set 3 : Just overload constructor. #

Patch Set 4 : Remove more unnecessary adapters #

Patch Set 5 : Simpler #

Patch Set 6 : NON_EXPORTED_BASE #

Total comments: 5

Patch Set 7 : DO NOT COMMIT - Annotate callers to see if they can use MenuModel/SimpleMenuModel::Delegate #

Patch Set 8 : Delete [Simple]MenuModel[::Delegate]::Menu[Will]Close[d]? (eep!) +TODO(investigate RVCMM) #

Patch Set 9 : Back to Patch set 6 #

Total comments: 2

Patch Set 10 : default arg #

Unified diffs Side-by-side diffs Delta from patch set Stats (+230 lines, -98 lines) Patch
M chrome/browser/ui/views/download/download_shelf_context_menu_view.h View 1 2 3 7 2 chunks +1 line, -3 lines 0 comments Download
M chrome/browser/ui/views/download/download_shelf_context_menu_view.cc View 1 2 3 7 3 chunks +7 lines, -12 lines 0 comments Download
M chrome/browser/ui/views/extensions/media_galleries_dialog_views.h View 1 2 3 3 chunks +1 line, -3 lines 0 comments Download
M chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc View 1 2 3 7 3 chunks +3 lines, -8 lines 0 comments Download
M chrome/browser/ui/views/frame/browser_frame.h View 1 2 3 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/frame/browser_frame.cc View 1 2 3 7 3 chunks +3 lines, -7 lines 0 comments Download
M ui/views/controls/combobox/combobox.h View 1 2 3 4 7 2 chunks +0 lines, -2 lines 0 comments Download
M ui/views/controls/combobox/combobox.cc View 7 3 chunks +4 lines, -8 lines 0 comments Download
M ui/views/controls/menu/menu_runner.h View 1 2 3 4 5 6 7 8 9 2 chunks +9 lines, -3 lines 0 comments Download
M ui/views/controls/menu/menu_runner.cc View 1 2 3 4 5 6 7 8 9 1 chunk +7 lines, -2 lines 0 comments Download
M ui/views/controls/menu/menu_runner_cocoa_unittest.mm View 1 11 chunks +155 lines, -30 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl.cc View 1 2 3 4 1 chunk +3 lines, -2 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl_adapter.h View 1 2 3 4 5 2 chunks +5 lines, -2 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl_adapter.cc View 1 2 3 4 7 1 chunk +6 lines, -4 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl_cocoa.h View 1 3 chunks +7 lines, -3 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl_cocoa.mm View 2 chunks +14 lines, -5 lines 0 comments Download
M ui/views/controls/menu/menu_runner_impl_interface.h View 2 chunks +5 lines, -2 lines 0 comments Download

Messages

Total messages: 79 (70 generated)
tapted
Hi sky, please take a look https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu/menu_runner.h File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu/menu_runner.h#newcode115 ui/views/controls/menu/menu_runner.h:115: MenuRunner(ui::MenuModel* menu_model, int32_t ...
4 years, 2 months ago (2016-10-12 10:05:21 UTC) #36
jonross
https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu/menu_runner.h File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu/menu_runner.h#newcode115 ui/views/controls/menu/menu_runner.h:115: MenuRunner(ui::MenuModel* menu_model, int32_t run_types); On 2016/10/12 10:05:21, tapted wrote: ...
4 years, 2 months ago (2016-10-12 14:35:18 UTC) #38
sky
We already have MenuWillClose in MenuModel. Did you consider adding MenuClosed in MenuModel?
4 years, 2 months ago (2016-10-12 16:22:32 UTC) #39
tapted
On 2016/10/12 16:22:32, sky wrote: > We already have MenuWillClose in MenuModel. Did you consider ...
4 years, 2 months ago (2016-10-13 11:43:38 UTC) #67
sky
LGTM with default arg https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu/menu_runner.h File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu/menu_runner.h#newcode114 ui/views/controls/menu/menu_runner.h:114: const base::Closure& on_menu_closed_callback); Combine this ...
4 years, 2 months ago (2016-10-13 17:44:07 UTC) #68
tapted
https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu/menu_runner.h File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu/menu_runner.h#newcode114 ui/views/controls/menu/menu_runner.h:114: const base::Closure& on_menu_closed_callback); On 2016/10/13 17:44:07, sky wrote: > ...
4 years, 2 months ago (2016-10-13 21:31:40 UTC) #71
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2394123002/370001
4 years, 2 months ago (2016-10-13 21:32:31 UTC) #75
commit-bot: I haz the power
Committed patchset #10 (id:370001)
4 years, 2 months ago (2016-10-13 22:19:05 UTC) #77
commit-bot: I haz the power
4 years, 2 months ago (2016-10-13 22:21:48 UTC) #79
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/7a7c6831b11536332403881c6619986b55f62e05
Cr-Commit-Position: refs/heads/master@{#425186}

Powered by Google App Engine
This is Rietveld 408576698