Home | History | Annotate | Download | only in browser
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.browser;
     18 
     19 import com.android.internal.preference.YesNoPreference;
     20 
     21 import android.content.Context;
     22 import android.util.AttributeSet;
     23 
     24 class BrowserYesNoPreference extends YesNoPreference {
     25 
     26     // This is the constructor called by the inflater
     27     public BrowserYesNoPreference(Context context, AttributeSet attrs) {
     28         super(context, attrs);
     29     }
     30 
     31     @Override
     32     protected void onDialogClosed(boolean positiveResult) {
     33         super.onDialogClosed(positiveResult);
     34 
     35         if (positiveResult) {
     36             setEnabled(false);
     37 
     38             BrowserSettings settings = BrowserSettings.getInstance();
     39             if (PreferenceKeys.PREF_PRIVACY_CLEAR_CACHE.equals(getKey())) {
     40                 settings.clearCache();
     41                 settings.clearDatabases();
     42             } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_COOKIES.equals(getKey())) {
     43                 settings.clearCookies();
     44             } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_HISTORY.equals(getKey())) {
     45                 settings.clearHistory();
     46             } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_FORM_DATA.equals(getKey())) {
     47                 settings.clearFormData();
     48             } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_PASSWORDS.equals(getKey())) {
     49                 settings.clearPasswords();
     50             } else if (PreferenceKeys.PREF_RESET_DEFAULT_PREFERENCES.equals(
     51                     getKey())) {
     52                 settings.resetDefaultPreferences();
     53                 setEnabled(true);
     54             } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_GEOLOCATION_ACCESS.equals(
     55                     getKey())) {
     56                 settings.clearLocationAccess();
     57             }
     58         }
     59     }
     60 }
     61