| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/confirm_bubble.h" |
| 6 |
| 7 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
| 8 #include "chrome/browser/ui/confirm_bubble_model.h" |
| 9 #include "chrome/browser/ui/views/confirm_bubble_views.h" |
| 10 #include "components/constrained_window/constrained_window_views.h" |
| 11 #include "ui/base/material_design/material_design_controller.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 void ShowConfirmBubbleViews(gfx::NativeWindow window, |
| 16 std::unique_ptr<ConfirmBubbleModel> model) { |
| 17 constrained_window::CreateBrowserModalDialogViews( |
| 18 new ConfirmBubbleViews(std::move(model)), window) |
| 19 ->Show(); |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
| 24 namespace chrome { |
| 25 |
| 26 void ShowConfirmBubble(gfx::NativeWindow window, |
| 27 gfx::NativeView anchor_view, |
| 28 const gfx::Point& origin, |
| 29 std::unique_ptr<ConfirmBubbleModel> model) { |
| 30 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 31 ShowConfirmBubbleViews(window, std::move(model)); |
| 32 return; |
| 33 } |
| 34 |
| 35 // Create a custom NSViewController that manages a bubble view, and add it to |
| 36 // a child to the specified |anchor_view|. This controller will be |
| 37 // automatically deleted when it loses first-responder status. |
| 38 ConfirmBubbleController* controller = |
| 39 [[ConfirmBubbleController alloc] initWithParent:anchor_view |
| 40 origin:origin.ToCGPoint() |
| 41 model:std::move(model)]; |
| 42 [anchor_view addSubview:[controller view] |
| 43 positioned:NSWindowAbove |
| 44 relativeTo:nil]; |
| 45 [[anchor_view window] makeFirstResponder:[controller view]]; |
| 46 } |
| 47 |
| 48 } // namespace chrome |
| OLD | NEW |