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

Unified Diff: chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc

Issue 25536010: Make packaged apps use AppNonClientFrameViewAsh when maximized (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
diff --git a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
index 89f4dabf4f07605c3e9dafbcc65b3f8b06a90f19..89e52330b96847a78be8668b7c93b85b41cfd082 100644
--- a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
@@ -4,165 +4,22 @@
#include "chrome/browser/ui/views/frame/app_non_client_frame_view_ash.h"
-#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
-#include "base/i18n/rtl.h"
-#include "chrome/browser/ui/views/frame/browser_frame.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "ash/wm/caption_buttons/hideable_caption_button_container.h"
#include "grit/ash_resources.h"
-#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
-#include "ui/views/background.h"
-#include "ui/views/border.h"
#include "ui/views/widget/widget.h"
-#include "ui/views/window/non_client_view.h"
-
-namespace {
-
-// The size of the shadow around the caption buttons.
-const int kShadowSizeX = 16;
-const int kShadowSizeBottom = 21;
-
-// The border for |control_view_|.
-class ControlViewBorder : public views::Border {
- public:
- ControlViewBorder() {
- int border_id = base::i18n::IsRTL() ?
- IDR_AURA_WINDOW_FULLSCREEN_SHADOW_RTL :
- IDR_AURA_WINDOW_FULLSCREEN_SHADOW;
- border_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- border_id).AsImageSkia();
- }
-
- virtual ~ControlViewBorder() {
- }
-
- private:
- // views::Border overrides:
- virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE {
- canvas->DrawImageInt(border_, 0, view.height() - border_.height());
- }
-
- virtual gfx::Insets GetInsets() const OVERRIDE {
- return gfx::Insets(0, kShadowSizeX, kShadowSizeBottom, 0);
- }
-
- gfx::ImageSkia border_;
-
- DISALLOW_COPY_AND_ASSIGN(ControlViewBorder);
-};
-
-// The background for |control_view_|.
-class ControlViewBackground : public views::Background {
- public:
- explicit ControlViewBackground(bool is_incognito) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- int control_base_resource_id = is_incognito ?
- IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE :
- IDR_AURA_WINDOW_HEADER_BASE_ACTIVE;
- background_ = rb.GetImageNamed(control_base_resource_id).AsImageSkia();
- }
-
- virtual ~ControlViewBackground() {
- }
-
- private:
- // views::Background override:
- virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
- gfx::Rect paint_bounds(view->GetContentsBounds());
- paint_bounds.set_x(view->GetMirroredXForRect(paint_bounds));
- canvas->TileImageInt(background_, paint_bounds.x(), paint_bounds.y(),
- paint_bounds.width(), paint_bounds.height());
- }
-
- gfx::ImageSkia background_;
-
- DISALLOW_COPY_AND_ASSIGN(ControlViewBackground);
-};
-
-} // namespace
-
-// Observer to detect when the browser frame widget closes so we can clean
-// up our ControlView. Because we can be closed via a keyboard shortcut we
-// are not guaranteed to run AppNonClientFrameView's Close() or Restore().
-class AppNonClientFrameViewAsh::FrameObserver : public views::WidgetObserver {
- public:
- explicit FrameObserver(AppNonClientFrameViewAsh* owner) : owner_(owner) {}
- virtual ~FrameObserver() {}
-
- // views::WidgetObserver:
- virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE {
- owner_->CloseControlWidget();
- }
-
- private:
- AppNonClientFrameViewAsh* owner_;
-
- DISALLOW_COPY_AND_ASSIGN(FrameObserver);
-};
// static
const char AppNonClientFrameViewAsh::kViewClassName[] =
"AppNonClientFrameViewAsh";
-// static
-const char AppNonClientFrameViewAsh::kControlWindowName[] =
- "AppNonClientFrameViewAshControls";
-
-AppNonClientFrameViewAsh::AppNonClientFrameViewAsh(
- BrowserFrame* frame, BrowserView* browser_view)
- : BrowserNonClientFrameView(frame, browser_view),
- control_view_(NULL),
- control_widget_(NULL),
- frame_observer_(new FrameObserver(this)) {
- control_view_ = new ash::FrameCaptionButtonContainerView(frame,
- ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
- control_view_->set_header_style(
- ash::FrameCaptionButtonContainerView::HEADER_STYLE_MAXIMIZED_HOSTED_APP);
- control_view_->set_border(new ControlViewBorder());
- control_view_->set_background(new ControlViewBackground(
- browser_view->IsOffTheRecord()));
-
- // This FrameView is always maximized so we don't want the window to have
- // resize borders.
- frame->GetNativeView()->set_hit_test_bounds_override_inner(gfx::Insets());
pkotwicz 2013/10/02 19:41:49 I removed this call because an empty gfx::Insets()
James Cook 2013/10/02 21:07:55 Are you sure this is safe? I seem to recall we did
pkotwicz 2013/10/03 20:45:35 You are completely right! Thanks for finding this
- // Watch for frame close so we can clean up the control widget.
- frame->AddObserver(frame_observer_.get());
- set_background(views::Background::CreateSolidBackground(SK_ColorBLACK));
pkotwicz 2013/10/02 19:41:49 I believe that setting the background is no longer
- // Create the controls.
- control_widget_ = new views::Widget;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
- params.parent = browser_view->GetNativeWindow();
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- control_widget_->Init(params);
- control_widget_->SetContentsView(control_view_);
- aura::Window* window = control_widget_->GetNativeView();
- window->SetName(kControlWindowName);
- // Need to exclude the shadow from the active control area.
- gfx::Insets hit_test_insets(control_view_->GetInsets());
- if (base::i18n::IsRTL()) {
- hit_test_insets = gfx::Insets(hit_test_insets.top(),
- hit_test_insets.right(),
- hit_test_insets.bottom(),
- hit_test_insets.left());
- }
- window->SetHitTestBoundsOverrideOuter(hit_test_insets, hit_test_insets);
-
- gfx::Rect control_bounds = GetControlBounds();
- window->SetBounds(control_bounds);
- control_widget_->Show();
+AppNonClientFrameViewAsh::AppNonClientFrameViewAsh(views::Widget* frame) {
+ container_.reset(new ash::HideableCaptionButtonContainer(
+ IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, frame));
+ container_->ShowButtonWidget();
}
AppNonClientFrameViewAsh::~AppNonClientFrameViewAsh() {
- frame()->RemoveObserver(frame_observer_.get());
- // This frame view can be replaced (and deleted) if the window is restored
- // via a keyboard shortcut like Alt-[. Ensure we close the control widget.
- CloseControlWidget();
}
gfx::Rect AppNonClientFrameViewAsh::GetBoundsForClientView() const {
@@ -192,45 +49,6 @@ void AppNonClientFrameViewAsh::UpdateWindowIcon() {
void AppNonClientFrameViewAsh::UpdateWindowTitle() {
}
-gfx::Rect AppNonClientFrameViewAsh::GetBoundsForTabStrip(
- views::View* tabstrip) const {
- return gfx::Rect();
-}
-
-BrowserNonClientFrameView::TabStripInsets
-AppNonClientFrameViewAsh::GetTabStripInsets(bool restored) const {
- return TabStripInsets();
-}
-
-int AppNonClientFrameViewAsh::GetThemeBackgroundXInset() const {
- return 0;
-}
-
-void AppNonClientFrameViewAsh::UpdateThrobber(bool running) {
-}
-
const char* AppNonClientFrameViewAsh::GetClassName() const {
return kViewClassName;
}
-
-void AppNonClientFrameViewAsh::OnBoundsChanged(
- const gfx::Rect& previous_bounds) {
- if (control_widget_)
- control_widget_->GetNativeView()->SetBounds(GetControlBounds());
-}
-
-gfx::Rect AppNonClientFrameViewAsh::GetControlBounds() const {
- if (!control_view_)
- return gfx::Rect();
- gfx::Size preferred = control_view_->GetPreferredSize();
- return gfx::Rect(
- base::i18n::IsRTL() ? 0 : (width() - preferred.width()), 0,
- preferred.width(), preferred.height());
-}
-
-void AppNonClientFrameViewAsh::CloseControlWidget() {
- if (control_widget_) {
- control_widget_->Close();
- control_widget_ = NULL;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698