OLD | NEW |
---|---|
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/location_bar/content_setting_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 NSPoint anchor = GetBubblePointInFrame(frame); | 295 NSPoint anchor = GetBubblePointInFrame(frame); |
296 anchor = [field convertPoint:anchor toView:nil]; | 296 anchor = [field convertPoint:anchor toView:nil]; |
297 anchor = ui::ConvertPointFromWindowToScreen([field window], anchor); | 297 anchor = ui::ConvertPointFromWindowToScreen([field window], anchor); |
298 | 298 |
299 // Open bubble. | 299 // Open bubble. |
300 ContentSettingBubbleModel* model = | 300 ContentSettingBubbleModel* model = |
301 content_setting_image_model_->CreateBubbleModel( | 301 content_setting_image_model_->CreateBubbleModel( |
302 browser->content_setting_bubble_model_delegate(), | 302 browser->content_setting_bubble_model_delegate(), |
303 web_contents, | 303 web_contents, |
304 profile_); | 304 profile_); |
305 model->set_decoration(this); | |
tapted
2017/05/16 07:39:37
this doesn't look right - can we just pass |this|
spqchan
2017/05/17 01:39:40
Good point. I implemented a method in LocationBarV
| |
305 | 306 |
306 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 307 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
307 gfx::Point origin = gfx::ScreenPointFromNSPoint(anchor); | 308 gfx::Point origin = gfx::ScreenPointFromNSPoint(anchor); |
308 chrome::ContentSettingBubbleViewsBridge::Show( | 309 chrome::ContentSettingBubbleViewsBridge::Show( |
309 [web_contents->GetTopLevelNativeWindow() contentView], | 310 [web_contents->GetTopLevelNativeWindow() contentView], |
tapted
2017/05/17 01:57:49
Is there a reason we can't pass |this| to ::Show(.
| |
310 model, web_contents, origin); | 311 model, web_contents, origin); |
311 } else { | 312 } else { |
312 // If the bubble is already opened, close it. Otherwise, open a new bubble. | 313 // If the bubble is already opened, close it. Otherwise, open a new bubble. |
313 if (bubbleWindow_ && [bubbleWindow_ isVisible]) { | 314 if (bubbleWindow_ && [bubbleWindow_ isVisible]) { |
314 [bubbleWindow_ close]; | 315 [bubbleWindow_ close]; |
315 bubbleWindow_.reset(); | 316 bubbleWindow_.reset(); |
316 } else { | 317 } else { |
317 ContentSettingBubbleController* bubbleController = | 318 ContentSettingBubbleController* bubbleController = |
318 [ContentSettingBubbleController showForModel:model | 319 [ContentSettingBubbleController showForModel:model |
319 webContents:web_contents | 320 webContents:web_contents |
320 parentWindow:[field window] | 321 parentWindow:[field window] |
321 decoration:this | 322 decoration:this |
tapted
2017/05/17 01:57:49
i.e. similar to the call here, for Cocoa
spqchan
2017/05/17 23:58:46
On 2017/05/17 01:57:49, tapted wrote:
> i.e. simil
| |
322 anchoredAt:anchor]; | 323 anchoredAt:anchor]; |
323 bubbleWindow_.reset([[bubbleController window] retain]); | 324 bubbleWindow_.reset([[bubbleController window] retain]); |
324 } | 325 } |
325 } | 326 } |
326 | 327 |
327 return true; | 328 return true; |
328 } | 329 } |
329 | 330 |
330 CGFloat ContentSettingDecoration::DividerPadding() const { | 331 CGFloat ContentSettingDecoration::DividerPadding() const { |
331 return kDividerPadding; | 332 return kDividerPadding; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 } | 439 } |
439 | 440 |
440 void ContentSettingDecoration::AnimationTimerFired() { | 441 void ContentSettingDecoration::AnimationTimerFired() { |
441 owner_->Layout(); | 442 owner_->Layout(); |
442 // Even after the animation completes, the |animator_| object should be kept | 443 // Even after the animation completes, the |animator_| object should be kept |
443 // alive to prevent the animation from re-appearing if the page opens | 444 // alive to prevent the animation from re-appearing if the page opens |
444 // additional popups later. The animator will be cleared when the decoration | 445 // additional popups later. The animator will be cleared when the decoration |
445 // hides, indicating something has changed with the WebContents (probably | 446 // hides, indicating something has changed with the WebContents (probably |
446 // navigation). | 447 // navigation). |
447 } | 448 } |
OLD | NEW |