OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/views/frame/embedded_non_client_view.h" |
| 6 |
| 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/views/frame/browser_view.h" |
| 9 #include "chrome/common/gfx/path.h" |
| 10 #include "chrome/common/l10n_util.h" |
| 11 #include "chrome/views/root_view.h" |
| 12 #include "chromium_strings.h" |
| 13 |
| 14 /////////////////////////////////////////////////////////////////////////////// |
| 15 // EmbeddedNonClientView, public: |
| 16 |
| 17 EmbeddedNonClientView::EmbeddedNonClientView(EmbeddedFrame* frame, |
| 18 BrowserView* browser_view) |
| 19 : NonClientView(), |
| 20 frame_(frame), |
| 21 browser_view_(browser_view) { |
| 22 } |
| 23 |
| 24 EmbeddedNonClientView::~EmbeddedNonClientView() { |
| 25 // Avoid assert in Browser destructor for tabstrip_model_ not being empty. |
| 26 browser_view_->browser()->CloseAllTabs(); |
| 27 } |
| 28 |
| 29 /////////////////////////////////////////////////////////////////////////////// |
| 30 // EmbeddedNonClientView, TabIconView::TabContentsProvider implementation: |
| 31 |
| 32 TabContents* EmbeddedNonClientView::GetCurrentTabContents() { |
| 33 return browser_view_->GetSelectedTabContents(); |
| 34 } |
| 35 |
| 36 SkBitmap EmbeddedNonClientView::GetFavIcon() { |
| 37 return frame_->window_delegate()->GetWindowIcon(); |
| 38 } |
| 39 |
| 40 /////////////////////////////////////////////////////////////////////////////// |
| 41 // EmbeddedNonClientView, views::BaseButton::ButtonListener implementation: |
| 42 |
| 43 void EmbeddedNonClientView::ButtonPressed(views::BaseButton* sender) { |
| 44 } |
| 45 |
| 46 /////////////////////////////////////////////////////////////////////////////// |
| 47 // EmbeddedNonClientView, views::NonClientView implementation: |
| 48 |
| 49 gfx::Rect EmbeddedNonClientView::CalculateClientAreaBounds(int width, |
| 50 int height) const { |
| 51 return gfx::Rect(0, 0, width, height); |
| 52 } |
| 53 |
| 54 gfx::Size EmbeddedNonClientView::CalculateWindowSizeForClientSize( |
| 55 int width, |
| 56 int height) const { |
| 57 return gfx::Size(width, height); |
| 58 } |
| 59 |
| 60 CPoint EmbeddedNonClientView::GetSystemMenuPoint() const { |
| 61 return CPoint(0,0); |
| 62 } |
| 63 |
| 64 int EmbeddedNonClientView::NonClientHitTest(const gfx::Point& point) { |
| 65 return HTNOWHERE; |
| 66 } |
| 67 |
| 68 void EmbeddedNonClientView::GetWindowMask(const gfx::Size& size, |
| 69 gfx::Path* window_mask) { |
| 70 DCHECK(window_mask); |
| 71 |
| 72 // Redefine the window visible region for the new size. |
| 73 window_mask->moveTo(0, 3); |
| 74 window_mask->lineTo(1, 1); |
| 75 window_mask->lineTo(3, 0); |
| 76 |
| 77 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); |
| 78 window_mask->lineTo(SkIntToScalar(size.width() - 1), 1); |
| 79 window_mask->lineTo(SkIntToScalar(size.width() - 1), 3); |
| 80 window_mask->lineTo(SkIntToScalar(size.width() - 0), 3); |
| 81 |
| 82 window_mask->lineTo(SkIntToScalar(size.width()), |
| 83 SkIntToScalar(size.height())); |
| 84 window_mask->lineTo(0, SkIntToScalar(size.height())); |
| 85 window_mask->close(); |
| 86 } |
| 87 |
| 88 void EmbeddedNonClientView::EnableClose(bool enable) { |
| 89 } |
| 90 |
| 91 void EmbeddedNonClientView::ResetWindowControls() { |
| 92 } |
| 93 |
| 94 /////////////////////////////////////////////////////////////////////////////// |
| 95 // EmbeddedNonClientView, views::View overrides: |
| 96 |
| 97 void EmbeddedNonClientView::Paint(ChromeCanvas* canvas) { |
| 98 } |
| 99 |
| 100 void EmbeddedNonClientView::Layout() { |
| 101 gfx::Rect client_bounds = CalculateClientAreaBounds(width(), height()); |
| 102 frame_->client_view()->SetBounds(client_bounds);; |
| 103 } |
| 104 |
| 105 gfx::Size EmbeddedNonClientView::GetPreferredSize() { |
| 106 return frame_->client_view()->GetPreferredSize();; |
| 107 } |
| 108 |
| 109 void EmbeddedNonClientView::ViewHierarchyChanged(bool is_add, |
| 110 views::View* parent, |
| 111 views::View* embedded) { |
| 112 if (is_add && embedded == this) { |
| 113 DCHECK(GetContainer()); |
| 114 DCHECK(frame_->client_view()->GetParent() != this); |
| 115 AddChildView(frame_->client_view()); |
| 116 |
| 117 // The Accessibility glue looks for the product name on these two views to |
| 118 // determine if this is in fact a Chrome window. |
| 119 GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 120 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 121 } |
| 122 } |
| 123 |
| 124 bool EmbeddedNonClientView::GetAccessibleRole(VARIANT* role) { |
| 125 DCHECK(role); |
| 126 // We aren't actually the client area of the window, but we act like it as |
| 127 // far as MSAA and the UI tests are concerned. |
| 128 role->vt = VT_I4; |
| 129 role->lVal = ROLE_SYSTEM_CLIENT; |
| 130 return true; |
| 131 } |
| 132 |
| 133 bool EmbeddedNonClientView::GetAccessibleName(std::wstring* name) { |
| 134 if (!accessible_name_.empty()) { |
| 135 *name = accessible_name_; |
| 136 return true; |
| 137 } |
| 138 return false; |
| 139 } |
| 140 |
| 141 void EmbeddedNonClientView::SetAccessibleName(const std::wstring& name) { |
| 142 accessible_name_ = name; |
| 143 } |
OLD | NEW |