Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/plugins_resource_service.h" | 5 #include "chrome/browser/plugins/plugins_resource_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/plugins/plugin_finder.h" | 11 #include "chrome/browser/plugins/plugin_finder.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
| 15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 16 #include "components/safe_json/safe_json_parser.h" | 16 #include "components/safe_json/safe_json_parser.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation = | |
| 21 net::DefineNetworkTrafficAnnotation("...", R"( | |
| 22 semantics { | |
| 23 sender: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
pugins_resource_service
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 24 description: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
Fetches updates to the list of plugins known to Ch
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 25 trigger: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
Triggered at regular intervals (once per day).
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 26 data: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
No data is sent as part of the request.
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 27 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
Bernhard Bauer
2017/03/14 10:07:55
GOOGLE_OWNED_SERVICE
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 28 } | |
| 29 policy { | |
| 30 cookies_allowed: false/true | |
|
Bernhard Bauer
2017/03/14 10:07:55
false
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 31 cookies_store: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
user
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 32 setting: "..." | |
| 33 policy { | |
| 34 [POLICY_NAME] { | |
| 35 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 36 [POLICY_NAME]: ... //(value to disable it) | |
| 37 } | |
| 38 } | |
| 39 policy_exception_justification: "..." | |
|
Bernhard Bauer
2017/03/14 10:07:55
Being able to identify plugins with known security
Ramin Halavati
2017/03/14 11:37:11
Done.
| |
| 40 })"); | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 namespace { | |
| 20 | 45 |
| 21 // Delay on first fetch so we don't interfere with startup. | 46 // Delay on first fetch so we don't interfere with startup. |
| 22 const int kStartResourceFetchDelayMs = 60 * 1000; | 47 const int kStartResourceFetchDelayMs = 60 * 1000; |
| 23 | 48 |
| 24 // Delay between calls to update the cache 1 day and 2 minutes in testing mode. | 49 // Delay between calls to update the cache 1 day and 2 minutes in testing mode. |
| 25 const int kCacheUpdateDelayMs = 24 * 60 * 60 * 1000; | 50 const int kCacheUpdateDelayMs = 24 * 60 * 60 * 1000; |
| 26 | 51 |
| 27 const char kPluginsServerUrl[] = | 52 const char kPluginsServerUrl[] = |
| 28 "https://www.gstatic.com/chrome/config/plugins_2/"; | 53 "https://www.gstatic.com/chrome/config/plugins_2/"; |
| 29 | 54 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 47 PluginsResourceService::PluginsResourceService(PrefService* local_state) | 72 PluginsResourceService::PluginsResourceService(PrefService* local_state) |
| 48 : web_resource::WebResourceService( | 73 : web_resource::WebResourceService( |
| 49 local_state, | 74 local_state, |
| 50 GetPluginsServerURL(), | 75 GetPluginsServerURL(), |
| 51 std::string(), | 76 std::string(), |
| 52 prefs::kPluginsResourceCacheUpdate, | 77 prefs::kPluginsResourceCacheUpdate, |
| 53 kStartResourceFetchDelayMs, | 78 kStartResourceFetchDelayMs, |
| 54 kCacheUpdateDelayMs, | 79 kCacheUpdateDelayMs, |
| 55 g_browser_process->system_request_context(), | 80 g_browser_process->system_request_context(), |
| 56 switches::kDisableBackgroundNetworking, | 81 switches::kDisableBackgroundNetworking, |
| 57 base::Bind(safe_json::SafeJsonParser::Parse)) {} | 82 base::Bind(safe_json::SafeJsonParser::Parse), |
| 83 kTrafficAnnotation) {} | |
| 58 | 84 |
| 59 void PluginsResourceService::Init() { | 85 void PluginsResourceService::Init() { |
| 60 const base::DictionaryValue* metadata = | 86 const base::DictionaryValue* metadata = |
| 61 prefs_->GetDictionary(prefs::kPluginsMetadata); | 87 prefs_->GetDictionary(prefs::kPluginsMetadata); |
| 62 PluginFinder::GetInstance()->ReinitializePlugins(metadata); | 88 PluginFinder::GetInstance()->ReinitializePlugins(metadata); |
| 63 StartAfterDelay(); | 89 StartAfterDelay(); |
| 64 } | 90 } |
| 65 | 91 |
| 66 PluginsResourceService::~PluginsResourceService() { | 92 PluginsResourceService::~PluginsResourceService() { |
| 67 } | 93 } |
| 68 | 94 |
| 69 // static | 95 // static |
| 70 void PluginsResourceService::RegisterPrefs(PrefRegistrySimple* registry) { | 96 void PluginsResourceService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 71 registry->RegisterDictionaryPref(prefs::kPluginsMetadata, | 97 registry->RegisterDictionaryPref(prefs::kPluginsMetadata, |
| 72 new base::DictionaryValue()); | 98 new base::DictionaryValue()); |
| 73 registry->RegisterStringPref(prefs::kPluginsResourceCacheUpdate, "0"); | 99 registry->RegisterStringPref(prefs::kPluginsResourceCacheUpdate, "0"); |
| 74 } | 100 } |
| 75 | 101 |
| 76 void PluginsResourceService::Unpack(const base::DictionaryValue& parsed_json) { | 102 void PluginsResourceService::Unpack(const base::DictionaryValue& parsed_json) { |
| 77 prefs_->Set(prefs::kPluginsMetadata, parsed_json); | 103 prefs_->Set(prefs::kPluginsMetadata, parsed_json); |
| 78 PluginFinder::GetInstance()->ReinitializePlugins(&parsed_json); | 104 PluginFinder::GetInstance()->ReinitializePlugins(&parsed_json); |
| 79 } | 105 } |
| OLD | NEW |