Home | History | Annotate | Download | only in renderer_host
      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
      3 // found in the LICENSE file.
      4 
      5 #include "content/public/browser/overscroll_configuration.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace {
     10 
     11 float g_horiz_threshold_complete = 0.25f;
     12 float g_vert_threshold_complete = 0.20f;
     13 
     14 float g_horiz_threshold_start_touchscreen = 50.f;
     15 float g_horiz_threshold_start_touchpad = 50.f;
     16 float g_vert_threshold_start = 0.f;
     17 
     18 float g_horiz_resist_after = 30.f;
     19 float g_vert_resist_after = 30.f;
     20 
     21 }
     22 
     23 namespace content {
     24 
     25 void SetOverscrollConfig(OverscrollConfig config, float value) {
     26   switch (config) {
     27     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE:
     28       g_horiz_threshold_complete = value;
     29       break;
     30 
     31     case OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE:
     32       g_vert_threshold_complete = value;
     33       break;
     34 
     35     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN:
     36       g_horiz_threshold_start_touchscreen = value;
     37       break;
     38 
     39     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD:
     40       g_horiz_threshold_start_touchpad = value;
     41       break;
     42 
     43     case OVERSCROLL_CONFIG_VERT_THRESHOLD_START:
     44       g_vert_threshold_start = value;
     45       break;
     46 
     47     case OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER:
     48       g_horiz_resist_after = value;
     49       break;
     50 
     51     case OVERSCROLL_CONFIG_VERT_RESIST_AFTER:
     52       g_vert_resist_after = value;
     53       break;
     54 
     55     case OVERSCROLL_CONFIG_NONE:
     56     case OVERSCROLL_CONFIG_COUNT:
     57       NOTREACHED();
     58   }
     59 }
     60 
     61 float GetOverscrollConfig(OverscrollConfig config) {
     62   switch (config) {
     63     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE:
     64       return g_horiz_threshold_complete;
     65 
     66     case OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE:
     67       return g_vert_threshold_complete;
     68 
     69     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN:
     70       return g_horiz_threshold_start_touchscreen;
     71 
     72     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD:
     73       return g_horiz_threshold_start_touchpad;
     74 
     75     case OVERSCROLL_CONFIG_VERT_THRESHOLD_START:
     76       return g_vert_threshold_start;
     77 
     78     case OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER:
     79       return g_horiz_resist_after;
     80 
     81     case OVERSCROLL_CONFIG_VERT_RESIST_AFTER:
     82       return g_vert_resist_after;
     83 
     84     case OVERSCROLL_CONFIG_NONE:
     85     case OVERSCROLL_CONFIG_COUNT:
     86       NOTREACHED();
     87   }
     88 
     89   return -1.f;
     90 }
     91 
     92 }  // namespace content
     93