Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: chrome/browser/ui/views/global_error_bubble_view.cc

Issue 10830366: Avoid overriding Bubble's GetAnchorRect() where possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a redundant DCHECK. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/views/global_error_bubble_view.h" 5 #include "chrome/browser/ui/views/global_error_bubble_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/global_error/global_error.h" 8 #include "chrome/browser/ui/global_error/global_error.h"
9 #include "chrome/browser/ui/global_error/global_error_service.h" 9 #include "chrome/browser/ui/global_error/global_error_service.h"
10 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 10 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // GlobalErrorBubbleView ------------------------------------------------------- 58 // GlobalErrorBubbleView -------------------------------------------------------
59 59
60 GlobalErrorBubbleView::GlobalErrorBubbleView( 60 GlobalErrorBubbleView::GlobalErrorBubbleView(
61 views::View* anchor_view, 61 views::View* anchor_view,
62 views::BubbleBorder::ArrowLocation location, 62 views::BubbleBorder::ArrowLocation location,
63 Browser* browser, 63 Browser* browser,
64 const base::WeakPtr<GlobalError>& error) 64 const base::WeakPtr<GlobalError>& error)
65 : BubbleDelegateView(anchor_view, location), 65 : BubbleDelegateView(anchor_view, location),
66 browser_(browser), 66 browser_(browser),
67 error_(error) { 67 error_(error) {
68 DCHECK(error_); 68 // Compensate for built-in vertical padding in the anchor view's image.
69 set_anchor_insets(
70 gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0));
71
69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 72 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
70 int resource_id = error_->GetBubbleViewIconResourceID(); 73 int resource_id = error_->GetBubbleViewIconResourceID();
71 scoped_ptr<views::ImageView> image_view(new views::ImageView()); 74 scoped_ptr<views::ImageView> image_view(new views::ImageView());
72 image_view->SetImage(rb.GetImageNamed(resource_id).ToImageSkia()); 75 image_view->SetImage(rb.GetImageNamed(resource_id).ToImageSkia());
73 76
74 string16 title_string(error_->GetBubbleViewTitle()); 77 string16 title_string(error_->GetBubbleViewTitle());
75 scoped_ptr<views::Label> title_label(new views::Label(title_string)); 78 scoped_ptr<views::Label> title_label(new views::Label(title_string));
76 title_label->SetMultiLine(true); 79 title_label->SetMultiLine(true);
77 title_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 80 title_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
78 title_label->SetFont(title_label->font().DeriveFont(1)); 81 title_label->SetFont(title_label->font().DeriveFont(1));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (cancel_button.get()) 141 if (cancel_button.get())
139 layout->AddView(cancel_button.release()); 142 layout->AddView(cancel_button.release());
140 143
141 // Adjust the message label size in case buttons are too long. 144 // Adjust the message label size in case buttons are too long.
142 message_label->SizeToFit(layout->GetPreferredSize(this).width()); 145 message_label->SizeToFit(layout->GetPreferredSize(this).width());
143 } 146 }
144 147
145 GlobalErrorBubbleView::~GlobalErrorBubbleView() { 148 GlobalErrorBubbleView::~GlobalErrorBubbleView() {
146 } 149 }
147 150
148 gfx::Rect GlobalErrorBubbleView::GetAnchorRect() {
149 gfx::Rect rect(views::BubbleDelegateView::GetAnchorRect());
150 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
151 return rect;
152 }
153
154 void GlobalErrorBubbleView::ButtonPressed(views::Button* sender, 151 void GlobalErrorBubbleView::ButtonPressed(views::Button* sender,
155 const ui::Event& event) { 152 const ui::Event& event) {
156 if (error_) { 153 if (error_) {
157 if (sender->tag() == TAG_ACCEPT_BUTTON) 154 if (sender->tag() == TAG_ACCEPT_BUTTON)
158 error_->BubbleViewAcceptButtonPressed(browser_); 155 error_->BubbleViewAcceptButtonPressed(browser_);
159 else if (sender->tag() == TAG_CANCEL_BUTTON) 156 else if (sender->tag() == TAG_CANCEL_BUTTON)
160 error_->BubbleViewCancelButtonPressed(browser_); 157 error_->BubbleViewCancelButtonPressed(browser_);
161 else 158 else
162 NOTREACHED(); 159 NOTREACHED();
163 } 160 }
164 GetWidget()->Close(); 161 GetWidget()->Close();
165 } 162 }
166 163
167 void GlobalErrorBubbleView::WindowClosing() { 164 void GlobalErrorBubbleView::WindowClosing() {
168 if (error_) 165 if (error_)
169 error_->BubbleViewDidClose(browser_); 166 error_->BubbleViewDidClose(browser_);
170 } 167 }
171 168
172 void GlobalErrorBubbleView::CloseBubbleView() { 169 void GlobalErrorBubbleView::CloseBubbleView() {
173 GetWidget()->Close(); 170 GetWidget()->Close();
174 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/global_error_bubble_view.h ('k') | chrome/browser/ui/views/location_bar/zoom_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698