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/ui/webui/version_handler.h" | 5 #include "chrome/browser/ui/webui/version_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/plugins/plugin_prefs.h" | 15 #include "chrome/browser/plugins/plugin_prefs.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
17 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
18 #include "components/variations/active_field_trials.h" | 19 #include "components/variations/active_field_trials.h" |
19 #include "components/version_ui/version_handler_helper.h" | 20 #include "components/version_ui/version_handler_helper.h" |
20 #include "components/version_ui/version_ui_constants.h" | 21 #include "components/version_ui/version_ui_constants.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/plugin_service.h" | 23 #include "content/public/browser/plugin_service.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 exec_path, profile_path); | 103 exec_path, profile_path); |
103 } | 104 } |
104 | 105 |
105 #if BUILDFLAG(ENABLE_PLUGINS) | 106 #if BUILDFLAG(ENABLE_PLUGINS) |
106 void VersionHandler::OnGotPlugins( | 107 void VersionHandler::OnGotPlugins( |
107 const std::vector<content::WebPluginInfo>& plugins) { | 108 const std::vector<content::WebPluginInfo>& plugins) { |
108 // Obtain the version of the first enabled Flash plugin. | 109 // Obtain the version of the first enabled Flash plugin. |
109 std::vector<content::WebPluginInfo> info_array; | 110 std::vector<content::WebPluginInfo> info_array; |
110 content::PluginService::GetInstance()->GetPluginInfoArray( | 111 content::PluginService::GetInstance()->GetPluginInfoArray( |
111 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); | 112 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); |
112 base::string16 flash_version = | 113 std::string flash_version_and_path = |
113 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); | 114 l10n_util::GetStringUTF8(IDS_PLUGINS_DISABLED_PLUGIN); |
114 PluginPrefs* plugin_prefs = | 115 PluginPrefs* plugin_prefs = |
115 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); | 116 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); |
116 if (plugin_prefs) { | 117 if (plugin_prefs) { |
117 for (size_t i = 0; i < info_array.size(); ++i) { | 118 for (size_t i = 0; i < info_array.size(); ++i) { |
118 if (plugin_prefs->IsPluginEnabled(info_array[i])) { | 119 if (plugin_prefs->IsPluginEnabled(info_array[i])) { |
119 flash_version = info_array[i].version; | 120 flash_version_and_path = base::StringPrintf( |
| 121 "%s %s", base::UTF16ToUTF8(info_array[i].version).c_str(), |
| 122 base::UTF16ToUTF8(info_array[i].path.LossyDisplayName()).c_str()); |
120 break; | 123 break; |
121 } | 124 } |
122 } | 125 } |
123 } | 126 } |
124 | 127 |
125 base::StringValue arg(flash_version); | 128 base::StringValue arg(flash_version_and_path); |
| 129 |
126 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFlashVersion, arg); | 130 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFlashVersion, arg); |
127 } | 131 } |
128 #endif // BUILDFLAG(ENABLE_PLUGINS) | 132 #endif // BUILDFLAG(ENABLE_PLUGINS) |
OLD | NEW |