| 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/plugins/plugin_policy_handler.h" | 5 #include "chrome/browser/plugins/plugin_policy_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/pattern.h" | 10 #include "base/strings/pattern.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/plugins/plugin_metadata.h" |
| 13 #include "chrome/browser/plugins/plugin_prefs.h" | 14 #include "chrome/browser/plugins/plugin_prefs.h" |
| 14 #include "chrome/common/chrome_content_client.h" | 15 #include "chrome/common/chrome_content_client.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "components/content_settings/core/common/pref_names.h" | 17 #include "components/content_settings/core/common/pref_names.h" |
| 17 #include "components/policy/core/browser/policy_error_map.h" | 18 #include "components/policy/core/browser/policy_error_map.h" |
| 18 #include "components/strings/grit/components_strings.h" | 19 #include "components/strings/grit/components_strings.h" |
| 19 #include "content/public/common/content_constants.h" | 20 #include "content/public/common/content_constants.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kAdobeFlashPlayerName[] = "Adobe Flash Player"; | |
| 24 | |
| 25 // Retrieves a list typed policy or nullptr if not present or not a list. | 24 // Retrieves a list typed policy or nullptr if not present or not a list. |
| 26 const base::ListValue* GetListPolicy(const policy::PolicyMap& policies, | 25 const base::ListValue* GetListPolicy(const policy::PolicyMap& policies, |
| 27 const std::string& policy) { | 26 const std::string& policy) { |
| 28 const base::Value* value = policies.GetValue(policy); | 27 const base::Value* value = policies.GetValue(policy); |
| 29 if (!value) | 28 if (!value) |
| 30 return nullptr; | 29 return nullptr; |
| 31 | 30 |
| 32 const base::ListValue* policy_value = nullptr; | 31 const base::ListValue* policy_value = nullptr; |
| 33 value->GetAsList(&policy_value); | 32 value->GetAsList(&policy_value); |
| 34 return policy_value; | 33 return policy_value; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 for (int i = 0; i < size; ++i) { | 52 for (int i = 0; i < size; ++i) { |
| 54 std::string plugin; | 53 std::string plugin; |
| 55 if (!plugins->GetString(i, &plugin)) | 54 if (!plugins->GetString(i, &plugin)) |
| 56 continue; | 55 continue; |
| 57 if (base::MatchPattern(ChromeContentClient::kPDFPluginName, plugin) && | 56 if (base::MatchPattern(ChromeContentClient::kPDFPluginName, plugin) && |
| 58 !policies.GetValue(policy::key::kAlwaysOpenPdfExternally)) { | 57 !policies.GetValue(policy::key::kAlwaysOpenPdfExternally)) { |
| 59 prefs->SetValue( | 58 prefs->SetValue( |
| 60 prefs::kPluginsAlwaysOpenPdfExternally, | 59 prefs::kPluginsAlwaysOpenPdfExternally, |
| 61 base::MakeUnique<base::FundamentalValue>(disable_pdf_plugin)); | 60 base::MakeUnique<base::FundamentalValue>(disable_pdf_plugin)); |
| 62 } | 61 } |
| 63 if ((base::MatchPattern(kAdobeFlashPlayerName, plugin) || | 62 if ((base::MatchPattern( |
| 63 PluginMetadata::kAdobeFlashPlayerGroupName, plugin) || |
| 64 base::MatchPattern(content::kFlashPluginName, plugin)) && | 64 base::MatchPattern(content::kFlashPluginName, plugin)) && |
| 65 !policies.GetValue(policy::key::kDefaultPluginsSetting)) { | 65 !policies.GetValue(policy::key::kDefaultPluginsSetting)) { |
| 66 prefs->SetValue( | 66 prefs->SetValue( |
| 67 prefs::kManagedDefaultPluginsSetting, | 67 prefs::kManagedDefaultPluginsSetting, |
| 68 base::MakeUnique<base::FundamentalValue>(flash_content_setting)); | 68 base::MakeUnique<base::FundamentalValue>(flash_content_setting)); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool PluginPolicyHandler::CheckPolicySettings(const policy::PolicyMap& policies, | 73 bool PluginPolicyHandler::CheckPolicySettings(const policy::PolicyMap& policies, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 return; | 103 return; |
| 104 const int size = plugins->GetSize(); | 104 const int size = plugins->GetSize(); |
| 105 for (int i = 0; i < size; ++i) { | 105 for (int i = 0; i < size; ++i) { |
| 106 std::string plugin; | 106 std::string plugin; |
| 107 if (!plugins->GetString(i, &plugin)) | 107 if (!plugins->GetString(i, &plugin)) |
| 108 continue; | 108 continue; |
| 109 if (base::MatchPattern(ChromeContentClient::kPDFPluginName, plugin) && | 109 if (base::MatchPattern(ChromeContentClient::kPDFPluginName, plugin) && |
| 110 !policies.GetValue(policy::key::kAlwaysOpenPdfExternally)) { | 110 !policies.GetValue(policy::key::kAlwaysOpenPdfExternally)) { |
| 111 prefs->RemoveValue(prefs::kPluginsAlwaysOpenPdfExternally); | 111 prefs->RemoveValue(prefs::kPluginsAlwaysOpenPdfExternally); |
| 112 } | 112 } |
| 113 if ((base::MatchPattern(kAdobeFlashPlayerName, plugin) || | 113 if ((base::MatchPattern( |
| 114 PluginMetadata::kAdobeFlashPlayerGroupName, plugin) || |
| 114 base::MatchPattern(content::kFlashPluginName, plugin)) && | 115 base::MatchPattern(content::kFlashPluginName, plugin)) && |
| 115 !policies.GetValue(policy::key::kDefaultPluginsSetting)) { | 116 !policies.GetValue(policy::key::kDefaultPluginsSetting)) { |
| 116 prefs->RemoveValue(prefs::kManagedDefaultPluginsSetting); | 117 prefs->RemoveValue(prefs::kManagedDefaultPluginsSetting); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 } | 120 } |
| OLD | NEW |