| 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/global_error_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/global_error_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/search_engines/util.h" | 12 #include "chrome/browser/search_engines/util.h" |
| 13 #import "chrome/browser/ui/browser.h" | 13 #import "chrome/browser/ui/browser.h" |
| 14 #import "chrome/browser/ui/browser_window.h" | 14 #import "chrome/browser/ui/browser_window.h" |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/l10n_util.h" | 16 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 17 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 17 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 18 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 18 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 19 #include "chrome/browser/ui/global_error/global_error.h" | 19 #include "chrome/browser/ui/global_error/global_error.h" |
| 20 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" | 20 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" |
| 21 #include "chrome/browser/ui/global_error/global_error_service.h" | 21 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 22 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 22 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 24 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | |
| 27 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 // The vertical offset of the wrench bubble from the wrench menu button. | 30 // The vertical offset of the wrench bubble from the wrench menu button. |
| 32 const CGFloat kWrenchBubblePointOffsetY = 6; | 31 const CGFloat kWrenchBubblePointOffsetY = 6; |
| 33 | 32 |
| 34 const CGFloat kParagraphSpacing = 6; | 33 const CGFloat kParagraphSpacing = 6; |
| 35 | 34 |
| 36 } // namespace | 35 } // namespace |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 [bubble showWindow:nil]; | 75 [bubble showWindow:nil]; |
| 77 | 76 |
| 78 return bubble->bridge_.get(); | 77 return bubble->bridge_.get(); |
| 79 } | 78 } |
| 80 | 79 |
| 81 - (void)awakeFromNib { | 80 - (void)awakeFromNib { |
| 82 [super awakeFromNib]; | 81 [super awakeFromNib]; |
| 83 | 82 |
| 84 DCHECK(error_); | 83 DCHECK(error_); |
| 85 | 84 |
| 86 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 85 gfx::Image image = error_->GetBubbleViewIcon(); |
| 87 [iconView_ setImage:rb.GetNativeImageNamed( | 86 DCHECK(!image.IsEmpty()); |
| 88 error_->GetBubbleViewIconResourceID()).ToNSImage()]; | 87 [iconView_ setImage:image.ToNSImage()]; |
| 89 | 88 |
| 90 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; | 89 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; |
| 91 std::vector<string16> messages = error_->GetBubbleViewMessages(); | 90 std::vector<string16> messages = error_->GetBubbleViewMessages(); |
| 92 string16 message = JoinString(messages, '\n'); | 91 string16 message = JoinString(messages, '\n'); |
| 93 | 92 |
| 94 scoped_nsobject<NSMutableAttributedString> messageValue( | 93 scoped_nsobject<NSMutableAttributedString> messageValue( |
| 95 [[NSMutableAttributedString alloc] | 94 [[NSMutableAttributedString alloc] |
| 96 initWithString:SysUTF16ToNSString(message)]); | 95 initWithString:SysUTF16ToNSString(message)]); |
| 97 scoped_nsobject<NSMutableParagraphStyle> style( | 96 scoped_nsobject<NSMutableParagraphStyle> style( |
| 98 [[NSMutableParagraphStyle alloc] init]); | 97 [[NSMutableParagraphStyle alloc] init]); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 [self close]; | 159 [self close]; |
| 161 } | 160 } |
| 162 | 161 |
| 163 @end | 162 @end |
| 164 | 163 |
| 165 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( | 164 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( |
| 166 Browser* browser, | 165 Browser* browser, |
| 167 const base::WeakPtr<GlobalError>& error) { | 166 const base::WeakPtr<GlobalError>& error) { |
| 168 return [GlobalErrorBubbleController showForBrowser:browser error:error]; | 167 return [GlobalErrorBubbleController showForBrowser:browser error:error]; |
| 169 } | 168 } |
| OLD | NEW |