| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/logging.h" // for NOTREACHED() | 7 #include "base/logging.h" // for NOTREACHED() |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/tab_contents/link_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/link_infobar_delegate.h" |
| 12 #import "chrome/browser/ui/cocoa/animatable_view.h" | 12 #import "chrome/browser/ui/cocoa/animatable_view.h" |
| 13 #include "chrome/browser/ui/cocoa/event_utils.h" | 13 #include "chrome/browser/ui/cocoa/event_utils.h" |
| 14 #include "chrome/browser/ui/cocoa/infobars/infobar.h" | 14 #include "chrome/browser/ui/cocoa/infobars/infobar.h" |
| 15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" | 16 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
| 17 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 18 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 18 #include "ui/gfx/image.h" | 19 #include "ui/gfx/image.h" |
| 19 #include "webkit/glue/window_open_disposition.h" | 20 #include "webkit/glue/window_open_disposition.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 // Durations set to match the default SlideAnimation duration. | 23 // Durations set to match the default SlideAnimation duration. |
| 23 const float kAnimateOpenDuration = 0.12; | 24 const float kAnimateOpenDuration = 0.12; |
| 24 const float kAnimateCloseDuration = 0.12; | 25 const float kAnimateCloseDuration = 0.12; |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 NSRect imageFrame = [image_ frame]; | 121 NSRect imageFrame = [image_ frame]; |
| 121 NSRect labelFrame = [labelPlaceholder_ frame]; | 122 NSRect labelFrame = [labelPlaceholder_ frame]; |
| 122 labelFrame.size.width += NSMinX(imageFrame) - NSMinX(labelFrame); | 123 labelFrame.size.width += NSMinX(imageFrame) - NSMinX(labelFrame); |
| 123 labelFrame.origin.x = imageFrame.origin.x; | 124 labelFrame.origin.x = imageFrame.origin.x; |
| 124 [image_ removeFromSuperview]; | 125 [image_ removeFromSuperview]; |
| 125 [labelPlaceholder_ setFrame:labelFrame]; | 126 [labelPlaceholder_ setFrame:labelFrame]; |
| 126 } | 127 } |
| 127 [self initializeLabel]; | 128 [self initializeLabel]; |
| 128 | 129 |
| 129 [self addAdditionalControls]; | 130 [self addAdditionalControls]; |
| 131 |
| 132 [infoBarView_ setInfobarType:delegate_->GetInfoBarType()]; |
| 130 } | 133 } |
| 131 | 134 |
| 132 // Called when someone clicks on the embedded link. | 135 // Called when someone clicks on the embedded link. |
| 133 - (BOOL) textView:(NSTextView*)textView | 136 - (BOOL) textView:(NSTextView*)textView |
| 134 clickedOnLink:(id)link | 137 clickedOnLink:(id)link |
| 135 atIndex:(NSUInteger)charIndex { | 138 atIndex:(NSUInteger)charIndex { |
| 136 if ([self respondsToSelector:@selector(linkClicked)]) | 139 if ([self respondsToSelector:@selector(linkClicked)]) |
| 137 [self performSelector:@selector(linkClicked)]; | 140 [self performSelector:@selector(linkClicked)]; |
| 138 return YES; | 141 return YES; |
| 139 } | 142 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 LinkInfoBarController* controller = | 513 LinkInfoBarController* controller = |
| 511 [[LinkInfoBarController alloc] initWithDelegate:this]; | 514 [[LinkInfoBarController alloc] initWithDelegate:this]; |
| 512 return new InfoBar(controller, this); | 515 return new InfoBar(controller, this); |
| 513 } | 516 } |
| 514 | 517 |
| 515 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { | 518 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { |
| 516 ConfirmInfoBarController* controller = | 519 ConfirmInfoBarController* controller = |
| 517 [[ConfirmInfoBarController alloc] initWithDelegate:this]; | 520 [[ConfirmInfoBarController alloc] initWithDelegate:this]; |
| 518 return new InfoBar(controller, this); | 521 return new InfoBar(controller, this); |
| 519 } | 522 } |
| OLD | NEW |