Home | History | Annotate | Download | only in common
      1 // Copyright 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.
      4 //
      5 // A struct for managing webkit's settings.
      6 //
      7 // Adding new values to this class probably involves updating
      8 // blink::WebSettings, content/common/view_messages.h, browser/tab_contents/
      9 // render_view_host_delegate_helper.cc, and browser/profiles/profile.cc.
     10 
     11 #ifndef WEBKIT_COMMON_WEBPREFERENCES_H__
     12 #define WEBKIT_COMMON_WEBPREFERENCES_H__
     13 
     14 #include <map>
     15 #include <string>
     16 #include <vector>
     17 
     18 #include "base/strings/string16.h"
     19 #include "net/base/network_change_notifier.h"
     20 #include "url/gurl.h"
     21 #include "webkit/common/webkit_common_export.h"
     22 
     23 namespace blink {
     24 class WebView;
     25 }
     26 
     27 struct WebPreferences;
     28 
     29 namespace webkit_glue {
     30 
     31 // Map of ISO 15924 four-letter script code to font family.  For example,
     32 // "Arab" to "My Arabic Font".
     33 typedef std::map<std::string, base::string16> ScriptFontFamilyMap;
     34 
     35 typedef std::vector<std::pair<std::string, std::string> >
     36     WebInspectorPreferences;
     37 
     38 enum EditingBehavior {
     39   EDITING_BEHAVIOR_MAC,
     40   EDITING_BEHAVIOR_WIN,
     41   EDITING_BEHAVIOR_UNIX,
     42   EDITING_BEHAVIOR_ANDROID,
     43   EDITING_BEHAVIOR_LAST = EDITING_BEHAVIOR_ANDROID
     44 };
     45 
     46 
     47 // The ISO 15924 script code for undetermined script aka Common. It's the
     48 // default used on WebKit's side to get/set a font setting when no script is
     49 // specified.
     50 WEBKIT_COMMON_EXPORT extern const char kCommonScript[];
     51 
     52 }  // namespace webkit_glue
     53 
     54 struct WEBKIT_COMMON_EXPORT WebPreferences {
     55   webkit_glue::ScriptFontFamilyMap standard_font_family_map;
     56   webkit_glue::ScriptFontFamilyMap fixed_font_family_map;
     57   webkit_glue::ScriptFontFamilyMap serif_font_family_map;
     58   webkit_glue::ScriptFontFamilyMap sans_serif_font_family_map;
     59   webkit_glue::ScriptFontFamilyMap cursive_font_family_map;
     60   webkit_glue::ScriptFontFamilyMap fantasy_font_family_map;
     61   webkit_glue::ScriptFontFamilyMap pictograph_font_family_map;
     62   int default_font_size;
     63   int default_fixed_font_size;
     64   int minimum_font_size;
     65   int minimum_logical_font_size;
     66   std::string default_encoding;
     67   bool javascript_enabled;
     68   bool web_security_enabled;
     69   bool javascript_can_open_windows_automatically;
     70   bool loads_images_automatically;
     71   bool images_enabled;
     72   bool plugins_enabled;
     73   bool dom_paste_enabled;
     74   webkit_glue::WebInspectorPreferences inspector_settings;
     75   bool site_specific_quirks_enabled;
     76   bool shrinks_standalone_images_to_fit;
     77   bool uses_universal_detector;
     78   bool text_areas_are_resizable;
     79   bool java_enabled;
     80   bool allow_scripts_to_close_windows;
     81   bool remote_fonts_enabled;
     82   bool javascript_can_access_clipboard;
     83   bool xslt_enabled;
     84   bool xss_auditor_enabled;
     85   // We don't use dns_prefetching_enabled to disable DNS prefetching.  Instead,
     86   // we disable the feature at a lower layer so that we catch non-WebKit uses
     87   // of DNS prefetch as well.
     88   bool dns_prefetching_enabled;
     89   bool local_storage_enabled;
     90   bool databases_enabled;
     91   bool application_cache_enabled;
     92   bool tabs_to_links;
     93   bool caret_browsing_enabled;
     94   bool hyperlink_auditing_enabled;
     95   bool is_online;
     96   net::NetworkChangeNotifier::ConnectionType connection_type;
     97   bool allow_universal_access_from_file_urls;
     98   bool allow_file_access_from_file_urls;
     99   bool webaudio_enabled;
    100   bool experimental_webgl_enabled;
    101   bool pepper_3d_enabled;
    102   bool flash_3d_enabled;
    103   bool flash_stage3d_enabled;
    104   bool flash_stage3d_baseline_enabled;
    105   bool gl_multisampling_enabled;
    106   bool privileged_webgl_extensions_enabled;
    107   bool webgl_errors_to_console_enabled;
    108   bool mock_scrollbars_enabled;
    109   bool layer_squashing_enabled;
    110   bool asynchronous_spell_checking_enabled;
    111   bool unified_textchecker_enabled;
    112   bool accelerated_compositing_for_video_enabled;
    113   bool accelerated_2d_canvas_enabled;
    114   int minimum_accelerated_2d_canvas_size;
    115   bool antialiased_2d_canvas_disabled;
    116   int accelerated_2d_canvas_msaa_sample_count;
    117   bool accelerated_filters_enabled;
    118   bool deferred_filters_enabled;
    119   bool container_culling_enabled;
    120   bool gesture_tap_highlight_enabled;
    121   bool allow_displaying_insecure_content;
    122   bool allow_running_insecure_content;
    123   bool password_echo_enabled;
    124   bool should_print_backgrounds;
    125   bool should_clear_document_background;
    126   bool enable_scroll_animator;
    127   bool css_variables_enabled;
    128   bool region_based_columns_enabled;
    129   bool touch_enabled;
    130   bool device_supports_touch;
    131   bool device_supports_mouse;
    132   bool touch_adjustment_enabled;
    133   int pointer_events_max_touch_points;
    134   bool sync_xhr_in_documents_enabled;
    135   bool deferred_image_decoding_enabled;
    136   bool should_respect_image_orientation;
    137   int number_of_cpu_cores;
    138   webkit_glue::EditingBehavior editing_behavior;
    139   bool supports_multiple_windows;
    140   bool viewport_enabled;
    141   bool viewport_meta_enabled;
    142   bool main_frame_resizes_are_orientation_changes;
    143   bool initialize_at_minimum_page_scale;
    144   bool smart_insert_delete_enabled;
    145   bool spatial_navigation_enabled;
    146   bool pinch_virtual_viewport_enabled;
    147   int pinch_overlay_scrollbar_thickness;
    148   bool use_solid_color_scrollbars;
    149   bool compositor_touch_hit_testing;
    150   bool navigate_on_drag_drop;
    151 
    152   // This flags corresponds to a Page's Settings' setCookieEnabled state. It
    153   // only controls whether or not the "document.cookie" field is properly
    154   // connected to the backing store, for instance if you wanted to be able to
    155   // define custom getters and setters from within a unique security content
    156   // without raising a DOM security exception.
    157   bool cookie_enabled;
    158 
    159   // This flag indicates whether H/W accelerated video decode is enabled for
    160   // pepper plugins. Defaults to false.
    161   bool pepper_accelerated_video_decode_enabled;
    162 
    163 #if defined(OS_ANDROID)
    164   bool text_autosizing_enabled;
    165   float font_scale_factor;
    166   float device_scale_adjustment;
    167   bool force_enable_zoom;
    168   bool disallow_fullscreen_for_non_media_elements;
    169   bool fullscreen_supported;
    170   bool double_tap_to_zoom_enabled;
    171   bool user_gesture_required_for_media_playback;
    172   GURL default_video_poster_url;
    173   bool support_deprecated_target_density_dpi;
    174   bool use_legacy_background_size_shorthand_behavior;
    175   bool wide_viewport_quirk;
    176   bool use_wide_viewport;
    177   bool force_zero_layout_height;
    178   bool viewport_meta_layout_size_quirk;
    179   bool viewport_meta_merge_content_quirk;
    180   bool viewport_meta_non_user_scalable_quirk;
    181   bool viewport_meta_zero_values_quirk;
    182   bool clobber_user_agent_initial_scale_quirk;
    183   bool ignore_main_frame_overflow_hidden_quirk;
    184   bool report_screen_size_in_physical_pixels_quirk;
    185 #endif
    186 
    187   // We try to keep the default values the same as the default values in
    188   // chrome, except for the cases where it would require lots of extra work for
    189   // the embedder to use the same default value.
    190   WebPreferences();
    191   ~WebPreferences();
    192 };
    193 
    194 #endif  // WEBKIT_COMMON_WEBPREFERENCES_H__
    195