| Index: chrome/browser/ui/cocoa/confirm_bubble_views_mac.mm
|
| diff --git a/chrome/browser/ui/cocoa/confirm_bubble_views_mac.mm b/chrome/browser/ui/cocoa/confirm_bubble_views_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5b8eba98c83837577f260534f2d0a365e2e7509e
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/cocoa/confirm_bubble_views_mac.mm
|
| @@ -0,0 +1,48 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/confirm_bubble.h"
|
| +
|
| +#import "chrome/browser/ui/cocoa/confirm_bubble_controller.h"
|
| +#include "chrome/browser/ui/confirm_bubble_model.h"
|
| +#include "chrome/browser/ui/views/confirm_bubble_views.h"
|
| +#include "components/constrained_window/constrained_window_views.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| +
|
| +namespace {
|
| +
|
| +void ShowConfirmBubbleViews(gfx::NativeWindow window,
|
| + std::unique_ptr<ConfirmBubbleModel> model) {
|
| + constrained_window::CreateBrowserModalDialogViews(
|
| + new ConfirmBubbleViews(std::move(model)), window)
|
| + ->Show();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +namespace chrome {
|
| +
|
| +void ShowConfirmBubble(gfx::NativeWindow window,
|
| + gfx::NativeView anchor_view,
|
| + const gfx::Point& origin,
|
| + std::unique_ptr<ConfirmBubbleModel> model) {
|
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + ShowConfirmBubbleViews(window, std::move(model));
|
| + return;
|
| + }
|
| +
|
| + // Create a custom NSViewController that manages a bubble view, and add it to
|
| + // a child to the specified |anchor_view|. This controller will be
|
| + // automatically deleted when it loses first-responder status.
|
| + ConfirmBubbleController* controller =
|
| + [[ConfirmBubbleController alloc] initWithParent:anchor_view
|
| + origin:origin.ToCGPoint()
|
| + model:std::move(model)];
|
| + [anchor_view addSubview:[controller view]
|
| + positioned:NSWindowAbove
|
| + relativeTo:nil];
|
| + [[anchor_view window] makeFirstResponder:[controller view]];
|
| +}
|
| +
|
| +} // namespace chrome
|
|
|