| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_frame.h" | 9 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
| 12 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "grit/theme_resources_standard.h" | 14 #include "grit/theme_resources_standard.h" |
| 15 #include "grit/ui_resources.h" | 15 #include "grit/ui_resources.h" |
| 16 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/font.h" | 20 #include "ui/gfx/font.h" |
| 21 #include "ui/gfx/path.h" | 21 #include "ui/gfx/path.h" |
| 22 #include "ui/views/controls/button/image_button.h" | 22 #include "ui/views/controls/button/image_button.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 25 | 25 |
| 26 using content::WebContents; |
| 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 // The frame border is only visible in restored mode and is hardcoded to 1 px on | 30 // The frame border is only visible in restored mode and is hardcoded to 1 px on |
| 29 // each side regardless of the system window border size. | 31 // each side regardless of the system window border size. |
| 30 const int kFrameBorderThickness = 1; | 32 const int kFrameBorderThickness = 1; |
| 31 // In the window corners, the resize areas don't actually expand bigger, but the | 33 // In the window corners, the resize areas don't actually expand bigger, but the |
| 32 // 16 px at the end of each edge triggers diagonal resizing. | 34 // 16 px at the end of each edge triggers diagonal resizing. |
| 33 const int kResizeAreaCornerSize = 16; | 35 const int kResizeAreaCornerSize = 16; |
| 34 // The titlebar never shrinks too short to show the caption button plus some | 36 // The titlebar never shrinks too short to show the caption button plus some |
| 35 // padding below it. | 37 // padding below it. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 if (sender == close_button_) | 233 if (sender == close_button_) |
| 232 frame()->Close(); | 234 frame()->Close(); |
| 233 } | 235 } |
| 234 | 236 |
| 235 /////////////////////////////////////////////////////////////////////////////// | 237 /////////////////////////////////////////////////////////////////////////////// |
| 236 // AppPanelBrowserFrameView, TabIconView::TabContentsProvider implementation: | 238 // AppPanelBrowserFrameView, TabIconView::TabContentsProvider implementation: |
| 237 | 239 |
| 238 bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const { | 240 bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const { |
| 239 // This function is queried during the creation of the window as the | 241 // This function is queried during the creation of the window as the |
| 240 // TabIconView we host is initialized, so we need to NULL check the selected | 242 // TabIconView we host is initialized, so we need to NULL check the selected |
| 241 // TabContents because in this condition there is not yet a selected tab. | 243 // WebContents because in this condition there is not yet a selected tab. |
| 242 TabContents* current_tab = browser_view()->GetSelectedTabContents(); | 244 WebContents* current_tab = browser_view()->GetSelectedWebContents(); |
| 243 return current_tab ? current_tab->IsLoading() : false; | 245 return current_tab ? current_tab->IsLoading() : false; |
| 244 } | 246 } |
| 245 | 247 |
| 246 SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() { | 248 SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() { |
| 247 return frame()->widget_delegate()->GetWindowIcon(); | 249 return frame()->widget_delegate()->GetWindowIcon(); |
| 248 } | 250 } |
| 249 | 251 |
| 250 /////////////////////////////////////////////////////////////////////////////// | 252 /////////////////////////////////////////////////////////////////////////////// |
| 251 // AppPanelBrowserFrameView, private: | 253 // AppPanelBrowserFrameView, private: |
| 252 | 254 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 504 } |
| 503 | 505 |
| 504 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width, | 506 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width, |
| 505 int height) const { | 507 int height) const { |
| 506 int top_height = NonClientTopBorderHeight(); | 508 int top_height = NonClientTopBorderHeight(); |
| 507 int border_thickness = NonClientBorderThickness(); | 509 int border_thickness = NonClientBorderThickness(); |
| 508 return gfx::Rect(border_thickness, top_height, | 510 return gfx::Rect(border_thickness, top_height, |
| 509 std::max(0, width - (2 * border_thickness)), | 511 std::max(0, width - (2 * border_thickness)), |
| 510 std::max(0, height - top_height - border_thickness)); | 512 std::max(0, height - top_height - border_thickness)); |
| 511 } | 513 } |
| OLD | NEW |