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/mac/scoped_nsobject.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/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/info_bubble_view.h" | 16 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
17 #import "chrome/browser/ui/cocoa/l10n_util.h" | 17 #import "chrome/browser/ui/cocoa/l10n_util.h" |
18 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 18 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 DCHECK(error_); | 83 DCHECK(error_); |
84 | 84 |
85 gfx::Image image = error_->GetBubbleViewIcon(); | 85 gfx::Image image = error_->GetBubbleViewIcon(); |
86 DCHECK(!image.IsEmpty()); | 86 DCHECK(!image.IsEmpty()); |
87 [iconView_ setImage:image.ToNSImage()]; | 87 [iconView_ setImage:image.ToNSImage()]; |
88 | 88 |
89 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; | 89 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; |
90 std::vector<string16> messages = error_->GetBubbleViewMessages(); | 90 std::vector<string16> messages = error_->GetBubbleViewMessages(); |
91 string16 message = JoinString(messages, '\n'); | 91 string16 message = JoinString(messages, '\n'); |
92 | 92 |
93 scoped_nsobject<NSMutableAttributedString> messageValue( | 93 base::scoped_nsobject<NSMutableAttributedString> messageValue( |
94 [[NSMutableAttributedString alloc] | 94 [[NSMutableAttributedString alloc] |
95 initWithString:SysUTF16ToNSString(message)]); | 95 initWithString:SysUTF16ToNSString(message)]); |
96 scoped_nsobject<NSMutableParagraphStyle> style( | 96 base::scoped_nsobject<NSMutableParagraphStyle> style( |
97 [[NSMutableParagraphStyle alloc] init]); | 97 [[NSMutableParagraphStyle alloc] init]); |
98 [style setParagraphSpacing:kParagraphSpacing]; | 98 [style setParagraphSpacing:kParagraphSpacing]; |
99 [messageValue addAttribute:NSParagraphStyleAttributeName | 99 [messageValue addAttribute:NSParagraphStyleAttributeName |
100 value:style | 100 value:style |
101 range:NSMakeRange(0, [messageValue length])]; | 101 range:NSMakeRange(0, [messageValue length])]; |
102 | 102 |
103 [message_ setAttributedStringValue:messageValue]; | 103 [message_ setAttributedStringValue:messageValue]; |
104 | 104 |
105 [acceptButton_ setTitle: | 105 [acceptButton_ setTitle: |
106 SysUTF16ToNSString(error_->GetBubbleViewAcceptButtonLabel())]; | 106 SysUTF16ToNSString(error_->GetBubbleViewAcceptButtonLabel())]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 [self close]; | 159 [self close]; |
160 } | 160 } |
161 | 161 |
162 @end | 162 @end |
163 | 163 |
164 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( | 164 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( |
165 Browser* browser, | 165 Browser* browser, |
166 const base::WeakPtr<GlobalError>& error) { | 166 const base::WeakPtr<GlobalError>& error) { |
167 return [GlobalErrorBubbleController showForBrowser:browser error:error]; | 167 return [GlobalErrorBubbleController showForBrowser:browser error:error]; |
168 } | 168 } |
OLD | NEW |