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

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: Patch to land 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
« no previous file with comments | « chrome/browser/ui/panels/panel_extension_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/panels/panel.h" 12 #include "chrome/browser/ui/panels/panel.h"
13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 13 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
14 #include "chrome/browser/ui/panels/panel_manager.h" 14 #include "chrome/browser/ui/panels/panel_manager.h"
15 #include "chrome/browser/ui/views/panels/panel_frame_view.h" 15 #include "chrome/browser/ui/views/panels/panel_frame_view.h"
16 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 17 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents_view.h" 18 #include "content/public/browser/web_contents_view.h"
19 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/path.h" 20 #include "ui/gfx/path.h"
21 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 #include "ui/views/controls/button/image_button.h" 22 #include "ui/views/controls/button/image_button.h"
23 #include "ui/views/controls/webview/webview.h" 23 #include "ui/views/controls/webview/webview.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 25
26 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) 26 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA)
27 #include "ui/base/win/shell.h"
28 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
29 #include "chrome/browser/shell_integration.h" 28 #include "chrome/browser/shell_integration.h"
30 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h" 29 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h"
30 #include "ui/base/win/shell.h"
31 #include "ui/gfx/icon_util.h"
31 #endif 32 #endif
32 33
33 namespace { 34 namespace {
34 35
35 // Supported accelerators. 36 // Supported accelerators.
36 // Note: We can't use the acclerator table defined in chrome/browser/ui/views 37 // Note: We can't use the acclerator table defined in chrome/browser/ui/views
37 // due to checkdeps violation. 38 // due to checkdeps violation.
38 struct AcceleratorMapping { 39 struct AcceleratorMapping {
39 ui::KeyboardCode keycode; 40 ui::KeyboardCode keycode;
40 int modifiers; 41 int modifiers;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 private: 84 private:
84 virtual void PressLeftMouseButtonTitlebar( 85 virtual void PressLeftMouseButtonTitlebar(
85 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; 86 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE;
86 virtual void ReleaseMouseButtonTitlebar( 87 virtual void ReleaseMouseButtonTitlebar(
87 panel::ClickModifier modifier) OVERRIDE; 88 panel::ClickModifier modifier) OVERRIDE;
88 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE; 89 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE;
89 virtual void CancelDragTitlebar() OVERRIDE; 90 virtual void CancelDragTitlebar() OVERRIDE;
90 virtual void FinishDragTitlebar() OVERRIDE; 91 virtual void FinishDragTitlebar() OVERRIDE;
91 virtual bool VerifyDrawingAttention() const OVERRIDE; 92 virtual bool VerifyDrawingAttention() const OVERRIDE;
92 virtual bool VerifyActiveState(bool is_active) OVERRIDE; 93 virtual bool VerifyActiveState(bool is_active) OVERRIDE;
94 virtual bool VerifyAppIcon() const OVERRIDE;
93 virtual bool IsWindowSizeKnown() const OVERRIDE; 95 virtual bool IsWindowSizeKnown() const OVERRIDE;
94 virtual bool IsAnimatingBounds() const OVERRIDE; 96 virtual bool IsAnimatingBounds() const OVERRIDE;
95 virtual bool IsButtonVisible( 97 virtual bool IsButtonVisible(
96 panel::TitlebarButtonType button_type) const OVERRIDE; 98 panel::TitlebarButtonType button_type) const OVERRIDE;
97 99
98 PanelView* panel_view_; 100 PanelView* panel_view_;
99 }; 101 };
100 102
101 NativePanelTestingWin::NativePanelTestingWin(PanelView* panel_view) 103 NativePanelTestingWin::NativePanelTestingWin(PanelView* panel_view)
102 : panel_view_(panel_view) { 104 : panel_view_(panel_view) {
(...skipping 25 matching lines...) Expand all
128 return panel_view_->GetFrameView()->paint_state() == 130 return panel_view_->GetFrameView()->paint_state() ==
129 PanelFrameView::PAINT_FOR_ATTENTION; 131 PanelFrameView::PAINT_FOR_ATTENTION;
130 } 132 }
131 133
132 bool NativePanelTestingWin::VerifyActiveState(bool is_active) { 134 bool NativePanelTestingWin::VerifyActiveState(bool is_active) {
133 return panel_view_->GetFrameView()->paint_state() == 135 return panel_view_->GetFrameView()->paint_state() ==
134 (is_active ? PanelFrameView::PAINT_AS_ACTIVE 136 (is_active ? PanelFrameView::PAINT_AS_ACTIVE
135 : PanelFrameView::PAINT_AS_INACTIVE); 137 : PanelFrameView::PAINT_AS_INACTIVE);
136 } 138 }
137 139
140 bool NativePanelTestingWin::VerifyAppIcon() const {
141 #if defined(OS_WIN) && !defined(USE_AURA)
142 // We only care about Windows 7 and later.
143 if (base::win::GetVersion() < base::win::VERSION_WIN7)
144 return true;
145
146 HWND native_window = panel_view_->GetNativePanelHandle();
147 HICON app_icon = reinterpret_cast<HICON>(
148 ::SendMessage(native_window, WM_GETICON, ICON_BIG, 0L));
149 if (!app_icon)
150 return false;
151 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(app_icon));
152 return bitmap.get() &&
153 bitmap->width() == panel::kPanelAppIconSize &&
154 bitmap->height() == panel::kPanelAppIconSize;
155 #else
156 return true;
157 #endif
158 }
159
138 bool NativePanelTestingWin::IsWindowSizeKnown() const { 160 bool NativePanelTestingWin::IsWindowSizeKnown() const {
139 return true; 161 return true;
140 } 162 }
141 163
142 bool NativePanelTestingWin::IsAnimatingBounds() const { 164 bool NativePanelTestingWin::IsAnimatingBounds() const {
143 return panel_view_->IsAnimatingBounds(); 165 return panel_view_->IsAnimatingBounds();
144 } 166 }
145 167
146 bool NativePanelTestingWin::IsButtonVisible( 168 bool NativePanelTestingWin::IsButtonVisible(
147 panel::TitlebarButtonType button_type) const { 169 panel::TitlebarButtonType button_type) const {
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 int height = web_view_->size().height(); 805 int height = web_view_->size().height();
784 SkRegion* region = new SkRegion; 806 SkRegion* region = new SkRegion;
785 region->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op); 807 region->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op);
786 region->op(width - kResizeInsideBoundsSize, 0, width, height, 808 region->op(width - kResizeInsideBoundsSize, 0, width, height,
787 SkRegion::kUnion_Op); 809 SkRegion::kUnion_Op);
788 region->op(0, height - kResizeInsideBoundsSize, width, height, 810 region->op(0, height - kResizeInsideBoundsSize, width, height,
789 SkRegion::kUnion_Op); 811 SkRegion::kUnion_Op);
790 web_contents->GetRenderViewHost()->GetView()->SetClickthroughRegion(region); 812 web_contents->GetRenderViewHost()->GetView()->SetClickthroughRegion(region);
791 #endif 813 #endif
792 } 814 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_extension_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698