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

Side by Side Diff: chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc

Issue 11229041: Rename and move Ash window frame files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/ui/views/ash/browser_non_client_frame_view_ash.h"
6
7 #include "ash/wm/frame_painter.h"
8 #include "ash/wm/workspace/frame_maximize_button.h"
9 #include "chrome/browser/themes/theme_service.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/ntp_background_util.h"
12 #include "chrome/browser/ui/search/search.h"
13 #include "chrome/browser/ui/search/search_delegate.h"
14 #include "chrome/browser/ui/search/search_model.h"
15 #include "chrome/browser/ui/search/search_ui.h"
16 #include "chrome/browser/ui/views/avatar_menu_button.h"
17 #include "chrome/browser/ui/views/frame/browser_frame.h"
18 #include "chrome/browser/ui/views/frame/browser_view.h"
19 #include "chrome/browser/ui/views/tab_icon_view.h"
20 #include "chrome/browser/ui/views/tabs/tab_strip.h"
21 #include "chrome/browser/ui/views/toolbar_view.h"
22 #include "chrome/browser/ui/webui/instant_ui.h"
23 #include "content/public/browser/web_contents.h"
24 #include "grit/ash_resources.h"
25 #include "grit/generated_resources.h" // Accessibility names
26 #include "grit/theme_resources.h"
27 #include "ui/aura/client/aura_constants.h"
28 #include "ui/aura/window.h"
29 #include "ui/base/accessibility/accessible_view_state.h"
30 #include "ui/base/hit_test.h"
31 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/layout.h"
33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/base/theme_provider.h"
35 #include "ui/compositor/layer_animator.h"
36 #include "ui/gfx/canvas.h"
37 #include "ui/gfx/image/image_skia.h"
38 #include "ui/views/controls/button/image_button.h"
39 #include "ui/views/widget/widget.h"
40 #include "ui/views/widget/widget_delegate.h"
41
42 namespace {
43
44 // The avatar ends 2 px above the bottom of the tabstrip (which, given the
45 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
46 // user).
47 const int kAvatarBottomSpacing = 2;
48 // There are 2 px on each side of the avatar (between the frame border and
49 // it on the left, and between it and the tabstrip on the right).
50 const int kAvatarSideSpacing = 2;
51 // Space between left edge of window and tabstrip.
52 const int kTabstripLeftSpacing = 0;
53 // Space between right edge of tabstrip and maximize button.
54 const int kTabstripRightSpacing = 10;
55 // Height of the shadow of the content area, at the top of the toolbar.
56 const int kContentShadowHeight = 1;
57
58 // Space between top of window and top of tabstrip for tall headers, such as
59 // for restored windows, apps, etc.
60 int tabstrip_top_spacing_tall() {
61 static int value = -1;
62 if (value == -1) {
63 switch (ui::GetDisplayLayout()) {
64 case ui::LAYOUT_ASH:
65 case ui::LAYOUT_DESKTOP:
66 value = 7;
67 break;
68 case ui::LAYOUT_TOUCH:
69 value = 8;
70 break;
71 default:
72 NOTREACHED();
73 }
74 }
75 return value;
76 }
77
78 // Space between top of window and top of tabstrip for short headers, such as
79 // for maximized windows, pop-ups, etc.
80 int tabstrip_top_spacing_short() {
81 static int value = -1;
82 if (value == -1) {
83 switch (ui::GetDisplayLayout()) {
84 case ui::LAYOUT_ASH:
85 case ui::LAYOUT_DESKTOP:
86 // Place them flush to the top to make them clickable when the cursor
87 // is at the screen edge.
88 value = 0;
89 break;
90 case ui::LAYOUT_TOUCH:
91 // Touch needs space for full-size window caption buttons (size, close)
92 // and Fitt's Law doesn't apply to fingers at the screen edge.
93 value = 8;
94 break;
95 default:
96 NOTREACHED();
97 }
98 }
99 return value;
100 }
101
102 // Height of the shadow in the tab image, used to ensure clicks in the shadow
103 // area still drag restored windows. This keeps the clickable area large enough
104 // to hit easily.
105 int tab_shadow_height() {
106 static int value = -1;
107 if (value == -1) {
108 switch (ui::GetDisplayLayout()) {
109 case ui::LAYOUT_ASH:
110 case ui::LAYOUT_DESKTOP:
111 value = 4;
112 break;
113 case ui::LAYOUT_TOUCH:
114 value = 5;
115 break;
116 default:
117 NOTREACHED();
118 }
119 }
120 return value;
121 }
122
123 } // namespace
124
125 ///////////////////////////////////////////////////////////////////////////////
126 // BrowserNonClientFrameViewAsh, public:
127
128 // static
129 const char BrowserNonClientFrameViewAsh::kViewClassName[] =
130 "BrowserNonClientFrameViewAsh";
131
132 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
133 BrowserFrame* frame, BrowserView* browser_view)
134 : BrowserNonClientFrameView(frame, browser_view),
135 size_button_(NULL),
136 close_button_(NULL),
137 window_icon_(NULL),
138 frame_painter_(new ash::FramePainter),
139 size_button_minimizes_(false) {
140 }
141
142 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() {
143 // A non-NULL |size_button_| means it was initialized in Init() where
144 // |this| was added as observer to ToolbarSearchAnimator, so remove it now.
145 if (size_button_) {
146 browser_view()->browser()->search_delegate()->toolbar_search_animator().
147 RemoveObserver(this);
148 }
149 }
150
151 void BrowserNonClientFrameViewAsh::Init() {
152 // Panels only minimize.
153 ash::FramePainter::SizeButtonBehavior size_button_behavior;
154 if (browser_view()->browser()->is_type_panel() &&
155 browser_view()->browser()->app_type() == Browser::APP_TYPE_CHILD) {
156 size_button_minimizes_ = true;
157 size_button_ = new views::ImageButton(this);
158 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MINIMIZES;
159 } else {
160 size_button_ = new ash::FrameMaximizeButton(this, this);
161 size_button_behavior = ash::FramePainter::SIZE_BUTTON_MAXIMIZES;
162 }
163 size_button_->SetAccessibleName(
164 l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE));
165 AddChildView(size_button_);
166 close_button_ = new views::ImageButton(this);
167 close_button_->SetAccessibleName(
168 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
169 AddChildView(close_button_);
170
171 // Initializing the TabIconView is expensive, so only do it if we need to.
172 if (browser_view()->ShouldShowWindowIcon()) {
173 window_icon_ = new TabIconView(this);
174 window_icon_->set_is_light(true);
175 AddChildView(window_icon_);
176 window_icon_->Update();
177 }
178
179 // Create incognito icon if necessary.
180 UpdateAvatarInfo();
181
182 // Frame painter handles layout of these buttons.
183 frame_painter_->Init(frame(), window_icon_, size_button_, close_button_,
184 size_button_behavior);
185
186 browser_view()->browser()->search_delegate()->toolbar_search_animator().
187 AddObserver(this);
188 }
189
190 ///////////////////////////////////////////////////////////////////////////////
191 // BrowserNonClientFrameView overrides:
192
193 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip(
194 views::View* tabstrip) const {
195 if (!tabstrip)
196 return gfx::Rect();
197 TabStripInsets insets(GetTabStripInsets(false));
198 return gfx::Rect(insets.left, insets.top,
199 std::max(0, width() - insets.left - insets.right),
200 tabstrip->GetPreferredSize().height());
201 }
202
203 BrowserNonClientFrameView::TabStripInsets
204 BrowserNonClientFrameViewAsh::GetTabStripInsets(bool force_restored) const {
205 int left = avatar_button() ? kAvatarSideSpacing +
206 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing :
207 kTabstripLeftSpacing;
208 int right = frame_painter_->GetRightInset() + kTabstripRightSpacing;
209 return TabStripInsets(NonClientTopBorderHeight(force_restored), left, right);
210 }
211
212 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const {
213 return frame_painter_->GetThemeBackgroundXInset();
214 }
215
216 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) {
217 if (window_icon_)
218 window_icon_->Update();
219 }
220
221 ///////////////////////////////////////////////////////////////////////////////
222 // views::NonClientFrameView overrides:
223
224 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const {
225 int top_height = NonClientTopBorderHeight(false);
226 return frame_painter_->GetBoundsForClientView(top_height, bounds());
227 }
228
229 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds(
230 const gfx::Rect& client_bounds) const {
231 int top_height = NonClientTopBorderHeight(false);
232 return frame_painter_->GetWindowBoundsForClientBounds(top_height,
233 client_bounds);
234 }
235
236 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
237 int hit_test = frame_painter_->NonClientHitTest(this, point);
238 // When the window is restored we want a large click target above the tabs
239 // to drag the window, so redirect clicks in the tab's shadow to caption.
240 if (hit_test == HTCLIENT) { // && !frame()->IsMaximized()) {
241 // Convert point to client coordinates.
242 gfx::Point client_point(point);
243 View::ConvertPointToTarget(this, frame()->client_view(), &client_point);
244 // Report hits in shadow at top of tabstrip as caption.
245 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
246 if (client_point.y() < tabstrip_bounds.y() + tab_shadow_height())
247 hit_test = HTCAPTION;
248 }
249 return hit_test;
250 }
251
252 void BrowserNonClientFrameViewAsh::GetWindowMask(const gfx::Size& size,
253 gfx::Path* window_mask) {
254 // Aura does not use window masks.
255 }
256
257 void BrowserNonClientFrameViewAsh::ResetWindowControls() {
258 size_button_->SetState(views::CustomButton::BS_NORMAL);
259 // The close button isn't affected by this constraint.
260 }
261
262 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() {
263 if (window_icon_)
264 window_icon_->SchedulePaint();
265 }
266
267 void BrowserNonClientFrameViewAsh::UpdateWindowTitle() {
268 if (!frame()->IsFullscreen())
269 frame_painter_->SchedulePaintForTitle(this, BrowserFrame::GetTitleFont());
270 }
271
272 ///////////////////////////////////////////////////////////////////////////////
273 // views::View overrides:
274
275 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
276 if (frame()->IsFullscreen())
277 return; // Nothing visible, don't paint.
278 // The primary header image changes based on window activation state and
279 // theme, so we look it up for each paint.
280 frame_painter_->PaintHeader(
281 this,
282 canvas,
283 ShouldPaintAsActive() ?
284 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE,
285 GetThemeFrameImageId(),
286 GetThemeFrameOverlayImage());
287 if (browser_view()->ShouldShowWindowTitle())
288 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont());
289 if (browser_view()->IsToolbarVisible()) {
290 chrome::search::Mode mode =
291 browser_view()->browser()->search_model()->mode();
292 bool fading_in = false;
293 // Get current opacity of gradient background animation to figure out if
294 // we need to paint both flat and gradient backgrounds or just one:
295 // - if |gradient_opacity| < 1f, paint flat background at full opacity, and
296 // only paint gradient background if |gradient_opacity| is not 0f;
297 // - if |gradient_opacity| is 1f, paint the background for the current mode
298 // at full opacity.
299 double gradient_opacity = browser_view()->browser()->search_delegate()->
300 toolbar_search_animator().GetGradientOpacity();
301 if (gradient_opacity < 1.0f) {
302 // Paint flat background of |MODE_NTP|.
303 PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP);
304 // We're done if we're not showing gradient background.
305 if (gradient_opacity == 0.0f)
306 return;
307 // Otherwise, we're fading in gradient background at |gradient_opacity|.
308 fading_in = true;
309 canvas->SaveLayerAlpha(static_cast<uint8>(gradient_opacity * 0xFF));
310 }
311 // Paint the background for the current mode.
312 PaintToolbarBackground(canvas, mode.mode);
313 // If we're fading in and have saved canvas, restore it now.
314 if (fading_in)
315 canvas->Restore();
316 } else {
317 PaintContentEdge(canvas);
318 }
319 }
320
321 void BrowserNonClientFrameViewAsh::Layout() {
322 frame_painter_->LayoutHeader(this, UseShortHeader());
323 if (avatar_button())
324 LayoutAvatar();
325 BrowserNonClientFrameView::Layout();
326 }
327
328 std::string BrowserNonClientFrameViewAsh::GetClassName() const {
329 return kViewClassName;
330 }
331
332 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const {
333 // If the rect is outside the bounds of the client area, claim it.
334 if (NonClientFrameView::HitTestRect(rect))
335 return true;
336
337 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
338 if (!browser_view()->tabstrip())
339 return false;
340 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
341 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
342 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin);
343 tabstrip_bounds.set_origin(tabstrip_origin);
344 if (rect.bottom() > tabstrip_bounds.bottom())
345 return false;
346
347 // We convert from our parent's coordinates since we assume we fill its bounds
348 // completely. We need to do this since we're not a parent of the tabstrip,
349 // meaning ConvertPointToTarget would otherwise return something bogus.
350 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of
351 // its center point once GetEventHandlerForRect() is implemented.
352 gfx::Point browser_view_point(rect.CenterPoint());
353 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point);
354 return browser_view()->IsPositionInWindowCaption(browser_view_point);
355 }
356
357 void BrowserNonClientFrameViewAsh::GetAccessibleState(
358 ui::AccessibleViewState* state) {
359 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR;
360 }
361
362 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() {
363 return frame_painter_->GetMinimumSize(this);
364 }
365
366 ///////////////////////////////////////////////////////////////////////////////
367 // views::ButtonListener overrides:
368
369 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender,
370 const ui::Event& event) {
371 // When shift-clicking slow down animations for visual debugging.
372 // We used to do this via an event filter that looked for the shift key being
373 // pressed but this interfered with several normal keyboard shortcuts.
374 if (event.IsShiftDown())
375 ui::LayerAnimator::set_slow_animation_mode(true);
376
377 if (sender == size_button_) {
378 // The maximize button may move out from under the cursor.
379 ResetWindowControls();
380 if (size_button_minimizes_)
381 frame()->Minimize();
382 else if (frame()->IsMaximized())
383 frame()->Restore();
384 else
385 frame()->Maximize();
386 // |this| may be deleted - some windows delete their frames on maximize.
387 } else if (sender == close_button_) {
388 frame()->Close();
389 }
390
391 if (event.IsShiftDown())
392 ui::LayerAnimator::set_slow_animation_mode(false);
393 }
394
395 ///////////////////////////////////////////////////////////////////////////////
396 // chrome::TabIconViewModel overrides:
397
398 bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const {
399 // This function is queried during the creation of the window as the
400 // TabIconView we host is initialized, so we need to NULL check the selected
401 // WebContents because in this condition there is not yet a selected tab.
402 content::WebContents* current_tab = browser_view()->GetActiveWebContents();
403 return current_tab ? current_tab->IsLoading() : false;
404 }
405
406 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() {
407 views::WidgetDelegate* delegate = frame()->widget_delegate();
408 if (!delegate)
409 return gfx::ImageSkia();
410 return delegate->GetWindowIcon();
411 }
412
413 ///////////////////////////////////////////////////////////////////////////////
414 // chrome::search::ToolbarSearchAnimator::Observer overrides:
415
416 void BrowserNonClientFrameViewAsh::OnToolbarBackgroundAnimatorProgressed() {
417 // We're fading in the toolbar background, repaint the toolbar background.
418 browser_view()->toolbar()->SchedulePaint();
419 }
420
421 void BrowserNonClientFrameViewAsh::OnToolbarBackgroundAnimatorCanceled(
422 content::WebContents* web_contents) {
423 // Fade in of toolbar background has been canceled, repaint the toolbar
424 // background.
425 browser_view()->toolbar()->SchedulePaint();
426 }
427
428 void BrowserNonClientFrameViewAsh::OnToolbarSeparatorChanged() {
429 // Omnibox popup has finished closing, paint the toolbar separator.
430 browser_view()->toolbar()->SchedulePaint();
431 }
432
433 ///////////////////////////////////////////////////////////////////////////////
434 // BrowserNonClientFrameViewAsh, private:
435
436
437 int BrowserNonClientFrameViewAsh::NonClientTopBorderHeight(
438 bool force_restored) const {
439 if (force_restored)
440 return tabstrip_top_spacing_tall();
441 if (frame()->IsFullscreen())
442 return 0;
443 // Windows with tab strips need a smaller non-client area.
444 if (browser_view()->IsTabStripVisible()) {
445 if (UseShortHeader())
446 return tabstrip_top_spacing_short();
447 return tabstrip_top_spacing_tall();
448 }
449 // For windows without a tab strip (popups, etc.) ensure we have enough space
450 // to see the window caption buttons.
451 return close_button_->bounds().bottom() - kContentShadowHeight;
452 }
453
454 bool BrowserNonClientFrameViewAsh::UseShortHeader() const {
455 // Restored browser -> tall header
456 // Maximized browser -> short header
457 // Popup&App window -> tall header
458 // Panel -> short header
459 // Dialogs use short header and are handled via CustomFrameViewAsh.
460 Browser* browser = browser_view()->browser();
461 switch (browser->type()) {
462 case Browser::TYPE_TABBED:
463 return frame()->IsMaximized();
464 case Browser::TYPE_POPUP:
465 return false;
466 case Browser::TYPE_PANEL:
467 return true;
468 default:
469 NOTREACHED();
470 return false;
471 }
472 }
473
474 void BrowserNonClientFrameViewAsh::LayoutAvatar() {
475 DCHECK(avatar_button());
476 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
477
478 int avatar_bottom = GetTabStripInsets(false).top +
479 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
480 int avatar_restored_y = avatar_bottom - incognito_icon.height();
481 int avatar_y = frame()->IsMaximized() ?
482 NonClientTopBorderHeight(false) + kContentShadowHeight:
483 avatar_restored_y;
484 gfx::Rect avatar_bounds(kAvatarSideSpacing,
485 avatar_y,
486 incognito_icon.width(),
487 avatar_bottom - avatar_y);
488 avatar_button()->SetBoundsRect(avatar_bounds);
489 }
490
491 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(
492 gfx::Canvas* canvas,
493 chrome::search::Mode::Type mode) {
494 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
495 if (toolbar_bounds.IsEmpty())
496 return;
497 gfx::Point toolbar_origin(toolbar_bounds.origin());
498 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
499 toolbar_bounds.set_origin(toolbar_origin);
500
501 int x = toolbar_bounds.x();
502 int w = toolbar_bounds.width();
503 int y = toolbar_bounds.y();
504 int h = toolbar_bounds.height();
505
506 // Gross hack: We split the toolbar images into two pieces, since sometimes
507 // (popup mode) the toolbar isn't tall enough to show the whole image. The
508 // split happens between the top shadow section and the bottom gradient
509 // section so that we never break the gradient.
510 int split_point = kFrameShadowThickness * 2;
511 int bottom_y = y + split_point;
512 ui::ThemeProvider* tp = GetThemeProvider();
513 int bottom_edge_height = h - split_point;
514
515 // Paint the main toolbar image. Since this image is also used to draw the
516 // tab background, we must use the tab strip offset to compute the image
517 // source y position. If you have to debug this code use an image editor
518 // to paint a diagonal line through the toolbar image and ensure it lines up
519 // across the tab and toolbar.
520 // Determine if we're using NTP background theme for top chrome i.e. toolbar
521 // and tab.
522 gfx::Rect paint_rect(x, bottom_y, w, bottom_edge_height);
523 Profile* profile = browser_view()->browser()->profile();
524 bool is_instant_extended_api_enabled =
525 chrome::search::IsInstantExtendedAPIEnabled(profile);
526 bool use_ntp_background_theme = false;
527 gfx::ImageSkia* theme_toolbar =
528 chrome::search::GetTopChromeBackgroundImage(tp,
529 is_instant_extended_api_enabled, mode,
530 InstantUI::ShouldShowWhiteNTP(profile), &use_ntp_background_theme);
531
532 // If |use_ntp_background_theme| is true, paint NTP background theme in
533 // toolbar, else paint IDR_THEME_TOOLBAR.
534 if (use_ntp_background_theme) {
535 // Convert |paint_rect| back to |BrowserView|.
536 gfx::Rect paint_rect_in_browser_view(paint_rect);
537 gfx::Point origin(paint_rect_in_browser_view.origin());
538 View::ConvertPointToTarget(this, browser_view(), &origin);
539 paint_rect_in_browser_view.set_origin(origin);
540 NtpBackgroundUtil::PaintBackgroundForBrowserClientArea(profile, canvas,
541 paint_rect, browser_view()->size(), paint_rect_in_browser_view);
542 } else {
543 SkColor background_color = chrome::search::GetToolbarBackgroundColor(
544 profile, mode);
545 canvas->FillRect(paint_rect, background_color);
546
547 canvas->TileImageInt(
548 *theme_toolbar,
549 x + GetThemeBackgroundXInset(),
550 bottom_y - GetTabStripInsets(false).top,
551 x, bottom_y,
552 w, theme_toolbar->height());
553 }
554
555 // The content area line has a shadow that extends a couple of pixels above
556 // the toolbar bounds.
557 const int kContentShadowHeight = 2;
558 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(
559 is_instant_extended_api_enabled ? IDR_TOOLBAR_SHADE_TOP_SEARCH :
560 IDR_TOOLBAR_SHADE_TOP);
561 canvas->TileImageInt(*toolbar_top,
562 0, 0,
563 x, y - kContentShadowHeight,
564 w, split_point + kContentShadowHeight + 1);
565
566 // Draw the "lightening" shade line around the edges of the toolbar.
567 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT);
568 canvas->TileImageInt(*toolbar_left,
569 0, 0,
570 x + kClientEdgeThickness,
571 y + kClientEdgeThickness + kContentShadowHeight,
572 toolbar_left->width(), theme_toolbar->height());
573 gfx::ImageSkia* toolbar_right =
574 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT);
575 canvas->TileImageInt(*toolbar_right,
576 0, 0,
577 w - toolbar_right->width() - 2 * kClientEdgeThickness,
578 y + kClientEdgeThickness + kContentShadowHeight,
579 toolbar_right->width(), theme_toolbar->height());
580
581 // Only draw the content/toolbar separator if Instant Extended API is disabled
582 // or mode is |DEFAULT|.
583 if (!is_instant_extended_api_enabled ||
584 browser_view()->browser()->search_delegate()->toolbar_search_animator().
585 IsToolbarSeparatorVisible()) {
586 canvas->FillRect(
587 gfx::Rect(x + kClientEdgeThickness,
588 toolbar_bounds.bottom() - kClientEdgeThickness,
589 w - (2 * kClientEdgeThickness),
590 kClientEdgeThickness),
591 ThemeService::GetDefaultColor(is_instant_extended_api_enabled ?
592 ThemeService::COLOR_SEARCH_SEPARATOR_LINE :
593 ThemeService::COLOR_TOOLBAR_SEPARATOR));
594 }
595 }
596
597 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
598 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(),
599 width(), kClientEdgeThickness),
600 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
601 }
602
603 int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const {
604 bool is_incognito = browser_view()->IsOffTheRecord();
605 if (browser_view()->IsBrowserTypeNormal()) {
606 // Use the standard resource ids to allow users to theme the frames.
607 if (ShouldPaintAsActive()) {
608 return is_incognito ?
609 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
610 }
611 return is_incognito ?
612 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
613 }
614 // Never theme app and popup windows.
615 if (ShouldPaintAsActive()) {
616 return is_incognito ?
617 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE :
618 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE;
619 }
620 return is_incognito ?
621 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_INACTIVE :
622 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
623 }
624
625 const gfx::ImageSkia*
626 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const {
627 ui::ThemeProvider* tp = GetThemeProvider();
628 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
629 browser_view()->IsBrowserTypeNormal() &&
630 !browser_view()->IsOffTheRecord()) {
631 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ?
632 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
633 }
634 return NULL;
635 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698