| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 8 #include "chrome/browser/ui/global_error.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_view.h" | 9 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 10 #include "chrome/browser/ui/views/toolbar_view.h" | 10 #include "chrome/browser/ui/views/toolbar_view.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 enum { | 22 enum { |
| 23 TAG_ACCEPT_BUTTON = 1, | 23 TAG_ACCEPT_BUTTON = 1, |
| 24 TAG_CANCEL_BUTTON, | 24 TAG_CANCEL_BUTTON, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 const int kMaxBubbleViewWidth = 262; | 27 const int kMaxBubbleViewWidth = 262; |
| 28 | 28 |
| 29 // The horizontal padding between the title and the icon. | 29 // The horizontal padding between the title and the icon. |
| 30 const int kTitleHorizontalPadding = 3; | 30 const int kTitleHorizontalPadding = 3; |
| 31 | 31 |
| 32 // The vertical offset of the wrench bubble from the wrench menu button. | 32 // The vertical inset of the wrench bubble anchor from the wrench menu button. |
| 33 const int kWrenchBubblePointOffsetY = -6; | 33 const int kAnchorVerticalInset = 5; |
| 34 | 34 |
| 35 const int kLayoutBottomPadding = 2; | 35 const int kLayoutBottomPadding = 2; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 GlobalErrorBubbleView::GlobalErrorBubbleView( | 39 GlobalErrorBubbleView::GlobalErrorBubbleView( |
| 40 views::View* anchor_view, | 40 views::View* anchor_view, |
| 41 views::BubbleBorder::ArrowLocation location, | 41 views::BubbleBorder::ArrowLocation location, |
| 42 Browser* browser, | 42 Browser* browser, |
| 43 GlobalError* error) | 43 GlobalError* error) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 // Adjust the message label size in case buttons are too long. | 119 // Adjust the message label size in case buttons are too long. |
| 120 message_label->SizeToFit(layout->GetPreferredSize(this).width()); | 120 message_label->SizeToFit(layout->GetPreferredSize(this).width()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 GlobalErrorBubbleView::~GlobalErrorBubbleView() { | 123 GlobalErrorBubbleView::~GlobalErrorBubbleView() { |
| 124 } | 124 } |
| 125 | 125 |
| 126 gfx::Rect GlobalErrorBubbleView::GetAnchorRect() { | 126 gfx::Rect GlobalErrorBubbleView::GetAnchorRect() { |
| 127 gfx::Rect rect(views::BubbleDelegateView::GetAnchorRect()); | 127 gfx::Rect rect(views::BubbleDelegateView::GetAnchorRect()); |
| 128 rect.Offset(0, anchor_view() ? kWrenchBubblePointOffsetY : 0); | 128 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0); |
| 129 return rect; | 129 return rect; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void GlobalErrorBubbleView::ButtonPressed(views::Button* sender, | 132 void GlobalErrorBubbleView::ButtonPressed(views::Button* sender, |
| 133 const views::Event& event) { | 133 const views::Event& event) { |
| 134 if (sender->tag() == TAG_ACCEPT_BUTTON) | 134 if (sender->tag() == TAG_ACCEPT_BUTTON) |
| 135 error_->BubbleViewAcceptButtonPressed(); | 135 error_->BubbleViewAcceptButtonPressed(); |
| 136 else if (sender->tag() == TAG_CANCEL_BUTTON) | 136 else if (sender->tag() == TAG_CANCEL_BUTTON) |
| 137 error_->BubbleViewCancelButtonPressed(); | 137 error_->BubbleViewCancelButtonPressed(); |
| 138 else | 138 else |
| 139 NOTREACHED(); | 139 NOTREACHED(); |
| 140 GetWidget()->Close(); | 140 GetWidget()->Close(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void GlobalErrorBubbleView::WindowClosing() { | 143 void GlobalErrorBubbleView::WindowClosing() { |
| 144 error_->BubbleViewDidClose(); | 144 error_->BubbleViewDidClose(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void GlobalError::ShowBubbleView(Browser* browser, GlobalError* error) { | 147 void GlobalError::ShowBubbleView(Browser* browser, GlobalError* error) { |
| 148 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 148 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 149 views::View* wrench_button = browser_view->toolbar()->app_menu(); | 149 views::View* wrench_button = browser_view->toolbar()->app_menu(); |
| 150 GlobalErrorBubbleView* bubble_view = | 150 GlobalErrorBubbleView* bubble_view = |
| 151 new GlobalErrorBubbleView(wrench_button, | 151 new GlobalErrorBubbleView(wrench_button, |
| 152 views::BubbleBorder::TOP_RIGHT, | 152 views::BubbleBorder::TOP_RIGHT, |
| 153 browser, | 153 browser, |
| 154 error); | 154 error); |
| 155 browser::CreateViewsBubble(bubble_view); | 155 browser::CreateViewsBubble(bubble_view); |
| 156 bubble_view->StartFade(true); | 156 bubble_view->StartFade(true); |
| 157 } | 157 } |
| OLD | NEW |