OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_popup_api.h" | 5 #include "chrome/browser/extensions/extension_popup_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Overridden from views::WidgetFocusChangeListener | 235 // Overridden from views::WidgetFocusChangeListener |
236 virtual void NativeFocusWillChange(gfx::NativeView focused_before, | 236 virtual void NativeFocusWillChange(gfx::NativeView focused_before, |
237 gfx::NativeView focused_now) { | 237 gfx::NativeView focused_now) { |
238 // If the popup doesn't exist, then do nothing. | 238 // If the popup doesn't exist, then do nothing. |
239 if (!popup_) | 239 if (!popup_) |
240 return; | 240 return; |
241 | 241 |
242 // If no view is to be focused, then Chrome was deactivated, so hide the | 242 // If no view is to be focused, then Chrome was deactivated, so hide the |
243 // popup. | 243 // popup. |
244 if (focused_now) { | 244 if (focused_now) { |
| 245 // On XP, the focus change handler may be invoked when the delegate has |
| 246 // already been revoked. |
| 247 // TODO(twiz@chromium.org): Resolve the trigger of this behaviour. |
| 248 if (!dispatcher_ || !dispatcher_->delegate()) |
| 249 return; |
| 250 |
245 gfx::NativeView host_view = | 251 gfx::NativeView host_view = |
246 dispatcher_->delegate()->GetNativeViewOfHost(); | 252 dispatcher_->delegate()->GetNativeViewOfHost(); |
247 | 253 |
248 // If the widget hosting the popup contains the newly focused view, then | 254 // If the widget hosting the popup contains the newly focused view, then |
249 // don't dismiss the pop-up. | 255 // don't dismiss the pop-up. |
250 ExtensionView* view = popup_->host()->view(); | 256 ExtensionView* view = popup_->host()->view(); |
251 if (view) { | 257 if (view) { |
252 views::Widget* popup_root_widget = view->GetWidget(); | 258 views::Widget* popup_root_widget = view->GetWidget(); |
253 if (popup_root_widget && | 259 if (popup_root_widget && |
254 popup_root_widget->ContainsNativeView(focused_now)) | 260 popup_root_widget->ContainsNativeView(focused_now)) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // static | 545 // static |
540 void PopupEventRouter::OnPopupClosed(Profile* profile, | 546 void PopupEventRouter::OnPopupClosed(Profile* profile, |
541 int routing_id) { | 547 int routing_id) { |
542 std::string full_event_name = base::StringPrintf( | 548 std::string full_event_name = base::StringPrintf( |
543 extension_popup_module_events::kOnPopupClosed, | 549 extension_popup_module_events::kOnPopupClosed, |
544 routing_id); | 550 routing_id); |
545 | 551 |
546 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 552 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
547 full_event_name, base::JSONWriter::kEmptyArray, profile, GURL()); | 553 full_event_name, base::JSONWriter::kEmptyArray, profile, GURL()); |
548 } | 554 } |
OLD | NEW |