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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/browser/hang_monitor/hung_plugin_action.h" | 7 #include "chrome/browser/hang_monitor/hung_plugin_action.h" |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
11 #include "chrome/browser/ui/simple_message_box.h" | 11 #include "chrome/browser/ui/simple_message_box.h" |
12 #include "chrome/common/logging_chrome.h" | 12 #include "chrome/common/logging_chrome.h" |
| 13 #include "content/public/browser/plugin_service.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/win/hwnd_util.h" | 16 #include "ui/base/win/hwnd_util.h" |
16 #include "webkit/plugins/npapi/plugin_utils.h" | 17 #include "webkit/plugins/webplugininfo.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const wchar_t kGTalkPluginName[] = L"Google Talk Plugin"; | 21 const wchar_t kGTalkPluginName[] = L"Google Talk Plugin"; |
21 const int kGTalkPluginLogMinVersion = 26; // For version 2.6 and below. | 22 const int kGTalkPluginLogMinVersion = 26; // For version 2.6 and below. |
22 | 23 |
23 enum GTalkPluginLogVersion { | 24 enum GTalkPluginLogVersion { |
24 GTALK_PLUGIN_VERSION_MIN = 0, | 25 GTALK_PLUGIN_VERSION_MIN = 0, |
25 GTALK_PLUGIN_VERSION_27, | 26 GTALK_PLUGIN_VERSION_27, |
26 GTALK_PLUGIN_VERSION_28, | 27 GTALK_PLUGIN_VERSION_28, |
27 GTALK_PLUGIN_VERSION_29, | 28 GTALK_PLUGIN_VERSION_29, |
28 GTALK_PLUGIN_VERSION_30, | 29 GTALK_PLUGIN_VERSION_30, |
29 GTALK_PLUGIN_VERSION_31, | 30 GTALK_PLUGIN_VERSION_31, |
30 GTALK_PLUGIN_VERSION_32, | 31 GTALK_PLUGIN_VERSION_32, |
31 GTALK_PLUGIN_VERSION_33, | 32 GTALK_PLUGIN_VERSION_33, |
32 GTALK_PLUGIN_VERSION_34, | 33 GTALK_PLUGIN_VERSION_34, |
33 GTALK_PLUGIN_VERSION_MAX | 34 GTALK_PLUGIN_VERSION_MAX |
34 }; | 35 }; |
35 | 36 |
36 // Converts the version string of Google Talk Plugin to a version enum. The | 37 // Converts the version string of Google Talk Plugin to a version enum. The |
37 // version format is "major(1 digit).minor(1 digit).sub(1 or 2 digits)", | 38 // version format is "major(1 digit).minor(1 digit).sub(1 or 2 digits)", |
38 // for example, "2.7.10" and "2.8.1". Converts the string to a number as | 39 // for example, "2.7.10" and "2.8.1". Converts the string to a number as |
39 // 10 * major + minor - kGTalkPluginLogMinVersion. | 40 // 10 * major + minor - kGTalkPluginLogMinVersion. |
40 GTalkPluginLogVersion GetGTalkPluginVersion(const string16& version) { | 41 GTalkPluginLogVersion GetGTalkPluginVersion(const string16& version) { |
41 int gtalk_plugin_version = GTALK_PLUGIN_VERSION_MIN; | 42 int gtalk_plugin_version = GTALK_PLUGIN_VERSION_MIN; |
42 Version plugin_version; | 43 Version plugin_version; |
43 webkit::npapi::CreateVersionFromString(version, &plugin_version); | 44 webkit::WebPluginInfo::CreateVersionFromString(version, &plugin_version); |
44 if (plugin_version.IsValid() && plugin_version.components().size() >= 2) { | 45 if (plugin_version.IsValid() && plugin_version.components().size() >= 2) { |
45 gtalk_plugin_version = 10 * plugin_version.components()[0] + | 46 gtalk_plugin_version = 10 * plugin_version.components()[0] + |
46 plugin_version.components()[1] - kGTalkPluginLogMinVersion; | 47 plugin_version.components()[1] - kGTalkPluginLogMinVersion; |
47 } | 48 } |
48 | 49 |
49 if (gtalk_plugin_version < GTALK_PLUGIN_VERSION_MIN) | 50 if (gtalk_plugin_version < GTALK_PLUGIN_VERSION_MIN) |
50 return GTALK_PLUGIN_VERSION_MIN; | 51 return GTALK_PLUGIN_VERSION_MIN; |
51 if (gtalk_plugin_version > GTALK_PLUGIN_VERSION_MAX) | 52 if (gtalk_plugin_version > GTALK_PLUGIN_VERSION_MAX) |
52 return GTALK_PLUGIN_VERSION_MAX; | 53 return GTALK_PLUGIN_VERSION_MAX; |
53 return static_cast<GTalkPluginLogVersion>(gtalk_plugin_version); | 54 return static_cast<GTalkPluginLogVersion>(gtalk_plugin_version); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 DCHECK(plugin_version); | 168 DCHECK(plugin_version); |
168 HWND window_to_check = plugin_window; | 169 HWND window_to_check = plugin_window; |
169 while (NULL != window_to_check) { | 170 while (NULL != window_to_check) { |
170 DWORD process_id = 0; | 171 DWORD process_id = 0; |
171 GetWindowThreadProcessId(window_to_check, &process_id); | 172 GetWindowThreadProcessId(window_to_check, &process_id); |
172 if (process_id == browser_process_id) { | 173 if (process_id == browser_process_id) { |
173 // If we have reached a window the that belongs to the browser process | 174 // If we have reached a window the that belongs to the browser process |
174 // we have gone too far. | 175 // we have gone too far. |
175 return false; | 176 return false; |
176 } | 177 } |
177 if (webkit::npapi::GetPluginNameFromWindow(window_to_check, plugin_name)) { | 178 if (content::PluginService::GetInstance()->GetPluginInfoFromWindow( |
178 webkit::npapi::GetPluginVersionFromWindow( | 179 window_to_check, plugin_name, plugin_version)) { |
179 window_to_check, plugin_version); | |
180 return true; | 180 return true; |
181 } | 181 } |
182 window_to_check = GetParent(window_to_check); | 182 window_to_check = GetParent(window_to_check); |
183 } | 183 } |
184 return false; | 184 return false; |
185 } | 185 } |
186 | 186 |
187 // static | 187 // static |
188 BOOL CALLBACK HungPluginAction::DismissMessageBox(HWND window, LPARAM ignore) { | 188 BOOL CALLBACK HungPluginAction::DismissMessageBox(HWND window, LPARAM ignore) { |
189 string16 class_name = ui::GetClassName(window); | 189 string16 class_name = ui::GetClassName(window); |
(...skipping 10 matching lines...) Expand all Loading... |
200 void CALLBACK HungPluginAction::HungWindowResponseCallback(HWND target_window, | 200 void CALLBACK HungPluginAction::HungWindowResponseCallback(HWND target_window, |
201 UINT message, | 201 UINT message, |
202 ULONG_PTR data, | 202 ULONG_PTR data, |
203 LRESULT result) { | 203 LRESULT result) { |
204 HungPluginAction* instance = reinterpret_cast<HungPluginAction*>(data); | 204 HungPluginAction* instance = reinterpret_cast<HungPluginAction*>(data); |
205 DCHECK(NULL != instance); | 205 DCHECK(NULL != instance); |
206 if (NULL != instance) { | 206 if (NULL != instance) { |
207 instance->OnWindowResponsive(target_window); | 207 instance->OnWindowResponsive(target_window); |
208 } | 208 } |
209 } | 209 } |
OLD | NEW |