| 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/web_resource/plugins_resource_service.h" | 5 #include "chrome/browser/plugins/plugins_resource_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/plugins/plugin_finder.h" | 8 #include "chrome/browser/plugins/plugin_finder.h" |
| 9 #include "chrome/browser/prefs/pref_registry_simple.h" | 9 #include "chrome/browser/prefs/pref_registry_simple.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 GURL GetPluginsServerURL() { | 32 GURL GetPluginsServerURL() { |
| 33 std::string filename; | 33 std::string filename; |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 filename = "plugins_win.json"; | 35 filename = "plugins_win.json"; |
| 36 #elif defined(OS_LINUX) | 36 #elif defined(OS_LINUX) |
| 37 filename = "plugins_linux.json"; | 37 filename = "plugins_linux.json"; |
| 38 #elif defined(OS_MACOSX) | 38 #elif defined(OS_MACOSX) |
| 39 filename = "plugins_mac.json"; | 39 filename = "plugins_mac.json"; |
| 40 #else | 40 #else |
| 41 NOTREACHED(); | 41 #error Unknown platform |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 std::string test_url = | 44 std::string test_url = |
| 45 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 45 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 46 switches::kPluginsMetadataServerURL); | 46 switches::kPluginsMetadataServerURL); |
| 47 return GURL(IsTest() ? test_url : kPluginsServerUrl + filename); | 47 return GURL(IsTest() ? test_url : kPluginsServerUrl + filename); |
| 48 } | 48 } |
| 49 | 49 |
| 50 int GetCacheUpdateDelay() { | 50 int GetCacheUpdateDelay() { |
| 51 return IsTest() ? kTestCacheUpdateDelayMs : kCacheUpdateDelayMs; | 51 return IsTest() ? kTestCacheUpdateDelayMs : kCacheUpdateDelayMs; |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 PluginsResourceService::PluginsResourceService(PrefService* local_state) | 56 PluginsResourceService::PluginsResourceService(PrefService* local_state) |
| 57 : WebResourceService(local_state, | 57 : WebResourceService(local_state, |
| 58 GetPluginsServerURL(), | 58 GetPluginsServerURL(), |
| 59 false, | 59 false, |
| 60 prefs::kPluginsResourceCacheUpdate, | 60 prefs::kPluginsResourceCacheUpdate, |
| 61 kStartResourceFetchDelayMs, | 61 kStartResourceFetchDelayMs, |
| 62 GetCacheUpdateDelay()) { | 62 GetCacheUpdateDelay()) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 void PluginsResourceService::Init() { |
| 66 const base::DictionaryValue* metadata = |
| 67 prefs_->GetDictionary(prefs::kPluginsMetadata); |
| 68 PluginFinder::GetInstance()->ReinitializePlugins(metadata); |
| 69 StartAfterDelay(); |
| 70 } |
| 71 |
| 65 PluginsResourceService::~PluginsResourceService() { | 72 PluginsResourceService::~PluginsResourceService() { |
| 66 } | 73 } |
| 67 | 74 |
| 68 // static | 75 // static |
| 69 void PluginsResourceService::RegisterPrefs(PrefRegistrySimple* registry) { | 76 void PluginsResourceService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 70 registry->RegisterDictionaryPref(prefs::kPluginsMetadata, | 77 registry->RegisterDictionaryPref(prefs::kPluginsMetadata, |
| 71 new base::DictionaryValue()); | 78 new base::DictionaryValue()); |
| 72 registry->RegisterStringPref(prefs::kPluginsResourceCacheUpdate, "0"); | 79 registry->RegisterStringPref(prefs::kPluginsResourceCacheUpdate, "0"); |
| 73 } | 80 } |
| 74 | 81 |
| 75 void PluginsResourceService::Unpack(const DictionaryValue& parsed_json) { | 82 void PluginsResourceService::Unpack(const DictionaryValue& parsed_json) { |
| 76 prefs_->Set(prefs::kPluginsMetadata, parsed_json); | 83 prefs_->Set(prefs::kPluginsMetadata, parsed_json); |
| 77 PluginFinder::GetInstance()->ReinitializePlugins(parsed_json); | 84 PluginFinder::GetInstance()->ReinitializePlugins(&parsed_json); |
| 78 } | 85 } |
| OLD | NEW |