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/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/plugins/plugin_prefs.h" | 14 #include "chrome/browser/plugins/plugin_prefs.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
18 #include "components/variations/active_field_trials.h" | 18 #include "components/variations/active_field_trials.h" |
19 #include "components/version_ui/version_handler_helper.h" | 19 #include "components/version_ui/version_handler_helper.h" |
20 #include "components/version_ui/version_ui_constants.h" | 20 #include "components/version_ui/version_ui_constants.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/plugin_service.h" | 22 #include "content/public/browser/plugin_service.h" |
23 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
24 #include "content/public/common/content_constants.h" | 24 #include "content/public/common/content_constants.h" |
| 25 #include "ppapi/features/features.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // Retrieves the executable and profile paths on the FILE thread. | 31 // Retrieves the executable and profile paths on the FILE thread. |
31 void GetFilePaths(const base::FilePath& profile_path, | 32 void GetFilePaths(const base::FilePath& profile_path, |
32 base::string16* exec_path_out, | 33 base::string16* exec_path_out, |
33 base::string16* profile_path_out) { | 34 base::string16* profile_path_out) { |
34 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 35 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
(...skipping 22 matching lines...) Expand all Loading... |
57 } | 58 } |
58 | 59 |
59 void VersionHandler::RegisterMessages() { | 60 void VersionHandler::RegisterMessages() { |
60 web_ui()->RegisterMessageCallback( | 61 web_ui()->RegisterMessageCallback( |
61 version_ui::kRequestVersionInfo, | 62 version_ui::kRequestVersionInfo, |
62 base::Bind(&VersionHandler::HandleRequestVersionInfo, | 63 base::Bind(&VersionHandler::HandleRequestVersionInfo, |
63 base::Unretained(this))); | 64 base::Unretained(this))); |
64 } | 65 } |
65 | 66 |
66 void VersionHandler::HandleRequestVersionInfo(const base::ListValue* args) { | 67 void VersionHandler::HandleRequestVersionInfo(const base::ListValue* args) { |
67 #if defined(ENABLE_PLUGINS) | 68 #if BUILDFLAG(ENABLE_PLUGINS) |
68 // The Flash version information is needed in the response, so make sure | 69 // The Flash version information is needed in the response, so make sure |
69 // the plugins are loaded. | 70 // the plugins are loaded. |
70 content::PluginService::GetInstance()->GetPlugins( | 71 content::PluginService::GetInstance()->GetPlugins( |
71 base::Bind(&VersionHandler::OnGotPlugins, | 72 base::Bind(&VersionHandler::OnGotPlugins, |
72 weak_ptr_factory_.GetWeakPtr())); | 73 weak_ptr_factory_.GetWeakPtr())); |
73 #endif | 74 #endif |
74 | 75 |
75 // Grab the executable path on the FILE thread. It is returned in | 76 // Grab the executable path on the FILE thread. It is returned in |
76 // OnGotFilePaths. | 77 // OnGotFilePaths. |
77 base::string16* exec_path_buffer = new base::string16; | 78 base::string16* exec_path_buffer = new base::string16; |
(...skipping 16 matching lines...) Expand all Loading... |
94 void VersionHandler::OnGotFilePaths(base::string16* executable_path_data, | 95 void VersionHandler::OnGotFilePaths(base::string16* executable_path_data, |
95 base::string16* profile_path_data) { | 96 base::string16* profile_path_data) { |
96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
97 | 98 |
98 base::StringValue exec_path(*executable_path_data); | 99 base::StringValue exec_path(*executable_path_data); |
99 base::StringValue profile_path(*profile_path_data); | 100 base::StringValue profile_path(*profile_path_data); |
100 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFilePaths, | 101 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFilePaths, |
101 exec_path, profile_path); | 102 exec_path, profile_path); |
102 } | 103 } |
103 | 104 |
104 #if defined(ENABLE_PLUGINS) | 105 #if BUILDFLAG(ENABLE_PLUGINS) |
105 void VersionHandler::OnGotPlugins( | 106 void VersionHandler::OnGotPlugins( |
106 const std::vector<content::WebPluginInfo>& plugins) { | 107 const std::vector<content::WebPluginInfo>& plugins) { |
107 // Obtain the version of the first enabled Flash plugin. | 108 // Obtain the version of the first enabled Flash plugin. |
108 std::vector<content::WebPluginInfo> info_array; | 109 std::vector<content::WebPluginInfo> info_array; |
109 content::PluginService::GetInstance()->GetPluginInfoArray( | 110 content::PluginService::GetInstance()->GetPluginInfoArray( |
110 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); | 111 GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); |
111 base::string16 flash_version = | 112 base::string16 flash_version = |
112 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); | 113 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); |
113 PluginPrefs* plugin_prefs = | 114 PluginPrefs* plugin_prefs = |
114 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); | 115 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); |
115 if (plugin_prefs) { | 116 if (plugin_prefs) { |
116 for (size_t i = 0; i < info_array.size(); ++i) { | 117 for (size_t i = 0; i < info_array.size(); ++i) { |
117 if (plugin_prefs->IsPluginEnabled(info_array[i])) { | 118 if (plugin_prefs->IsPluginEnabled(info_array[i])) { |
118 flash_version = info_array[i].version; | 119 flash_version = info_array[i].version; |
119 break; | 120 break; |
120 } | 121 } |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 base::StringValue arg(flash_version); | 125 base::StringValue arg(flash_version); |
125 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFlashVersion, arg); | 126 web_ui()->CallJavascriptFunctionUnsafe(version_ui::kReturnFlashVersion, arg); |
126 } | 127 } |
127 #endif // defined(ENABLE_PLUGINS) | 128 #endif // BUILDFLAG(ENABLE_PLUGINS) |
OLD | NEW |