Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / workspace / workspace_cycler_configuration.cc
blobe9aede2749658e436982841ba265a1dbc192e230
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/wm/workspace/workspace_cycler_configuration.h"
7 #include "ash/ash_switches.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "base/values.h"
12 namespace {
14 ListValue* g_shallower_than_selected_y_offsets = NULL;
15 ListValue* g_deeper_than_selected_y_offsets = NULL;
16 double g_selected_y_offset = 40;
17 double g_selected_scale = 1.0;
18 double g_min_scale = 1.0;
19 double g_max_scale = 1.0;
20 double g_min_brightness = -0.4;
21 double g_background_opacity = 0.8;
22 double g_desktop_workspace_brightness = -0.4;
23 double g_distance_to_initiate_cycling = 4.0;
24 double g_scroll_amount_to_cycle_to_next_workspace = 4.0;
25 double g_cycler_step_animation_duration_ratio = 4.0;
26 double g_start_cycler_animation_duration = 100.0;
27 double g_stop_cycler_animation_duration = 250.0;
29 } // namespace
31 namespace ash {
33 // static
34 bool WorkspaceCyclerConfiguration::IsCyclerEnabled() {
35 return CommandLine::ForCurrentProcess()->HasSwitch(
36 ash::switches::kAshEnableWorkspaceScrubbing);
39 // static
40 bool WorkspaceCyclerConfiguration::IsListProperty(Property property) {
41 return (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS ||
42 property == DEEPER_THAN_SELECTED_Y_OFFSETS);
45 // static
46 void WorkspaceCyclerConfiguration::SetListValue(Property property,
47 const ListValue& list_value) {
48 DCHECK(IsListProperty(property));
49 if (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS)
50 g_shallower_than_selected_y_offsets = list_value.DeepCopy();
51 else if (property == DEEPER_THAN_SELECTED_Y_OFFSETS)
52 g_deeper_than_selected_y_offsets = list_value.DeepCopy();
55 // static
56 void WorkspaceCyclerConfiguration::SetDouble(Property property, double value) {
57 switch (property) {
58 case SHALLOWER_THAN_SELECTED_Y_OFFSETS:
59 case DEEPER_THAN_SELECTED_Y_OFFSETS:
60 NOTREACHED();
61 break;
62 case SELECTED_Y_OFFSET:
63 g_selected_y_offset = value;
64 break;
65 case SELECTED_SCALE:
66 g_selected_scale = value;
67 break;
68 case MIN_SCALE:
69 g_min_scale = value;
70 break;
71 case MAX_SCALE:
72 g_max_scale = value;
73 break;
74 case MIN_BRIGHTNESS:
75 g_min_brightness = value;
76 break;
77 case BACKGROUND_OPACITY:
78 g_background_opacity = value;
79 break;
80 case DESKTOP_WORKSPACE_BRIGHTNESS:
81 g_desktop_workspace_brightness = value;
82 break;
83 case DISTANCE_TO_INITIATE_CYCLING:
84 g_distance_to_initiate_cycling = value;
85 break;
86 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE:
87 g_scroll_amount_to_cycle_to_next_workspace = value;
88 break;
89 case CYCLER_STEP_ANIMATION_DURATION_RATIO:
90 g_cycler_step_animation_duration_ratio = value;
91 break;
92 case START_CYCLER_ANIMATION_DURATION:
93 g_start_cycler_animation_duration = value;
94 break;
95 case STOP_CYCLER_ANIMATION_DURATION:
96 g_stop_cycler_animation_duration = value;
97 break;
101 // static
102 const ListValue& WorkspaceCyclerConfiguration::GetListValue(Property property) {
103 DCHECK(IsListProperty(property));
104 if (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS) {
105 if (!g_shallower_than_selected_y_offsets) {
106 // First time the property is accessed. Initialize it to the default
107 // value.
108 g_shallower_than_selected_y_offsets = new base::ListValue();
109 g_shallower_than_selected_y_offsets->AppendDouble(-40);
110 g_shallower_than_selected_y_offsets->AppendDouble(-32);
111 g_shallower_than_selected_y_offsets->AppendDouble(-20);
113 return *g_shallower_than_selected_y_offsets;
114 } else if (property == DEEPER_THAN_SELECTED_Y_OFFSETS) {
115 if (!g_deeper_than_selected_y_offsets) {
116 // First time the property is accessed. Initialize it to the default
117 // value.
118 g_deeper_than_selected_y_offsets = new base::ListValue();
119 g_deeper_than_selected_y_offsets->AppendDouble(28);
120 g_deeper_than_selected_y_offsets->AppendDouble(20);
122 return *g_deeper_than_selected_y_offsets;
125 NOTREACHED();
126 CR_DEFINE_STATIC_LOCAL(base::ListValue, default_return_value, ());
127 return default_return_value;
130 // static
131 double WorkspaceCyclerConfiguration::GetDouble(Property property) {
132 switch (property) {
133 case SHALLOWER_THAN_SELECTED_Y_OFFSETS:
134 case DEEPER_THAN_SELECTED_Y_OFFSETS:
135 NOTREACHED();
136 return 0;
137 case SELECTED_Y_OFFSET:
138 return g_selected_y_offset;
139 case SELECTED_SCALE:
140 return g_selected_scale;
141 case MIN_SCALE:
142 return g_min_scale;
143 case MAX_SCALE:
144 return g_max_scale;
145 case MIN_BRIGHTNESS:
146 return g_min_brightness;
147 case BACKGROUND_OPACITY:
148 return g_background_opacity;
149 case DESKTOP_WORKSPACE_BRIGHTNESS:
150 return g_desktop_workspace_brightness;
151 case DISTANCE_TO_INITIATE_CYCLING:
152 return g_distance_to_initiate_cycling;
153 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE:
154 return g_scroll_amount_to_cycle_to_next_workspace;
155 case CYCLER_STEP_ANIMATION_DURATION_RATIO:
156 return g_cycler_step_animation_duration_ratio;
157 case START_CYCLER_ANIMATION_DURATION:
158 return g_start_cycler_animation_duration;
159 case STOP_CYCLER_ANIMATION_DURATION:
160 return g_stop_cycler_animation_duration;
162 NOTREACHED();
163 return 0;
166 } // namespace ash