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

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

Issue 441803004: Introduce new WebApp header style for hosted apps and fizzy apps on ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 6 years, 4 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/browser_non_client_frame_view_ash.cc
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index 1089441851e30bc72efb9b2c4720f018fd95526a..c8ca4a65ac335132f5b59b7a041a41edc2d1de61 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -7,18 +7,22 @@
#include <algorithm>
#include "ash/ash_switches.h"
+#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/default_header_painter.h"
#include "ash/frame/frame_border_hit_test_controller.h"
#include "ash/frame/header_painter_util.h"
#include "ash/shell.h"
#include "base/command_line.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
+#include "chrome/browser/ui/views/frame/webapp_header_painter_ash.h"
#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/tab_icon_view.h"
@@ -83,6 +87,7 @@ BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
BrowserFrame* frame, BrowserView* browser_view)
: BrowserNonClientFrameView(frame, browser_view),
caption_button_container_(NULL),
+ webapp_back_button_(NULL),
pkotwicz 2014/08/06 21:36:49 Nit: Rename to web_app_back_button_
benwells 2014/08/13 00:53:45 Done.
window_icon_(NULL),
frame_border_hit_test_controller_(
new ash::FrameBorderHitTestController(frame)) {
@@ -91,6 +96,7 @@ BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() {
ash::Shell::GetInstance()->RemoveShellObserver(this);
+ chrome::RemoveCommandObserver(browser_view()->browser(), IDC_BACK, this);
}
void BrowserNonClientFrameViewAsh::Init() {
@@ -116,6 +122,17 @@ void BrowserNonClientFrameViewAsh::Init() {
header_painter_.reset(header_painter);
header_painter->Init(frame(), this, window_icon_,
caption_button_container_);
+ } else if (UseWebAppHeaderStyle()) {
+ webapp_back_button_ =
+ new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK);
+ UpdateBackButtonState(false);
pkotwicz 2014/08/06 21:36:48 The back button should be enabled by default. Othe
benwells 2014/08/13 00:53:45 Done.
+ chrome::AddCommandObserver(browser_view()->browser(), IDC_BACK, this);
+ AddChildView(webapp_back_button_);
+
+ WebAppHeaderPainterAsh* header_painter = new WebAppHeaderPainterAsh;
pkotwicz 2014/08/06 21:36:48 I would rather use DefaultHeaderPainter (as oppose
benwells 2014/08/11 07:06:15 Yeah there is currently little special logic. I'll
benwells 2014/08/13 00:53:45 Done.
+ header_painter_.reset(header_painter);
+ header_painter->InitForWebApp(frame(), this, webapp_back_button_,
+ caption_button_container_);
} else {
BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh;
header_painter_.reset(header_painter);
@@ -156,7 +173,7 @@ int BrowserNonClientFrameViewAsh::GetTopInset() const {
return kTabstripTopSpacingTall;
}
- if (UsePackagedAppHeaderStyle())
+ if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle())
return header_painter_->GetHeaderHeightForPainting();
int caption_buttons_bottom = caption_button_container_->bounds().bottom();
@@ -206,6 +223,10 @@ int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
(avatar_label() && avatar_label()->GetMirroredBounds().Contains(point))))
return HTCLIENT;
+ if (hit_test == HTCAPTION && webapp_back_button_ &&
+ webapp_back_button_->GetMirroredBounds().Contains(point))
+ return HTCLIENT;
+
// When the window is restored we want a large click target above the tabs
// to drag the window, so redirect clicks in the tab's shadow to caption.
if (hit_test == HTCLIENT &&
@@ -265,7 +286,7 @@ void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
header_painter_->PaintHeader(canvas, header_mode);
if (browser_view()->IsToolbarVisible())
PaintToolbarBackground(canvas);
- else if (!UsePackagedAppHeaderStyle())
+ else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle())
PaintContentEdge(canvas);
}
@@ -363,6 +384,24 @@ gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() {
}
///////////////////////////////////////////////////////////////////////////////
+// CommandObserver:
+
+void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id,
+ bool enabled) {
+ DCHECK_EQ(IDC_BACK, id);
+ UpdateBackButtonState(enabled);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// views::ButtonListener:
+
+void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender,
+ const ui::Event& event) {
+ DCHECK_EQ(sender, webapp_back_button_);
+ chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK);
+}
+
+///////////////////////////////////////////////////////////////////////////////
// BrowserNonClientFrameViewAsh, private:
// views::NonClientFrameView:
@@ -417,12 +456,20 @@ bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const {
bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const {
// Non streamlined hosted apps do not have a toolbar or tabstrip. Their header
// should look the same as the header for packaged apps. Streamlined hosted
- // apps have a toolbar so should use the browser header style.
+ // apps have the experimental WebApp header style.
pkotwicz 2014/08/06 21:36:48 Nit: Maybe change the return value to: return brow
benwells 2014/08/13 00:53:45 Done.
return browser_view()->browser()->is_app() &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableStreamlinedHostedApps);
}
+bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const {
+ // Use of the experimental WebApp header style is guarded with the
+ // streamlined hosted app style.
+ return browser_view()->browser()->is_app() &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableStreamlinedHostedApps);
+}
+
void BrowserNonClientFrameViewAsh::LayoutAvatar() {
DCHECK(avatar_button());
#if !defined(OS_CHROMEOS)
@@ -550,9 +597,15 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {
}
void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
- DCHECK(!UsePackagedAppHeaderStyle());
+ DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle());
canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(),
width(), kClientEdgeThickness),
ThemeProperties::GetDefaultColor(
ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
}
+
+void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) {
+ webapp_back_button_->SetState(enabled ? views::Button::STATE_NORMAL
+ : views::Button::STATE_DISABLED);
+ webapp_back_button_->set_paint_as_active(enabled);
+}
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698