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

Unified Diff: ui/app_list/views/app_list_view.cc

Issue 2934513004: Changed static variable flag to be a bool in the anon namespace. (Closed)
Patch Set: In AppListView: Moved function and variable out of the global scope. In SearchBoxView: Moved variab… Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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 a38c6092e4bd9be4872f4008e16246d1c1d9cb77..5e65200c38abb95578e5427f8c2cc06e9d4883c9 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -75,12 +75,6 @@ constexpr float kAppListOpacity = 0.8;
// The vertical position for the appearing animation of the speech UI.
constexpr float kSpeechUIAppearingPosition = 12;
-bool IsFullscreenAppListEnabled() {
- // Cache this value to avoid repeated lookup.
- static bool cached_value = features::IsFullscreenAppListEnabled();
- return cached_value;
-}
-
// This view forwards the focus to the search box widget by providing it as a
// FocusTraversable when a focus search is provided.
class SearchBoxFocusHost : public views::View {
@@ -202,10 +196,10 @@ AppListView::AppListView(AppListViewDelegate* delegate)
overlay_view_(nullptr),
animation_observer_(new HideViewAnimationObserver()) {
CHECK(delegate);
-
+ IsFullscreenAppListEnabled();
delegate_->GetSpeechUI()->AddObserver(this);
- if (IsFullscreenAppListEnabled())
+ if (is_fullscreen_app_list_enabled_)
display_observer_.Add(display::Screen::GetScreen());
}
@@ -218,12 +212,13 @@ AppListView::~AppListView() {
void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) {
base::Time start_time = base::Time::Now();
+ IsFullscreenAppListEnabled();
InitContents(parent, initial_apps_page);
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
set_color(kContentsBackgroundColor);
set_parent_window(parent);
- if (IsFullscreenAppListEnabled())
+ if (is_fullscreen_app_list_enabled_)
InitializeFullscreen(parent, initial_apps_page);
else
InitializeBubble(parent, initial_apps_page);
@@ -231,7 +226,7 @@ void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) {
InitChildWidgets();
AddChildView(overlay_view_);
- if (IsFullscreenAppListEnabled())
+ if (is_fullscreen_app_list_enabled_)
SetState(app_list_state_);
if (delegate_)
@@ -249,7 +244,7 @@ void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
void AppListView::MaybeSetAnchorPoint(const gfx::Point& anchor_point) {
// if the AppListView is a bubble
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled_)
SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
}
@@ -264,7 +259,7 @@ void AppListView::ShowWhenReady() {
void AppListView::UpdateBounds() {
// if the AppListView is a bubble
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled_)
SizeToContents();
}
@@ -357,7 +352,7 @@ void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"440224, 441028 AppListView::InitContents"));
- if (IsFullscreenAppListEnabled()) {
+ if (is_fullscreen_app_list_enabled_) {
// The shield view that colors the background of the app list and makes it
// transparent.
app_list_background_shield_ = new views::View;
@@ -596,7 +591,7 @@ void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
}
void AppListView::OnMouseEvent(ui::MouseEvent* event) {
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled_)
return;
switch (event->type()) {
@@ -618,7 +613,7 @@ void AppListView::OnMouseEvent(ui::MouseEvent* event) {
}
void AppListView::OnGestureEvent(ui::GestureEvent* event) {
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled_)
return;
switch (event->type()) {
@@ -646,7 +641,7 @@ bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
// If the ContentsView does not handle the back action, then this is the
// top level, so we close the app list.
if (!app_list_main_view_->contents_view()->Back()) {
- if (IsFullscreenAppListEnabled()) {
+ if (is_fullscreen_app_list_enabled_) {
SetState(CLOSED);
} else {
app_list_main_view_->Close();
@@ -681,7 +676,7 @@ void AppListView::Layout() {
speech_view_->SetBoundsRect(speech_bounds);
}
- if (IsFullscreenAppListEnabled()) {
+ if (is_fullscreen_app_list_enabled_) {
app_list_main_view_->contents_view()->Layout();
app_list_background_shield_->SetBoundsRect(contents_bounds);
}
@@ -718,6 +713,11 @@ void AppListView::SetState(AppListState new_state) {
app_list_state_ = new_state;
}
+void AppListView::IsFullscreenAppListEnabled() {
xiyuan 2017/06/12 22:33:15 Get rid of this function and just initialize |is_f
newcomer 2017/06/12 23:48:17 Done.
+ // Cache this value to avoid repeated lookup.
+ is_fullscreen_app_list_enabled_ = features::IsFullscreenAppListEnabled();
+}
+
void AppListView::OnWidgetDestroying(views::Widget* widget) {
BubbleDialogDelegateView::OnWidgetDestroying(widget);
if (delegate_ && widget == GetWidget())
@@ -804,7 +804,7 @@ void AppListView::OnSpeechRecognitionStateChanged(
void AppListView::OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) {
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled_)
return;
// Set the |fullscreen_widget_| size to fit the new display metrics.

Powered by Google App Engine
This is Rietveld 408576698