| 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/pepper_flash_settings_manager.h" | 5 #include "chrome/browser/pepper_flash_settings_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/plugins/plugin_prefs.h" | 17 #include "chrome/browser/plugins/plugin_prefs.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" | 19 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "components/user_prefs/pref_registry_syncable.h" | 21 #include "components/user_prefs/pref_registry_syncable.h" |
| 22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/pepper_flash_settings_helper.h" | 24 #include "content/public/browser/pepper_flash_settings_helper.h" |
| 25 #include "content/public/browser/plugin_service.h" | 25 #include "content/public/browser/plugin_service.h" |
| 26 #include "content/public/common/content_constants.h" | 26 #include "content/public/common/content_constants.h" |
| 27 #include "content/public/common/webplugininfo.h" |
| 27 #include "ipc/ipc_channel.h" | 28 #include "ipc/ipc_channel.h" |
| 28 #include "ipc/ipc_listener.h" | 29 #include "ipc/ipc_listener.h" |
| 29 #include "ppapi/proxy/ppapi_messages.h" | 30 #include "ppapi/proxy/ppapi_messages.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 #include "webkit/plugins/plugin_constants.h" | 32 #include "webkit/plugins/plugin_constants.h" |
| 32 #include "webkit/plugins/webplugininfo.h" | |
| 33 | 33 |
| 34 using content::BrowserThread; | 34 using content::BrowserThread; |
| 35 | 35 |
| 36 class PepperFlashSettingsManager::Core | 36 class PepperFlashSettingsManager::Core |
| 37 : public IPC::Listener, | 37 : public IPC::Listener, |
| 38 public base::RefCountedThreadSafe<Core, BrowserThread::DeleteOnIOThread> { | 38 public base::RefCountedThreadSafe<Core, BrowserThread::DeleteOnIOThread> { |
| 39 public: | 39 public: |
| 40 Core(base::WeakPtr<PepperFlashSettingsManager> manager, | 40 Core(base::WeakPtr<PepperFlashSettingsManager> manager, |
| 41 content::BrowserContext* browser_context); | 41 content::BrowserContext* browser_context); |
| 42 | 42 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 iter->max_age); | 394 iter->max_age); |
| 395 break; | 395 break; |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { | 400 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { |
| 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 402 DCHECK_EQ(STATE_UNINITIALIZED, state_); | 402 DCHECK_EQ(STATE_UNINITIALIZED, state_); |
| 403 | 403 |
| 404 webkit::WebPluginInfo plugin_info; | 404 content::WebPluginInfo plugin_info; |
| 405 if (!PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs_.get(), | 405 if (!PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs_.get(), |
| 406 &plugin_info)) { | 406 &plugin_info)) { |
| 407 NotifyErrorFromIOThread(); | 407 NotifyErrorFromIOThread(); |
| 408 return; | 408 return; |
| 409 } | 409 } |
| 410 | 410 |
| 411 base::FilePath profile_path = | 411 base::FilePath profile_path = |
| 412 browser_context_path_.Append(content::kPepperDataDirname); | 412 browser_context_path_.Append(content::kPepperDataDirname); |
| 413 #if defined(OS_WIN) | 413 #if defined(OS_WIN) |
| 414 plugin_data_path_ = profile_path.Append(plugin_info.name); | 414 plugin_data_path_ = profile_path.Append(plugin_info.name); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 } | 940 } |
| 941 | 941 |
| 942 PepperFlashSettingsManager::~PepperFlashSettingsManager() { | 942 PepperFlashSettingsManager::~PepperFlashSettingsManager() { |
| 943 if (core_.get()) | 943 if (core_.get()) |
| 944 core_->Detach(); | 944 core_->Detach(); |
| 945 } | 945 } |
| 946 | 946 |
| 947 // static | 947 // static |
| 948 bool PepperFlashSettingsManager::IsPepperFlashInUse( | 948 bool PepperFlashSettingsManager::IsPepperFlashInUse( |
| 949 PluginPrefs* plugin_prefs, | 949 PluginPrefs* plugin_prefs, |
| 950 webkit::WebPluginInfo* plugin_info) { | 950 content::WebPluginInfo* plugin_info) { |
| 951 if (!plugin_prefs) | 951 if (!plugin_prefs) |
| 952 return false; | 952 return false; |
| 953 | 953 |
| 954 content::PluginService* plugin_service = | 954 content::PluginService* plugin_service = |
| 955 content::PluginService::GetInstance(); | 955 content::PluginService::GetInstance(); |
| 956 std::vector<webkit::WebPluginInfo> plugins; | 956 std::vector<content::WebPluginInfo> plugins; |
| 957 plugin_service->GetPluginInfoArray( | 957 plugin_service->GetPluginInfoArray( |
| 958 GURL(), kFlashPluginSwfMimeType, false, &plugins, NULL); | 958 GURL(), kFlashPluginSwfMimeType, false, &plugins, NULL); |
| 959 | 959 |
| 960 for (std::vector<webkit::WebPluginInfo>::iterator iter = plugins.begin(); | 960 for (std::vector<content::WebPluginInfo>::iterator iter = plugins.begin(); |
| 961 iter != plugins.end(); ++iter) { | 961 iter != plugins.end(); ++iter) { |
| 962 if (iter->is_pepper_plugin() && plugin_prefs->IsPluginEnabled(*iter)) { | 962 if (iter->is_pepper_plugin() && plugin_prefs->IsPluginEnabled(*iter)) { |
| 963 if (plugin_info) | 963 if (plugin_info) |
| 964 *plugin_info = *iter; | 964 *plugin_info = *iter; |
| 965 return true; | 965 return true; |
| 966 } | 966 } |
| 967 } | 967 } |
| 968 return false; | 968 return false; |
| 969 } | 969 } |
| 970 | 970 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 void PepperFlashSettingsManager::OnError(Core* core) { | 1065 void PepperFlashSettingsManager::OnError(Core* core) { |
| 1066 DCHECK(core); | 1066 DCHECK(core); |
| 1067 if (core != core_.get()) | 1067 if (core != core_.get()) |
| 1068 return; | 1068 return; |
| 1069 | 1069 |
| 1070 core_->Detach(); | 1070 core_->Detach(); |
| 1071 core_ = NULL; | 1071 core_ = NULL; |
| 1072 } | 1072 } |
| OLD | NEW |