| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 [infoText.get() insertAttributedString:attributedString.get() | 331 [infoText.get() insertAttributedString:attributedString.get() |
| 332 atIndex:linkOffset]; | 332 atIndex:linkOffset]; |
| 333 // Update the label view with the new text. | 333 // Update the label view with the new text. |
| 334 [[label_.get() textStorage] setAttributedString:infoText]; | 334 [[label_.get() textStorage] setAttributedString:infoText]; |
| 335 } | 335 } |
| 336 | 336 |
| 337 @end | 337 @end |
| 338 | 338 |
| 339 | 339 |
| 340 ///////////////////////////////////////////////////////////////////////// | 340 ///////////////////////////////////////////////////////////////////////// |
| 341 // AlertInfoBarController implementation | |
| 342 | |
| 343 @implementation AlertInfoBarController | |
| 344 | |
| 345 // Alert infobars have a text message. | |
| 346 - (void)addAdditionalControls { | |
| 347 // No buttons. | |
| 348 [self removeButtons]; | |
| 349 | |
| 350 // Insert the text. | |
| 351 AlertInfoBarDelegate* delegate = delegate_->AsAlertInfoBarDelegate(); | |
| 352 DCHECK(delegate); | |
| 353 [self setLabelToMessage:base::SysUTF16ToNSString(delegate->GetMessageText())]; | |
| 354 } | |
| 355 | |
| 356 @end | |
| 357 | |
| 358 | |
| 359 ///////////////////////////////////////////////////////////////////////// | |
| 360 // LinkInfoBarController implementation | 341 // LinkInfoBarController implementation |
| 361 | 342 |
| 362 @implementation LinkInfoBarController | 343 @implementation LinkInfoBarController |
| 363 | 344 |
| 364 // Link infobars have a text message, of which part is linkified. We | 345 // Link infobars have a text message, of which part is linkified. We |
| 365 // use an NSAttributedString to display styled text, and we set a | 346 // use an NSAttributedString to display styled text, and we set a |
| 366 // NSLink attribute on the hyperlink portion of the message. Infobars | 347 // NSLink attribute on the hyperlink portion of the message. Infobars |
| 367 // use a custom NSTextField subclass, which allows us to override | 348 // use a custom NSTextField subclass, which allows us to override |
| 368 // textView:clickedOnLink:atIndex: and intercept clicks. | 349 // textView:clickedOnLink:atIndex: and intercept clicks. |
| 369 // | 350 // |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 delegate_->AsConfirmInfoBarDelegate()->LinkClicked(disposition)) | 492 delegate_->AsConfirmInfoBarDelegate()->LinkClicked(disposition)) |
| 512 [self removeInfoBar]; | 493 [self removeInfoBar]; |
| 513 } | 494 } |
| 514 | 495 |
| 515 @end | 496 @end |
| 516 | 497 |
| 517 | 498 |
| 518 ////////////////////////////////////////////////////////////////////////// | 499 ////////////////////////////////////////////////////////////////////////// |
| 519 // CreateInfoBar() implementations | 500 // CreateInfoBar() implementations |
| 520 | 501 |
| 521 InfoBar* AlertInfoBarDelegate::CreateInfoBar() { | |
| 522 AlertInfoBarController* controller = | |
| 523 [[AlertInfoBarController alloc] initWithDelegate:this]; | |
| 524 return new InfoBar(controller); | |
| 525 } | |
| 526 | |
| 527 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 502 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 528 LinkInfoBarController* controller = | 503 LinkInfoBarController* controller = |
| 529 [[LinkInfoBarController alloc] initWithDelegate:this]; | 504 [[LinkInfoBarController alloc] initWithDelegate:this]; |
| 530 return new InfoBar(controller); | 505 return new InfoBar(controller); |
| 531 } | 506 } |
| 532 | 507 |
| 533 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 508 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 534 ConfirmInfoBarController* controller = | 509 ConfirmInfoBarController* controller = |
| 535 [[ConfirmInfoBarController alloc] initWithDelegate:this]; | 510 [[ConfirmInfoBarController alloc] initWithDelegate:this]; |
| 536 return new InfoBar(controller); | 511 return new InfoBar(controller); |
| 537 } | 512 } |
| OLD | NEW |