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

Unified Diff: chrome/browser/ui/cocoa/confirm_bubble_views_mac.mm

Issue 2650583012: MacViews: Enable views based Ask Google For Suggestions dialog behind secondary-ui-md flag. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/confirm_bubble_cocoa.mm ('k') | chrome/browser/ui/views/confirm_bubble_views.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/cocoa/confirm_bubble_cocoa.mm ('k') | chrome/browser/ui/views/confirm_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698