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 = 50.f;
     15 float g_vert_threshold_start = 0.f;
     16 
     17 float g_horiz_resist_after = 30.f;
     18 float g_vert_resist_after = 30.f;
     19 
     20 }
     21 
     22 namespace content {
     23 
     24 void SetOverscrollConfig(OverscrollConfig config, float value) {
     25   switch (config) {
     26     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE:
     27       g_horiz_threshold_complete = value;
     28       break;
     29 
     30     case OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE:
     31       g_vert_threshold_complete = value;
     32       break;
     33 
     34     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START:
     35       g_horiz_threshold_start = value;
     36       break;
     37 
     38     case OVERSCROLL_CONFIG_VERT_THRESHOLD_START:
     39       g_vert_threshold_start = value;
     40       break;
     41 
     42     case OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER:
     43       g_horiz_resist_after = value;
     44       break;
     45 
     46     case OVERSCROLL_CONFIG_VERT_RESIST_AFTER:
     47       g_vert_resist_after = value;
     48       break;
     49 
     50     case OVERSCROLL_CONFIG_NONE:
     51     case OVERSCROLL_CONFIG_COUNT:
     52       NOTREACHED();
     53   }
     54 }
     55 
     56 float GetOverscrollConfig(OverscrollConfig config) {
     57   switch (config) {
     58     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE:
     59       return g_horiz_threshold_complete;
     60 
     61     case OVERSCROLL_CONFIG_VERT_THRESHOLD_COMPLETE:
     62       return g_vert_threshold_complete;
     63 
     64     case OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START:
     65       return g_horiz_threshold_start;
     66 
     67     case OVERSCROLL_CONFIG_VERT_THRESHOLD_START:
     68       return g_vert_threshold_start;
     69 
     70     case OVERSCROLL_CONFIG_HORIZ_RESIST_AFTER:
     71       return g_horiz_resist_after;
     72 
     73     case OVERSCROLL_CONFIG_VERT_RESIST_AFTER:
     74       return g_vert_resist_after;
     75 
     76     case OVERSCROLL_CONFIG_NONE:
     77     case OVERSCROLL_CONFIG_COUNT:
     78       NOTREACHED();
     79   }
     80 
     81   return -1.f;
     82 }
     83 
     84 }  // namespace content
     85