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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 void VersionHandler::RegisterMessages() { | 56 void VersionHandler::RegisterMessages() { |
57 web_ui()->RegisterMessageCallback( | 57 web_ui()->RegisterMessageCallback( |
58 "requestVersionInfo", | 58 "requestVersionInfo", |
59 base::Bind(&VersionHandler::HandleRequestVersionInfo, | 59 base::Bind(&VersionHandler::HandleRequestVersionInfo, |
60 base::Unretained(this))); | 60 base::Unretained(this))); |
61 } | 61 } |
62 | 62 |
63 void VersionHandler::HandleRequestVersionInfo(const ListValue* args) { | 63 void VersionHandler::HandleRequestVersionInfo(const ListValue* args) { |
| 64 #if defined(ENABLE_PLUGINS) |
64 // The Flash version information is needed in the response, so make sure | 65 // The Flash version information is needed in the response, so make sure |
65 // the plugins are loaded. | 66 // the plugins are loaded. |
66 content::PluginService::GetInstance()->GetPlugins( | 67 content::PluginService::GetInstance()->GetPlugins( |
67 base::Bind(&VersionHandler::OnGotPlugins, | 68 base::Bind(&VersionHandler::OnGotPlugins, |
68 weak_ptr_factory_.GetWeakPtr())); | 69 weak_ptr_factory_.GetWeakPtr())); |
| 70 #endif |
69 | 71 |
70 // Grab the executable path on the FILE thread. It is returned in | 72 // Grab the executable path on the FILE thread. It is returned in |
71 // OnGotFilePaths. | 73 // OnGotFilePaths. |
72 string16* exec_path_buffer = new string16; | 74 string16* exec_path_buffer = new string16; |
73 string16* profile_path_buffer = new string16; | 75 string16* profile_path_buffer = new string16; |
74 content::BrowserThread::PostTaskAndReply( | 76 content::BrowserThread::PostTaskAndReply( |
75 content::BrowserThread::FILE, FROM_HERE, | 77 content::BrowserThread::FILE, FROM_HERE, |
76 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(), | 78 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(), |
77 base::Unretained(exec_path_buffer), | 79 base::Unretained(exec_path_buffer), |
78 base::Unretained(profile_path_buffer)), | 80 base::Unretained(profile_path_buffer)), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 119 |
118 void VersionHandler::OnGotFilePaths(string16* executable_path_data, | 120 void VersionHandler::OnGotFilePaths(string16* executable_path_data, |
119 string16* profile_path_data) { | 121 string16* profile_path_data) { |
120 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
121 | 123 |
122 StringValue exec_path(*executable_path_data); | 124 StringValue exec_path(*executable_path_data); |
123 StringValue profile_path(*profile_path_data); | 125 StringValue profile_path(*profile_path_data); |
124 web_ui()->CallJavascriptFunction("returnFilePaths", exec_path, profile_path); | 126 web_ui()->CallJavascriptFunction("returnFilePaths", exec_path, profile_path); |
125 } | 127 } |
126 | 128 |
| 129 #if defined(ENABLE_PLUGINS) |
127 void VersionHandler::OnGotPlugins( | 130 void VersionHandler::OnGotPlugins( |
128 const std::vector<webkit::WebPluginInfo>& plugins) { | 131 const std::vector<webkit::WebPluginInfo>& plugins) { |
129 #if !defined(OS_ANDROID) | |
130 // Obtain the version of the first enabled Flash plugin. | 132 // Obtain the version of the first enabled Flash plugin. |
131 std::vector<webkit::WebPluginInfo> info_array; | 133 std::vector<webkit::WebPluginInfo> info_array; |
132 content::PluginService::GetInstance()->GetPluginInfoArray( | 134 content::PluginService::GetInstance()->GetPluginInfoArray( |
133 GURL(), kFlashPluginSwfMimeType, false, &info_array, NULL); | 135 GURL(), kFlashPluginSwfMimeType, false, &info_array, NULL); |
134 string16 flash_version = | 136 string16 flash_version = |
135 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); | 137 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); |
136 PluginPrefs* plugin_prefs = | 138 PluginPrefs* plugin_prefs = |
137 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())); | 139 PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())); |
138 if (plugin_prefs) { | 140 if (plugin_prefs) { |
139 for (size_t i = 0; i < info_array.size(); ++i) { | 141 for (size_t i = 0; i < info_array.size(); ++i) { |
140 if (plugin_prefs->IsPluginEnabled(info_array[i])) { | 142 if (plugin_prefs->IsPluginEnabled(info_array[i])) { |
141 flash_version = info_array[i].version; | 143 flash_version = info_array[i].version; |
142 break; | 144 break; |
143 } | 145 } |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 StringValue arg(flash_version); | 149 StringValue arg(flash_version); |
148 web_ui()->CallJavascriptFunction("returnFlashVersion", arg); | 150 web_ui()->CallJavascriptFunction("returnFlashVersion", arg); |
149 #endif | |
150 } | 151 } |
| 152 #endif // defined(ENABLE_PLUGINS) |
OLD | NEW |