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

Side by Side Diff: chrome/browser/ui/views/panels/panel_view.cc

Issue 10987037: Add tests for panel app icon functionaility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix builds 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/panels/panel_view.h" 5 #include "chrome/browser/ui/views/panels/panel_view.h"
6 6
7 #include <map> 7 #include <map>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/win/windows_version.h"
10 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/panels/panel.h" 13 #include "chrome/browser/ui/panels/panel.h"
13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 14 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
14 #include "chrome/browser/ui/panels/panel_manager.h" 15 #include "chrome/browser/ui/panels/panel_manager.h"
15 #include "chrome/browser/ui/views/panels/panel_frame_view.h" 16 #include "chrome/browser/ui/views/panels/panel_frame_view.h"
16 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents_view.h" 19 #include "content/public/browser/web_contents_view.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/path.h" 21 #include "ui/gfx/path.h"
21 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
22 #include "ui/views/controls/button/image_button.h" 23 #include "ui/views/controls/button/image_button.h"
23 #include "ui/views/controls/webview/webview.h" 24 #include "ui/views/controls/webview/webview.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 26
26 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) 27 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA)
27 #include "ui/base/win/shell.h"
28 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
29 #include "chrome/browser/shell_integration.h" 29 #include "chrome/browser/shell_integration.h"
30 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h" 30 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h"
31 #include "ui/base/win/shell.h"
32 #include "ui/gfx/icon_util.h"
31 #endif 33 #endif
32 34
33 namespace { 35 namespace {
34 36
35 // Supported accelerators. 37 // Supported accelerators.
36 // Note: We can't use the acclerator table defined in chrome/browser/ui/views 38 // Note: We can't use the acclerator table defined in chrome/browser/ui/views
37 // due to checkdeps violation. 39 // due to checkdeps violation.
38 struct AcceleratorMapping { 40 struct AcceleratorMapping {
39 ui::KeyboardCode keycode; 41 ui::KeyboardCode keycode;
40 int modifiers; 42 int modifiers;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 private: 85 private:
84 virtual void PressLeftMouseButtonTitlebar( 86 virtual void PressLeftMouseButtonTitlebar(
85 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; 87 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE;
86 virtual void ReleaseMouseButtonTitlebar( 88 virtual void ReleaseMouseButtonTitlebar(
87 panel::ClickModifier modifier) OVERRIDE; 89 panel::ClickModifier modifier) OVERRIDE;
88 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE; 90 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE;
89 virtual void CancelDragTitlebar() OVERRIDE; 91 virtual void CancelDragTitlebar() OVERRIDE;
90 virtual void FinishDragTitlebar() OVERRIDE; 92 virtual void FinishDragTitlebar() OVERRIDE;
91 virtual bool VerifyDrawingAttention() const OVERRIDE; 93 virtual bool VerifyDrawingAttention() const OVERRIDE;
92 virtual bool VerifyActiveState(bool is_active) OVERRIDE; 94 virtual bool VerifyActiveState(bool is_active) OVERRIDE;
95 virtual bool VerifyAppIcon() const OVERRIDE;
93 virtual bool IsWindowSizeKnown() const OVERRIDE; 96 virtual bool IsWindowSizeKnown() const OVERRIDE;
94 virtual bool IsAnimatingBounds() const OVERRIDE; 97 virtual bool IsAnimatingBounds() const OVERRIDE;
95 virtual bool IsButtonVisible( 98 virtual bool IsButtonVisible(
96 panel::TitlebarButtonType button_type) const OVERRIDE; 99 panel::TitlebarButtonType button_type) const OVERRIDE;
97 100
98 PanelView* panel_view_; 101 PanelView* panel_view_;
99 }; 102 };
100 103
101 NativePanelTestingWin::NativePanelTestingWin(PanelView* panel_view) 104 NativePanelTestingWin::NativePanelTestingWin(PanelView* panel_view)
102 : panel_view_(panel_view) { 105 : panel_view_(panel_view) {
(...skipping 25 matching lines...) Expand all
128 return panel_view_->GetFrameView()->paint_state() == 131 return panel_view_->GetFrameView()->paint_state() ==
129 PanelFrameView::PAINT_FOR_ATTENTION; 132 PanelFrameView::PAINT_FOR_ATTENTION;
130 } 133 }
131 134
132 bool NativePanelTestingWin::VerifyActiveState(bool is_active) { 135 bool NativePanelTestingWin::VerifyActiveState(bool is_active) {
133 return panel_view_->GetFrameView()->paint_state() == 136 return panel_view_->GetFrameView()->paint_state() ==
134 (is_active ? PanelFrameView::PAINT_AS_ACTIVE 137 (is_active ? PanelFrameView::PAINT_AS_ACTIVE
135 : PanelFrameView::PAINT_AS_INACTIVE); 138 : PanelFrameView::PAINT_AS_INACTIVE);
136 } 139 }
137 140
141 bool NativePanelTestingWin::VerifyAppIcon() const {
142 #if defined(OS_WIN) && !defined(USE_AURA)
jennb 2012/10/02 17:51:08 Should this be USE_ASH? Aura is the hw accelerate
jianli 2012/10/02 21:37:26 This should be USE_AURA since there could be a bui
143 // We only care about Windows 7 and later.
144 if (base::win::GetVersion() < base::win::VERSION_WIN7)
145 return true;
146
147 HWND native_window = panel_view_->GetNativePanelHandle();
148 HICON app_icon = reinterpret_cast<HICON>(
149 ::SendMessage(native_window, WM_GETICON, ICON_BIG, 0L));
150 if (!app_icon)
151 return false;
152 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(app_icon));
153 return bitmap.get() && bitmap->width() == 32 && bitmap->height() == 32;
154 #else
155 return true;
156 #endif
157 }
158
138 bool NativePanelTestingWin::IsWindowSizeKnown() const { 159 bool NativePanelTestingWin::IsWindowSizeKnown() const {
139 return true; 160 return true;
140 } 161 }
141 162
142 bool NativePanelTestingWin::IsAnimatingBounds() const { 163 bool NativePanelTestingWin::IsAnimatingBounds() const {
143 return panel_view_->IsAnimatingBounds(); 164 return panel_view_->IsAnimatingBounds();
144 } 165 }
145 166
146 bool NativePanelTestingWin::IsButtonVisible( 167 bool NativePanelTestingWin::IsButtonVisible(
147 panel::TitlebarButtonType button_type) const { 168 panel::TitlebarButtonType button_type) const {
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 int height = web_view_->size().height(); 804 int height = web_view_->size().height();
784 SkRegion* region = new SkRegion; 805 SkRegion* region = new SkRegion;
785 region->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op); 806 region->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op);
786 region->op(width - kResizeInsideBoundsSize, 0, width, height, 807 region->op(width - kResizeInsideBoundsSize, 0, width, height,
787 SkRegion::kUnion_Op); 808 SkRegion::kUnion_Op);
788 region->op(0, height - kResizeInsideBoundsSize, width, height, 809 region->op(0, height - kResizeInsideBoundsSize, width, height,
789 SkRegion::kUnion_Op); 810 SkRegion::kUnion_Op);
790 web_contents->GetRenderViewHost()->GetView()->SetClickthroughRegion(region); 811 web_contents->GetRenderViewHost()->GetView()->SetClickthroughRegion(region);
791 #endif 812 #endif
792 } 813 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698