| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_webkit_preferences.h" | 5 #include "chrome/browser/extensions/extension_webkit_preferences.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/manifest.h" | 10 #include "chrome/common/extensions/manifest.h" |
| 11 #include "webkit/glue/webpreferences.h" | 11 #include "webkit/glue/webpreferences.h" |
| 12 | 12 |
| 13 namespace extension_webkit_preferences { | 13 namespace extension_webkit_preferences { |
| 14 | 14 |
| 15 void SetPreferences(const extensions::Extension* extension, | 15 void SetPreferences(const extensions::Extension* extension, |
| 16 chrome::ViewType render_view_type, | 16 extensions::ViewType render_view_type, |
| 17 webkit_glue::WebPreferences* webkit_prefs) { | 17 webkit_glue::WebPreferences* webkit_prefs) { |
| 18 if (!extension) | 18 if (!extension) |
| 19 return; | 19 return; |
| 20 | 20 |
| 21 if (!extension->is_hosted_app()) { | 21 if (!extension->is_hosted_app()) { |
| 22 // Extensions are trusted so we override any user preferences for disabling | 22 // Extensions are trusted so we override any user preferences for disabling |
| 23 // javascript or images. | 23 // javascript or images. |
| 24 webkit_prefs->loads_images_automatically = true; | 24 webkit_prefs->loads_images_automatically = true; |
| 25 webkit_prefs->javascript_enabled = true; | 25 webkit_prefs->javascript_enabled = true; |
| 26 | 26 |
| 27 // Tabs aren't typically allowed to close windows. But extensions shouldn't | 27 // Tabs aren't typically allowed to close windows. But extensions shouldn't |
| 28 // be subject to that. | 28 // be subject to that. |
| 29 webkit_prefs->allow_scripts_to_close_windows = true; | 29 webkit_prefs->allow_scripts_to_close_windows = true; |
| 30 | 30 |
| 31 // Disable gpu acceleration for extension background pages to avoid | 31 // Disable gpu acceleration for extension background pages to avoid |
| 32 // unecessarily creating a compositor context for them. | 32 // unecessarily creating a compositor context for them. |
| 33 if (render_view_type == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 33 if (render_view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 34 webkit_prefs->accelerated_compositing_enabled = false; | 34 webkit_prefs->accelerated_compositing_enabled = false; |
| 35 webkit_prefs->force_compositing_mode = false; | 35 webkit_prefs->force_compositing_mode = false; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 if (extension->is_platform_app()) { | 39 if (extension->is_platform_app()) { |
| 40 webkit_prefs->databases_enabled = false; | 40 webkit_prefs->databases_enabled = false; |
| 41 webkit_prefs->local_storage_enabled = false; | 41 webkit_prefs->local_storage_enabled = false; |
| 42 webkit_prefs->sync_xhr_in_documents_enabled = false; | 42 webkit_prefs->sync_xhr_in_documents_enabled = false; |
| 43 webkit_prefs->cookie_enabled = false; | 43 webkit_prefs->cookie_enabled = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 // performance characteristics to be similar in both cases. | 55 // performance characteristics to be similar in both cases. |
| 56 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 56 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 57 if (extension->location() == extensions::Manifest::COMPONENT && | 57 if (extension->location() == extensions::Manifest::COMPONENT && |
| 58 !command_line.HasSwitch(switches::kAllowWebUICompositing)) { | 58 !command_line.HasSwitch(switches::kAllowWebUICompositing)) { |
| 59 webkit_prefs->accelerated_compositing_enabled = false; | 59 webkit_prefs->accelerated_compositing_enabled = false; |
| 60 webkit_prefs->accelerated_2d_canvas_enabled = false; | 60 webkit_prefs->accelerated_2d_canvas_enabled = false; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // extension_webkit_preferences | 64 } // extension_webkit_preferences |
| OLD | NEW |