| OLD | NEW |
| 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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #endif | 43 #endif |
| 44 #if !defined(OS_CHROMEOS) | 44 #if !defined(OS_CHROMEOS) |
| 45 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 45 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 46 #endif | 46 #endif |
| 47 #endif // defined(USE_AURA) | 47 #endif // defined(USE_AURA) |
| 48 | 48 |
| 49 namespace app_list { | 49 namespace app_list { |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 void (*g_next_paint_callback)(); | 53 // For UMA and testing. If non-null, triggered when the app list is painted. |
| 54 base::Closure g_next_paint_callback; |
| 54 | 55 |
| 55 // The margin from the edge to the speech UI. | 56 // The margin from the edge to the speech UI. |
| 56 const int kSpeechUIMargin = 12; | 57 const int kSpeechUIMargin = 12; |
| 57 | 58 |
| 58 // The vertical position for the appearing animation of the speech UI. | 59 // The vertical position for the appearing animation of the speech UI. |
| 59 const float kSpeechUIAppearingPosition = 12; | 60 const float kSpeechUIAppearingPosition = 12; |
| 60 | 61 |
| 61 // The distance between the arrow tip and edge of the anchor view. | 62 // The distance between the arrow tip and edge of the anchor view. |
| 62 const int kArrowOffset = 10; | 63 const int kArrowOffset = 10; |
| 63 | 64 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void AppListView::UpdateBounds() { | 193 void AppListView::UpdateBounds() { |
| 193 SizeToContents(); | 194 SizeToContents(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 gfx::Size AppListView::GetPreferredSize() { | 197 gfx::Size AppListView::GetPreferredSize() { |
| 197 return app_list_main_view_->GetPreferredSize(); | 198 return app_list_main_view_->GetPreferredSize(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void AppListView::Paint(gfx::Canvas* canvas) { | 201 void AppListView::Paint(gfx::Canvas* canvas) { |
| 201 views::BubbleDelegateView::Paint(canvas); | 202 views::BubbleDelegateView::Paint(canvas); |
| 202 if (g_next_paint_callback) { | 203 if (!g_next_paint_callback.is_null()) { |
| 203 g_next_paint_callback(); | 204 g_next_paint_callback.Run(); |
| 204 g_next_paint_callback = NULL; | 205 g_next_paint_callback.Reset(); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 | 208 |
| 208 void AppListView::OnThemeChanged() { | 209 void AppListView::OnThemeChanged() { |
| 209 #if defined(OS_WIN) | 210 #if defined(OS_WIN) |
| 210 GetWidget()->Close(); | 211 GetWidget()->Close(); |
| 211 #endif | 212 #endif |
| 212 } | 213 } |
| 213 | 214 |
| 214 bool AppListView::ShouldHandleSystemCommands() const { | 215 bool AppListView::ShouldHandleSystemCommands() const { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 236 | 237 |
| 237 void AppListView::AddObserver(AppListViewObserver* observer) { | 238 void AppListView::AddObserver(AppListViewObserver* observer) { |
| 238 observers_.AddObserver(observer); | 239 observers_.AddObserver(observer); |
| 239 } | 240 } |
| 240 | 241 |
| 241 void AppListView::RemoveObserver(AppListViewObserver* observer) { | 242 void AppListView::RemoveObserver(AppListViewObserver* observer) { |
| 242 observers_.RemoveObserver(observer); | 243 observers_.RemoveObserver(observer); |
| 243 } | 244 } |
| 244 | 245 |
| 245 // static | 246 // static |
| 246 void AppListView::SetNextPaintCallback(void (*callback)()) { | 247 void AppListView::SetNextPaintCallback(const base::Closure& callback) { |
| 247 g_next_paint_callback = callback; | 248 g_next_paint_callback = callback; |
| 248 } | 249 } |
| 249 | 250 |
| 250 #if defined(OS_WIN) | 251 #if defined(OS_WIN) |
| 251 HWND AppListView::GetHWND() const { | 252 HWND AppListView::GetHWND() const { |
| 252 #if defined(USE_AURA) | 253 #if defined(USE_AURA) |
| 253 gfx::NativeWindow window = | 254 gfx::NativeWindow window = |
| 254 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 255 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 255 return window->GetHost()->GetAcceleratedWidget(); | 256 return window->GetHost()->GetAcceleratedWidget(); |
| 256 #else | 257 #else |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 #else | 504 #else |
| 504 speech_view_->SetVisible(recognizing); | 505 speech_view_->SetVisible(recognizing); |
| 505 app_list_main_view_->SetVisible(!recognizing); | 506 app_list_main_view_->SetVisible(!recognizing); |
| 506 | 507 |
| 507 // Needs to schedule paint of AppListView itself, to repaint the background. | 508 // Needs to schedule paint of AppListView itself, to repaint the background. |
| 508 GetBubbleFrameView()->SchedulePaint(); | 509 GetBubbleFrameView()->SchedulePaint(); |
| 509 #endif | 510 #endif |
| 510 } | 511 } |
| 511 | 512 |
| 512 } // namespace app_list | 513 } // namespace app_list |
| OLD | NEW |