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/mac/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 #import "chrome/browser/ui/browser.h" | 12 #import "chrome/browser/ui/browser.h" |
13 #import "chrome/browser/ui/browser_window.h" | 13 #import "chrome/browser/ui/browser_window.h" |
14 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" | 14 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.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" |
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 "components/search_engines/util.h" | 23 #include "components/search_engines/util.h" |
24 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" | 24 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" |
| 25 #import "ui/base/cocoa/a11y_util.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
27 | 28 |
28 namespace { | 29 namespace { |
29 const CGFloat kParagraphSpacing = 6; | 30 const CGFloat kParagraphSpacing = 6; |
30 } // namespace | 31 } // namespace |
31 | 32 |
32 namespace GlobalErrorBubbleControllerInternal { | 33 namespace GlobalErrorBubbleControllerInternal { |
33 | 34 |
34 // This is the bridge to the C++ GlobalErrorBubbleViewBase object. | 35 // This is the bridge to the C++ GlobalErrorBubbleViewBase object. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 73 } |
73 | 74 |
74 - (void)awakeFromNib { | 75 - (void)awakeFromNib { |
75 [super awakeFromNib]; | 76 [super awakeFromNib]; |
76 | 77 |
77 DCHECK(error_); | 78 DCHECK(error_); |
78 | 79 |
79 gfx::Image image = error_->GetBubbleViewIcon(); | 80 gfx::Image image = error_->GetBubbleViewIcon(); |
80 DCHECK(!image.IsEmpty()); | 81 DCHECK(!image.IsEmpty()); |
81 [iconView_ setImage:image.ToNSImage()]; | 82 [iconView_ setImage:image.ToNSImage()]; |
| 83 // So far, none of these icons have useful descriptions (they only specify |
| 84 // "image"). Hide them from the accessibility order for voice over. If any |
| 85 // new bubbles use this for an informational icon, we can add a new method |
| 86 // to the GlobalErrorWithStandardBubble class. |
| 87 ui::a11y_util::HideImageFromAccessibilityOrder(iconView_); |
82 | 88 |
83 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; | 89 [title_ setStringValue:SysUTF16ToNSString(error_->GetBubbleViewTitle())]; |
84 std::vector<base::string16> messages = error_->GetBubbleViewMessages(); | 90 std::vector<base::string16> messages = error_->GetBubbleViewMessages(); |
85 base::string16 message = base::JoinString(messages, base::ASCIIToUTF16("\n")); | 91 base::string16 message = base::JoinString(messages, base::ASCIIToUTF16("\n")); |
86 | 92 |
87 base::scoped_nsobject<NSMutableAttributedString> messageValue( | 93 base::scoped_nsobject<NSMutableAttributedString> messageValue( |
88 [[NSMutableAttributedString alloc] | 94 [[NSMutableAttributedString alloc] |
89 initWithString:SysUTF16ToNSString(message)]); | 95 initWithString:SysUTF16ToNSString(message)]); |
90 base::scoped_nsobject<NSMutableParagraphStyle> style( | 96 base::scoped_nsobject<NSMutableParagraphStyle> style( |
91 [[NSMutableParagraphStyle alloc] init]); | 97 [[NSMutableParagraphStyle alloc] init]); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 [self close]; | 159 [self close]; |
154 } | 160 } |
155 | 161 |
156 @end | 162 @end |
157 | 163 |
158 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( | 164 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( |
159 Browser* browser, | 165 Browser* browser, |
160 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { | 166 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { |
161 return [GlobalErrorBubbleController showForBrowser:browser error:error]; | 167 return [GlobalErrorBubbleController showForBrowser:browser error:error]; |
162 } | 168 } |
OLD | NEW |