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

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: 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
« no previous file with comments | « no previous file | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9379e55c88fa8b40ae9af739aabea3e61ad61d81 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -75,10 +75,13 @@ constexpr float kAppListOpacity = 0.8;
// The vertical position for the appearing animation of the speech UI.
constexpr float kSpeechUIAppearingPosition = 12;
-bool IsFullscreenAppListEnabled() {
+// The switch that is checked to determine if the fullscreen app list feature is
+// enabled.
+bool is_fullscreen_app_list_enabled;
xiyuan 2017/06/12 17:24:38 I'd say make this a member of the class that needs
vadimt 2017/06/12 18:16:57 +1. Please don't add non-const global variables.
newcomer 2017/06/12 22:25:58 Done.
newcomer 2017/06/12 22:25:58 Done.
+
+void IsFullscreenAppListEnabled() {
// Cache this value to avoid repeated lookup.
- static bool cached_value = features::IsFullscreenAppListEnabled();
- return cached_value;
+ is_fullscreen_app_list_enabled = features::IsFullscreenAppListEnabled();
}
// This view forwards the focus to the search box widget by providing it as a
@@ -205,7 +208,7 @@ AppListView::AppListView(AppListViewDelegate* delegate)
delegate_->GetSpeechUI()->AddObserver(this);
- if (IsFullscreenAppListEnabled())
+ if (is_fullscreen_app_list_enabled)
display_observer_.Add(display::Screen::GetScreen());
}
@@ -218,12 +221,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 +235,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 +253,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 +268,7 @@ void AppListView::ShowWhenReady() {
void AppListView::UpdateBounds() {
// if the AppListView is a bubble
- if (!IsFullscreenAppListEnabled())
+ if (!is_fullscreen_app_list_enabled)
SizeToContents();
}
@@ -357,7 +361,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 +600,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 +622,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 +650,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 +685,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);
}
@@ -804,7 +808,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.
« no previous file with comments | « no previous file | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698