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

Side by Side Diff: chrome/browser/ui/cocoa/confirm_bubble_cocoa.mm

Issue 2650583012: MacViews: Enable views based Ask Google For Suggestions dialog behind secondary-ui-md flag. (Closed)
Patch Set: Rebase. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" 5 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
(...skipping 23 matching lines...) Expand all
34 const int kRelatedControlVerticalSpacing = 8; 34 const int kRelatedControlVerticalSpacing = 8;
35 35
36 // Vertical spacing between the edge of the window and the 36 // Vertical spacing between the edge of the window and the
37 // top or bottom of a button. 37 // top or bottom of a button.
38 const int kButtonVEdgeMargin = 6; 38 const int kButtonVEdgeMargin = 6;
39 39
40 // Horizontal spacing between the edge of the window and the 40 // Horizontal spacing between the edge of the window and the
41 // left or right of a button. 41 // left or right of a button.
42 const int kButtonHEdgeMargin = 7; 42 const int kButtonHEdgeMargin = 7;
43 43
44 namespace chrome {
45
46 void ShowConfirmBubble(gfx::NativeWindow window,
47 gfx::NativeView anchor_view,
48 const gfx::Point& origin,
49 std::unique_ptr<ConfirmBubbleModel> model) {
50 // Create a custom NSViewController that manages a bubble view, and add it to
51 // a child to the specified |anchor_view|. This controller will be
52 // automatically deleted when it loses first-responder status.
53 ConfirmBubbleController* controller =
54 [[ConfirmBubbleController alloc] initWithParent:anchor_view
55 origin:origin.ToCGPoint()
56 model:std::move(model)];
57 [anchor_view addSubview:[controller view]
58 positioned:NSWindowAbove
59 relativeTo:nil];
60 [[anchor_view window] makeFirstResponder:[controller view]];
61 }
62
63 } // namespace chrome
64
65 // An interface that is derived from NSTextView and does not accept 44 // An interface that is derived from NSTextView and does not accept
66 // first-responder status, i.e. a NSTextView-derived class that never becomes 45 // first-responder status, i.e. a NSTextView-derived class that never becomes
67 // the first responder. When we click a NSTextView object, it becomes the first 46 // the first responder. When we click a NSTextView object, it becomes the first
68 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime 47 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime
69 // when it loses first-responder status not to prevent disturbing other 48 // when it loses first-responder status not to prevent disturbing other
70 // responders. 49 // responders.
71 // To prevent text views in this ConfirmBubbleCocoa object from stealing the 50 // To prevent text views in this ConfirmBubbleCocoa object from stealing the
72 // first-responder status, we use this view in the ConfirmBubbleCocoa object. 51 // first-responder status, we use this view in the ConfirmBubbleCocoa object.
73 @interface ConfirmBubbleTextView : NSTextView 52 @interface ConfirmBubbleTextView : NSTextView
74 @end 53 @end
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 256
278 - (void)clickCancel { 257 - (void)clickCancel {
279 [self cancel:self]; 258 [self cancel:self];
280 } 259 }
281 260
282 - (void)clickLink { 261 - (void)clickLink {
283 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; 262 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0];
284 } 263 }
285 264
286 @end 265 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698