Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/hang_monitor/hung_plugin_action.cc

Issue 1815593002: Remove windowed NPAPI code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make_test_plugin_windowless
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/win/win_util.h" 11 #include "base/win/win_util.h"
12 #include "chrome/browser/ui/simple_message_box.h" 12 #include "chrome/browser/ui/simple_message_box.h"
13 #include "chrome/common/logging_chrome.h" 13 #include "chrome/common/logging_chrome.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "content/public/browser/plugin_service.h" 15 #include "content/public/browser/plugin_service.h"
16 #include "content/public/common/webplugininfo.h" 16 #include "content/public/common/webplugininfo.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/gfx/win/hwnd_util.h" 18 #include "ui/gfx/win/hwnd_util.h"
19 19
20 namespace {
21
22 const wchar_t kGTalkPluginName[] = L"Google Talk Plugin";
23 const int kGTalkPluginLogMinVersion = 26; // For version 2.6 and below.
24
25 enum GTalkPluginLogVersion {
26 GTALK_PLUGIN_VERSION_MIN = 0,
27 GTALK_PLUGIN_VERSION_27,
28 GTALK_PLUGIN_VERSION_28,
29 GTALK_PLUGIN_VERSION_29,
30 GTALK_PLUGIN_VERSION_30,
31 GTALK_PLUGIN_VERSION_31,
32 GTALK_PLUGIN_VERSION_32,
33 GTALK_PLUGIN_VERSION_33,
34 GTALK_PLUGIN_VERSION_34,
35 GTALK_PLUGIN_VERSION_MAX
36 };
37
38 // Converts the version string of Google Talk Plugin to a version enum. The
39 // version format is "major(1 digit).minor(1 digit).sub(1 or 2 digits)",
40 // for example, "2.7.10" and "2.8.1". Converts the string to a number as
41 // 10 * major + minor - kGTalkPluginLogMinVersion.
42 GTalkPluginLogVersion GetGTalkPluginVersion(const base::string16& version) {
43 int gtalk_plugin_version = GTALK_PLUGIN_VERSION_MIN;
44 Version plugin_version;
45 content::WebPluginInfo::CreateVersionFromString(version, &plugin_version);
46 if (plugin_version.IsValid() && plugin_version.components().size() >= 2) {
47 gtalk_plugin_version = 10 * plugin_version.components()[0] +
48 plugin_version.components()[1] - kGTalkPluginLogMinVersion;
49 }
50
51 if (gtalk_plugin_version < GTALK_PLUGIN_VERSION_MIN)
52 return GTALK_PLUGIN_VERSION_MIN;
53 if (gtalk_plugin_version > GTALK_PLUGIN_VERSION_MAX)
54 return GTALK_PLUGIN_VERSION_MAX;
55 return static_cast<GTalkPluginLogVersion>(gtalk_plugin_version);
56 }
57
58 } // namespace
59
60 HungPluginAction::HungPluginAction() : current_hung_plugin_window_(NULL) { 20 HungPluginAction::HungPluginAction() : current_hung_plugin_window_(NULL) {
61 } 21 }
62 22
63 HungPluginAction::~HungPluginAction() { 23 HungPluginAction::~HungPluginAction() {
64 } 24 }
65 25
66 bool HungPluginAction::OnHungWindowDetected(HWND hung_window, 26 bool HungPluginAction::OnHungWindowDetected(HWND hung_window,
67 HWND top_level_window, 27 HWND top_level_window,
68 ActionOnHungWindow* action) { 28 ActionOnHungWindow* action) {
69 if (NULL == action) { 29 if (NULL == action) {
70 return false; 30 return false;
71 } 31 }
72 if (!IsWindow(hung_window)) { 32 if (!IsWindow(hung_window)) {
73 return false; 33 return false;
74 } 34 }
75 35
76 bool continue_hang_detection = true; 36 bool continue_hang_detection = true;
77 37
78 DWORD hung_window_process_id = 0; 38 DWORD hung_window_process_id = 0;
79 DWORD top_level_window_process_id = 0; 39 DWORD top_level_window_process_id = 0;
80 GetWindowThreadProcessId(hung_window, &hung_window_process_id); 40 GetWindowThreadProcessId(hung_window, &hung_window_process_id);
81 GetWindowThreadProcessId(top_level_window, &top_level_window_process_id); 41 GetWindowThreadProcessId(top_level_window, &top_level_window_process_id);
82 42
83 *action = HungWindowNotification::HUNG_WINDOW_IGNORE; 43 *action = HungWindowNotification::HUNG_WINDOW_IGNORE;
84 if (top_level_window_process_id != hung_window_process_id) { 44 if (top_level_window_process_id != hung_window_process_id) {
85 base::string16 plugin_name; 45 base::string16 plugin_name =
86 base::string16 plugin_version; 46 l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME);
87
88 content::PluginService::GetInstance()->GetPluginInfoFromWindow(
89 hung_window, &plugin_name, &plugin_version);
90 if (plugin_name.empty()) {
91 plugin_name = l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME);
92 } else if (kGTalkPluginName == plugin_name) {
93 UMA_HISTOGRAM_ENUMERATION("GTalkPlugin.Hung",
94 GetGTalkPluginVersion(plugin_version),
95 GTALK_PLUGIN_VERSION_MAX + 1);
96 }
97 47
98 if (logging::DialogsAreSuppressed()) { 48 if (logging::DialogsAreSuppressed()) {
99 NOTREACHED() << "Terminated a hung plugin process."; 49 NOTREACHED() << "Terminated a hung plugin process.";
100 *action = HungWindowNotification::HUNG_WINDOW_TERMINATE_PROCESS; 50 *action = HungWindowNotification::HUNG_WINDOW_TERMINATE_PROCESS;
101 } else { 51 } else {
102 const base::string16 title = l10n_util::GetStringUTF16( 52 const base::string16 title = l10n_util::GetStringUTF16(
103 IDS_BROWSER_HANGMONITOR_TITLE); 53 IDS_BROWSER_HANGMONITOR_TITLE);
104 const base::string16 message = l10n_util::GetStringFUTF16( 54 const base::string16 message = l10n_util::GetStringFUTF16(
105 IDS_BROWSER_HANGMONITOR, plugin_name); 55 IDS_BROWSER_HANGMONITOR, plugin_name);
106 // Before displaying the message box, invoke SendMessageCallback on the 56 // Before displaying the message box, invoke SendMessageCallback on the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void CALLBACK HungPluginAction::HungWindowResponseCallback(HWND target_window, 122 void CALLBACK HungPluginAction::HungWindowResponseCallback(HWND target_window,
173 UINT message, 123 UINT message,
174 ULONG_PTR data, 124 ULONG_PTR data,
175 LRESULT result) { 125 LRESULT result) {
176 HungPluginAction* instance = reinterpret_cast<HungPluginAction*>(data); 126 HungPluginAction* instance = reinterpret_cast<HungPluginAction*>(data);
177 DCHECK(NULL != instance); 127 DCHECK(NULL != instance);
178 if (NULL != instance) { 128 if (NULL != instance) {
179 instance->OnWindowResponsive(target_window); 129 instance->OnWindowResponsive(target_window);
180 } 130 }
181 } 131 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698