| Index: chrome/browser/views/frame/embedded_non_client_view.cc
|
| ===================================================================
|
| --- chrome/browser/views/frame/embedded_non_client_view.cc (revision 0)
|
| +++ chrome/browser/views/frame/embedded_non_client_view.cc (revision 0)
|
| @@ -0,0 +1,143 @@
|
| +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/views/frame/embedded_non_client_view.h"
|
| +
|
| +#include "chrome/browser/browser.h"
|
| +#include "chrome/browser/views/frame/browser_view.h"
|
| +#include "chrome/common/gfx/path.h"
|
| +#include "chrome/common/l10n_util.h"
|
| +#include "chrome/views/root_view.h"
|
| +#include "chromium_strings.h"
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// EmbeddedNonClientView, public:
|
| +
|
| +EmbeddedNonClientView::EmbeddedNonClientView(EmbeddedFrame* frame,
|
| + BrowserView* browser_view)
|
| + : NonClientView(),
|
| + frame_(frame),
|
| + browser_view_(browser_view) {
|
| +}
|
| +
|
| +EmbeddedNonClientView::~EmbeddedNonClientView() {
|
| + // Avoid assert in Browser destructor for tabstrip_model_ not being empty.
|
| + browser_view_->browser()->CloseAllTabs();
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// EmbeddedNonClientView, TabIconView::TabContentsProvider implementation:
|
| +
|
| +TabContents* EmbeddedNonClientView::GetCurrentTabContents() {
|
| + return browser_view_->GetSelectedTabContents();
|
| +}
|
| +
|
| +SkBitmap EmbeddedNonClientView::GetFavIcon() {
|
| + return frame_->window_delegate()->GetWindowIcon();
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// EmbeddedNonClientView, views::BaseButton::ButtonListener implementation:
|
| +
|
| +void EmbeddedNonClientView::ButtonPressed(views::BaseButton* sender) {
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// EmbeddedNonClientView, views::NonClientView implementation:
|
| +
|
| +gfx::Rect EmbeddedNonClientView::CalculateClientAreaBounds(int width,
|
| + int height) const {
|
| + return gfx::Rect(0, 0, width, height);
|
| +}
|
| +
|
| +gfx::Size EmbeddedNonClientView::CalculateWindowSizeForClientSize(
|
| + int width,
|
| + int height) const {
|
| + return gfx::Size(width, height);
|
| +}
|
| +
|
| +CPoint EmbeddedNonClientView::GetSystemMenuPoint() const {
|
| + return CPoint(0,0);
|
| +}
|
| +
|
| +int EmbeddedNonClientView::NonClientHitTest(const gfx::Point& point) {
|
| + return HTNOWHERE;
|
| +}
|
| +
|
| +void EmbeddedNonClientView::GetWindowMask(const gfx::Size& size,
|
| + gfx::Path* window_mask) {
|
| + DCHECK(window_mask);
|
| +
|
| + // Redefine the window visible region for the new size.
|
| + window_mask->moveTo(0, 3);
|
| + window_mask->lineTo(1, 1);
|
| + window_mask->lineTo(3, 0);
|
| +
|
| + window_mask->lineTo(SkIntToScalar(size.width() - 3), 0);
|
| + window_mask->lineTo(SkIntToScalar(size.width() - 1), 1);
|
| + window_mask->lineTo(SkIntToScalar(size.width() - 1), 3);
|
| + window_mask->lineTo(SkIntToScalar(size.width() - 0), 3);
|
| +
|
| + window_mask->lineTo(SkIntToScalar(size.width()),
|
| + SkIntToScalar(size.height()));
|
| + window_mask->lineTo(0, SkIntToScalar(size.height()));
|
| + window_mask->close();
|
| +}
|
| +
|
| +void EmbeddedNonClientView::EnableClose(bool enable) {
|
| +}
|
| +
|
| +void EmbeddedNonClientView::ResetWindowControls() {
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// EmbeddedNonClientView, views::View overrides:
|
| +
|
| +void EmbeddedNonClientView::Paint(ChromeCanvas* canvas) {
|
| +}
|
| +
|
| +void EmbeddedNonClientView::Layout() {
|
| + gfx::Rect client_bounds = CalculateClientAreaBounds(width(), height());
|
| + frame_->client_view()->SetBounds(client_bounds);;
|
| +}
|
| +
|
| +gfx::Size EmbeddedNonClientView::GetPreferredSize() {
|
| + return frame_->client_view()->GetPreferredSize();;
|
| +}
|
| +
|
| +void EmbeddedNonClientView::ViewHierarchyChanged(bool is_add,
|
| + views::View* parent,
|
| + views::View* embedded) {
|
| + if (is_add && embedded == this) {
|
| + DCHECK(GetContainer());
|
| + DCHECK(frame_->client_view()->GetParent() != this);
|
| + AddChildView(frame_->client_view());
|
| +
|
| + // The Accessibility glue looks for the product name on these two views to
|
| + // determine if this is in fact a Chrome window.
|
| + GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
|
| + SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
|
| + }
|
| +}
|
| +
|
| +bool EmbeddedNonClientView::GetAccessibleRole(VARIANT* role) {
|
| + DCHECK(role);
|
| + // We aren't actually the client area of the window, but we act like it as
|
| + // far as MSAA and the UI tests are concerned.
|
| + role->vt = VT_I4;
|
| + role->lVal = ROLE_SYSTEM_CLIENT;
|
| + return true;
|
| +}
|
| +
|
| +bool EmbeddedNonClientView::GetAccessibleName(std::wstring* name) {
|
| + if (!accessible_name_.empty()) {
|
| + *name = accessible_name_;
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +void EmbeddedNonClientView::SetAccessibleName(const std::wstring& name) {
|
| + accessible_name_ = name;
|
| +}
|
|
|