Commit a005bd3d authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Merge BrowserNonClientFrameViewAsh/Mash.

Bug: 854704
Change-Id: I0900ccb649bb7c8b814b8b138bc52439d26bbb67
Reviewed-on: https://chromium-review.googlesource.com/1111651Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569807}
parent 046d91b8
......@@ -159,10 +159,6 @@ class DefaultCaptionButtonModel : public CaptionButtonModel {
const char FrameCaptionButtonContainerView::kViewClassName[] =
"FrameCaptionButtonContainerView";
FrameCaptionButtonContainerView::FrameCaptionButtonContainerView(
views::Widget* frame)
: FrameCaptionButtonContainerView(frame, nullptr) {}
FrameCaptionButtonContainerView::FrameCaptionButtonContainerView(
views::Widget* frame,
std::unique_ptr<CaptionButtonModel> model)
......
......@@ -8,6 +8,7 @@
#include <map>
#include "ash/ash_export.h"
#include "ash/frame/caption_buttons/caption_button_model.h"
#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_size_button_delegate.h"
#include "base/macros.h"
......@@ -26,8 +27,6 @@ class Widget;
namespace ash {
class CaptionButtonModel;
// Container view for the frame caption buttons. It performs the appropriate
// action when a caption button is clicked.
class ASH_EXPORT FrameCaptionButtonContainerView
......@@ -39,9 +38,9 @@ class ASH_EXPORT FrameCaptionButtonContainerView
static const char kViewClassName[];
// |frame| is the views::Widget that the caption buttons act on.
explicit FrameCaptionButtonContainerView(views::Widget* frame);
FrameCaptionButtonContainerView(views::Widget* frame,
std::unique_ptr<CaptionButtonModel> model);
FrameCaptionButtonContainerView(
views::Widget* frame,
std::unique_ptr<CaptionButtonModel> model = nullptr);
~FrameCaptionButtonContainerView() override;
// For testing.
......
......@@ -1905,8 +1905,6 @@ split_static_library("ui") {
"views/frame/browser_frame_mash.h",
"views/frame/browser_non_client_frame_view_ash.cc",
"views/frame/browser_non_client_frame_view_ash.h",
"views/frame/browser_non_client_frame_view_mash.cc",
"views/frame/browser_non_client_frame_view_mash.h",
"views/frame/immersive_context_mus.cc",
"views/frame/immersive_context_mus.h",
"views/frame/immersive_handler_factory_mus.cc",
......
specific_include_rules = {
# This class is only used in classic Ash.
# Parts of this class use Ash, but only when run in classic Ash mode.
"browser_non_client_frame_view_ash\.*": [
"+ash",
],
......
......@@ -13,6 +13,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "chrome/browser/command_observer.h"
#include "chrome/browser/ui/ash/browser_image_registrar.h"
#include "chrome/browser/ui/ash/tablet_mode_client_observer.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
......@@ -60,7 +61,10 @@ class BrowserNonClientFrameViewAsh
int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
void UpdateThrobber(bool running) override;
void UpdateClientArea() override;
void UpdateMinimumSize() override;
int GetTabStripLeftInset() const override;
void OnTabsMaxXChanged() override;
// views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
......@@ -80,6 +84,7 @@ class BrowserNonClientFrameViewAsh
const char* GetClassName() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
gfx::Size GetMinimumSize() const override;
void OnThemeChanged() override;
void ChildPreferredSizeChanged(views::View* child) override;
// ash::CustomFrameHeader::AppearanceProvider:
......@@ -175,19 +180,19 @@ class BrowserNonClientFrameViewAsh
void StartHostedAppAnimation();
// View which contains the window controls.
ash::FrameCaptionButtonContainerView* caption_button_container_;
ash::FrameCaptionButtonContainerView* caption_button_container_ = nullptr;
ash::FrameCaptionButton* back_button_;
ash::FrameCaptionButton* back_button_ = nullptr;
// For popups, the window icon.
TabIconView* window_icon_;
TabIconView* window_icon_ = nullptr;
// Helper class for painting the header.
std::unique_ptr<ash::FrameHeader> frame_header_;
// Container for extra frame buttons shown for hosted app windows.
// Owned by views hierarchy.
HostedAppButtonContainer* hosted_app_button_container_;
HostedAppButtonContainer* hosted_app_button_container_ = nullptr;
// URL origin text for hosted app windows.
// Owned by views hierarchy.
......@@ -197,7 +202,7 @@ class BrowserNonClientFrameViewAsh
ash::mojom::SplitViewControllerPtr split_view_controller_;
// The binding this instance uses to implement mojom::SplitViewObserver.
mojo::Binding<ash::mojom::SplitViewObserver> observer_binding_;
mojo::Binding<ash::mojom::SplitViewObserver> observer_binding_{this};
// Indicates whether overview mode is active. Hide the header for V1 apps in
// overview mode because a fake header is added for better UX. If also in
......@@ -209,7 +214,14 @@ class BrowserNonClientFrameViewAsh
ash::mojom::SplitViewState split_view_state_ =
ash::mojom::SplitViewState::NO_SNAP;
base::WeakPtrFactory<BrowserNonClientFrameViewAsh> weak_factory_;
// A reference to the entry in BrowserImageRegistrar for each frame
// image. Multiple windows that share a browser theme will hold onto each ref.
scoped_refptr<ImageRegistration> active_frame_image_registration_;
scoped_refptr<ImageRegistration> inactive_frame_image_registration_;
scoped_refptr<ImageRegistration> active_frame_overlay_image_registration_;
scoped_refptr<ImageRegistration> inactive_frame_overlay_image_registration_;
base::WeakPtrFactory<BrowserNonClientFrameViewAsh> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
};
......
......@@ -2,23 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "build/build_config.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mash.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "ui/base/ui_base_features.h"
namespace chrome {
BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
BrowserFrame* frame,
BrowserView* browser_view) {
if (!features::IsAshInBrowserProcess()) {
BrowserNonClientFrameViewMash* frame_view =
new BrowserNonClientFrameViewMash(frame, browser_view);
frame_view->Init();
return frame_view;
}
BrowserNonClientFrameViewAsh* frame_view =
new BrowserNonClientFrameViewAsh(frame, browser_view);
frame_view->Init();
......
// Copyright 2015 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.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_MASH_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_MASH_H_
#include <memory>
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/ui/ash/browser_image_registrar.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/tab_icon_view_model.h"
class TabIconView;
// TODO: Make sure caption buttons ink drop effects work with immersive
// fullscreen mode browsers. https://crbug.com/840242.
class BrowserNonClientFrameViewMash : public BrowserNonClientFrameView,
public TabIconViewModel {
public:
static const char kViewClassName[];
BrowserNonClientFrameViewMash(BrowserFrame* frame, BrowserView* browser_view);
~BrowserNonClientFrameViewMash() override;
void Init();
// BrowserNonClientFrameView:
void OnBrowserViewInitViewsComplete() override;
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
void UpdateThrobber(bool running) override;
void UpdateClientArea() override;
void UpdateMinimumSize() override;
int GetTabStripLeftInset() const override;
void OnTabsMaxXChanged() override;
// views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
gfx::Rect GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const override;
int NonClientHitTest(const gfx::Point& point) override;
void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override;
void ResetWindowControls() override;
void UpdateWindowIcon() override;
void UpdateWindowTitle() override;
void SizeConstraintsChanged() override;
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
void Layout() override;
const char* GetClassName() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
gfx::Size GetMinimumSize() const override;
void OnThemeChanged() override;
// TabIconViewModel:
bool ShouldTabIconViewAnimate() const override;
gfx::ImageSkia GetFaviconForTabIconView() override;
protected:
// BrowserNonClientFrameView:
AvatarButtonStyle GetAvatarButtonStyle() const override;
private:
// Distance between the right edge of the NonClientFrameView and the tab
// strip.
int GetTabStripRightInset() const;
// Returns true if the header should be painted so that it looks the same as
// the header used for packaged apps. Packaged apps use a different color
// scheme than browser windows.
bool UsePackagedAppHeaderStyle() const;
// Returns true if there is anything to paint. Some fullscreen windows do not
// need their frames painted.
bool ShouldPaint() const;
// Draws the line under the header for windows without a toolbar and not using
// the packaged app header style.
void PaintContentEdge(gfx::Canvas* canvas);
// Returns the height for the header (non-client frame area).
int GetHeaderHeight() const;
// TODO(sky): Figure out how to support WebAppLeftHeaderView.
// For popups, the window icon.
TabIconView* window_icon_;
TabStrip* tab_strip_;
// A reference to the entry in BrowserImageRegistrar for each frame
// image. Multiple windows that share a browser theme will hold onto each ref.
scoped_refptr<ImageRegistration> active_frame_image_registration_;
scoped_refptr<ImageRegistration> inactive_frame_image_registration_;
scoped_refptr<ImageRegistration> active_frame_overlay_image_registration_;
scoped_refptr<ImageRegistration> inactive_frame_overlay_image_registration_;
DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewMash);
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_MASH_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment