Index: ui/app_list/views/app_list_view.cc |
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc |
index 2a1be91f97cb2a39c98e458b0cd518b89c0b5d5e..aa91ec6720fa35aece8fc90b4af20adf0f4dfbd8 100644 |
--- a/ui/app_list/views/app_list_view.cc |
+++ b/ui/app_list/views/app_list_view.cc |
@@ -124,15 +124,18 @@ class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter { |
DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); |
}; |
+// Returns whether the fullscreen app list has been enabled via cmd line switch. |
+bool IsFullscreenAppListEnabled() { |
+ return base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableFullscreenAppList); |
+} |
+ |
} // namespace |
// An animation observer to hide the view at the end of the animation. |
class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { |
public: |
- HideViewAnimationObserver() |
- : frame_(NULL), |
- target_(NULL) { |
- } |
+ HideViewAnimationObserver() : frame_(NULL), target_(NULL) {} |
~HideViewAnimationObserver() override { |
if (target_) |
@@ -190,39 +193,45 @@ AppListView::~AppListView() { |
RemoveAllChildViews(true); |
} |
-void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { |
+void AppListView::Initialize(gfx::NativeView parent, |
+ int initial_apps_page, |
+ const gfx::Rect& display_work_area_bounds) { |
base::Time start_time = base::Time::Now(); |
- |
InitContents(parent, initial_apps_page); |
- |
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
- set_margins(gfx::Insets()); |
- set_parent_window(parent); |
- set_close_on_deactivate(false); |
- set_shadow(views::BubbleBorder::NO_ASSETS); |
set_color(kContentsBackgroundColor); |
- // This creates the app list widget. (Before this, child widgets cannot be |
- // created.) |
- views::BubbleDialogDelegateView::CreateBubble(this); |
- SetBubbleArrow(views::BubbleBorder::FLOAT); |
- // We can now create the internal widgets. |
+ if (IsFullscreenAppListEnabled()) { |
+ InitializeFullscreen(parent, initial_apps_page, |
+ display_work_area_bounds); |
vadimt
2017/04/20 20:21:35
indentation....
sky
2017/04/20 21:08:45
I think if you run git cl format it'll fix all the
newcomer
2017/04/21 19:51:22
I gave it a shot!
|
+ } else { |
+ InitializeBubble(parent, initial_apps_page); |
+ } |
+ |
InitChildWidgets(); |
+ AddChildView(overlay_view_); |
+ if (delegate_) |
+ delegate_->ViewInitialized(); |
+ UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", |
+ base::Time::Now() - start_time); |
+} |
- aura::Window* window = GetWidget()->GetNativeWindow(); |
- window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this)); |
+void AppListView::Initialize(gfx::NativeView parent, |
+ int initial_apps_page){ |
+ base::Time start_time = base::Time::Now(); |
- const int kOverlayCornerRadius = |
- GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
- overlay_view_ = new AppListOverlayView(kOverlayCornerRadius); |
- overlay_view_->SetBoundsRect(GetContentsBounds()); |
+ InitContents(parent, initial_apps_page); |
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
+ set_color(kContentsBackgroundColor); |
+ InitializeBubble(parent, initial_apps_page); |
+ InitChildWidgets(); |
AddChildView(overlay_view_); |
if (delegate_) |
delegate_->ViewInitialized(); |
UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", |
- base::Time::Now() - start_time); |
+ base::Time::Now() - start_time); |
} |
void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { |
@@ -231,8 +240,12 @@ void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { |
GetBubbleFrameView()->SchedulePaint(); |
} |
-void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { |
- SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
+void AppListView::MaybeSetAnchorPoint(const gfx::Point& anchor_point) { |
+ // if the AppListView is a bubble |
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ app_list::switches::kEnableFullscreenAppList)) { |
+ SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
+ } |
} |
void AppListView::SetDragAndDropHostOfCurrentAppList( |
@@ -250,7 +263,11 @@ void AppListView::CloseAppList() { |
} |
void AppListView::UpdateBounds() { |
- SizeToContents(); |
+ // if the AppListView is a bubble |
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ app_list::switches::kEnableFullscreenAppList)) { |
+ SizeToContents(); |
+ } |
} |
void AppListView::SetAppListOverlayVisible(bool visible) { |
@@ -304,6 +321,10 @@ void AppListView::OnPaint(gfx::Canvas* canvas) { |
} |
} |
+const char* AppListView::GetClassName() const { |
+ return "AppListView"; |
+} |
+ |
bool AppListView::ShouldHandleSystemCommands() const { |
return true; |
} |
@@ -343,7 +364,6 @@ void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { |
app_list_main_view_->SetPaintToLayer(); |
app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); |
app_list_main_view_->layer()->SetMasksToBounds(true); |
- |
// This will be added to the |search_box_widget_| after the app list widget is |
// initialized. |
search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); |
@@ -410,9 +430,52 @@ void AppListView::InitChildWidgets() { |
app_list_main_view_->contents_view()->Layout(); |
} |
-void AppListView::OnBeforeBubbleWidgetInit( |
- views::Widget::InitParams* params, |
- views::Widget* widget) const { |
+void AppListView::InitializeFullscreen( |
+ gfx::NativeView parent, |
+ int initial_apps_page, |
+ const gfx::Rect& display_work_area_bounds) { |
+ |
+ views::Widget* widget = new views::Widget; |
+ views::Widget::InitParams app_list_overlay_view_params( |
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
+ |
+ app_list_overlay_view_params.parent = parent; |
+ app_list_overlay_view_params.delegate = this; |
+ |
+ widget->Init(app_list_overlay_view_params); |
+ widget->SetBounds(display_work_area_bounds); |
+ widget->GetLayer()->SetFillsBoundsOpaquely(false); |
+ widget->GetLayer()->SetBackgroundBlur(10); |
+ |
+ overlay_view_ = new AppListOverlayView(0 /* no corners */); |
+} |
+ |
+void AppListView::InitializeBubble(gfx::NativeView parent, |
+ int initial_apps_page) { |
+ set_margins(gfx::Insets()); |
+ set_parent_window(parent); |
+ set_close_on_deactivate(false); |
+ set_shadow(views::BubbleBorder::NO_ASSETS); |
+ |
+ |
+ // This creates the app list widget. (Before this, child widgets cannot be |
+ // created.) |
+ views::BubbleDialogDelegateView::CreateBubble(this); |
+ |
+ SetBubbleArrow(views::BubbleBorder::FLOAT); |
+ // We can now create the internal widgets. |
+ |
+ aura::Window* window = GetWidget()->GetNativeWindow(); |
+ window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this)); |
+ |
+ const int kOverlayCornerRadius = |
+ GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
+ overlay_view_ = new AppListOverlayView(kOverlayCornerRadius); |
+ overlay_view_->SetBoundsRect(GetContentsBounds()); |
+} |
+ |
+void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, |
+ views::Widget* widget) const { |
if (!params->native_widget) { |
views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); |
if (views_delegate && !views_delegate->native_widget_factory().is_null()) { |
@@ -441,8 +504,7 @@ void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const { |
DCHECK(mask); |
DCHECK(GetBubbleFrameView()); |
- mask->addRect(gfx::RectToSkRect( |
- GetBubbleFrameView()->GetContentsBounds())); |
+ mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds())); |
} |
bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
@@ -475,8 +537,8 @@ void AppListView::Layout() { |
gfx::Rect speech_bounds = centered_bounds; |
int preferred_height = speech_view_->GetPreferredSize().height(); |
speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); |
- speech_bounds.set_height(std::min(speech_bounds.height(), |
- preferred_height)); |
+ speech_bounds.set_height( |
+ std::min(speech_bounds.height(), preferred_height)); |
speech_bounds.Inset(-speech_view_->GetInsets()); |
speech_view_->SetBoundsRect(speech_bounds); |
} |
@@ -522,8 +584,7 @@ void AppListView::OnSpeechRecognitionStateChanged( |
animation_observer_->set_frame(GetBubbleFrameView()); |
gfx::Transform speech_transform; |
- speech_transform.Translate( |
- 0, SkFloatToMScalar(kSpeechUIAppearingPosition)); |
+ speech_transform.Translate(0, SkFloatToMScalar(kSpeechUIAppearingPosition)); |
if (will_appear) |
speech_view_->layer()->SetTransform(speech_transform); |