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

Side by Side Diff: chrome/browser/external_tab_container_win.cc

Issue 3014001: ChromeFrame tabs would hang at times while closing. This would randomly occur... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | Annotate | Revision Log
OLDNEW
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/external_tab_container_win.h" 5 #include "chrome/browser/external_tab_container_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/win_util.h" 9 #include "app/win_util.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 22 matching lines...) Expand all
33 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
34 #include "views/grid_layout.h" 34 #include "views/grid_layout.h"
35 #include "views/widget/root_view.h" 35 #include "views/widget/root_view.h"
36 #include "views/window/window.h" 36 #include "views/window/window.h"
37 37
38 static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; 38 static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject";
39 39
40 base::LazyInstance<ExternalTabContainer::PendingTabs> 40 base::LazyInstance<ExternalTabContainer::PendingTabs>
41 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED); 41 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED);
42 42
43 // ExternalTabContainer::PendingTabs ExternalTabContainer::pending_tabs_;
44 ExternalTabContainer* ExternalTabContainer::innermost_tab_for_unload_event_
45 = NULL;
46
47 ExternalTabContainer::ExternalTabContainer( 43 ExternalTabContainer::ExternalTabContainer(
48 AutomationProvider* automation, AutomationResourceMessageFilter* filter) 44 AutomationProvider* automation, AutomationResourceMessageFilter* filter)
49 : automation_(automation), 45 : automation_(automation),
50 tab_contents_(NULL), 46 tab_contents_(NULL),
51 tab_contents_container_(NULL), 47 tab_contents_container_(NULL),
52 tab_handle_(0), 48 tab_handle_(0),
53 ignore_next_load_notification_(false), 49 ignore_next_load_notification_(false),
54 automation_resource_message_filter_(filter), 50 automation_resource_message_filter_(filter),
55 load_requests_via_automation_(false), 51 load_requests_via_automation_(false),
56 handle_top_level_requests_(false), 52 handle_top_level_requests_(false),
57 external_method_factory_(this), 53 external_method_factory_(this),
58 enabled_extension_automation_(false), 54 enabled_extension_automation_(false),
59 waiting_for_unload_event_(false), 55 waiting_for_unload_event_(false),
60 pending_(false), 56 pending_(false),
61 infobars_enabled_(true), 57 infobars_enabled_(true),
62 focus_manager_(NULL), 58 focus_manager_(NULL),
63 external_tab_view_(NULL) { 59 external_tab_view_(NULL),
60 notification_window_(NULL),
61 notification_message_(NULL) {
64 } 62 }
65 63
66 ExternalTabContainer::~ExternalTabContainer() { 64 ExternalTabContainer::~ExternalTabContainer() {
67 Uninitialize(); 65 Uninitialize();
68 } 66 }
69 67
70 bool ExternalTabContainer::Init(Profile* profile, 68 bool ExternalTabContainer::Init(Profile* profile,
71 HWND parent, 69 HWND parent,
72 const gfx::Rect& bounds, 70 const gfx::Rect& bounds,
73 DWORD style, 71 DWORD style,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void ExternalTabContainer::ActivateContents(TabContents* contents) { 385 void ExternalTabContainer::ActivateContents(TabContents* contents) {
388 } 386 }
389 387
390 void ExternalTabContainer::LoadingStateChanged(TabContents* source) { 388 void ExternalTabContainer::LoadingStateChanged(TabContents* source) {
391 } 389 }
392 390
393 void ExternalTabContainer::CloseContents(TabContents* source) { 391 void ExternalTabContainer::CloseContents(TabContents* source) {
394 static const int kExternalTabCloseContentsDelayMS = 100; 392 static const int kExternalTabCloseContentsDelayMS = 100;
395 393
396 if (waiting_for_unload_event_) { 394 if (waiting_for_unload_event_) {
397 // If we are not the innermost tab waiting for the unload event to return 395 PostMessage(notification_window_, notification_message_, 0, 0);
398 // then don't handle this notification right away as we need the inner 396 waiting_for_unload_event_ = false;
399 // message loop to terminate.
400 if (this != innermost_tab_for_unload_event_) {
401 ChromeThread::PostDelayedTask(
402 ChromeThread::UI, FROM_HERE,
403 NewRunnableMethod(this, &ExternalTabContainer::CloseContents,
404 source), kExternalTabCloseContentsDelayMS);
405 return;
406 }
407 MessageLoop::current()->Quit();
408 } else { 397 } else {
409 if (automation_) { 398 if (automation_) {
410 automation_->Send(new AutomationMsg_CloseExternalTab(0, tab_handle_)); 399 automation_->Send(new AutomationMsg_CloseExternalTab(0, tab_handle_));
411 } 400 }
412 } 401 }
413 } 402 }
414 403
415 void ExternalTabContainer::MoveContents(TabContents* source, 404 void ExternalTabContainer::MoveContents(TabContents* source,
416 const gfx::Rect& pos) { 405 const gfx::Rect& pos) {
417 } 406 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { 672 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) {
684 LRESULT result = views::WidgetWin::OnCreate(create_struct); 673 LRESULT result = views::WidgetWin::OnCreate(create_struct);
685 if (result == 0) { 674 if (result == 0) {
686 // Grab a reference here which will be released in OnFinalMessage 675 // Grab a reference here which will be released in OnFinalMessage
687 AddRef(); 676 AddRef();
688 } 677 }
689 return result; 678 return result;
690 } 679 }
691 680
692 void ExternalTabContainer::OnDestroy() { 681 void ExternalTabContainer::OnDestroy() {
693 if (tab_contents_) {
694 waiting_for_unload_event_ = true;
695 if (Browser::RunUnloadEventsHelper(tab_contents_)) {
696 // Maintain a local global stack of Externa;TabCotainers waiting for the
697 // unload event listeners to finish. We need this as we only want to
698 // handle the CloseContents call from the TabContents when the current
699 // ExternalTabContainers message loop is active. This ensures that nested
700 // ExternalTabContainer message loops terminate correctly.
701 ExternalTabContainer* current_tab = innermost_tab_for_unload_event_;
702 innermost_tab_for_unload_event_ = this;
703 MessageLoop::current()->Run();
704 innermost_tab_for_unload_event_ = current_tab;
705 }
706 waiting_for_unload_event_ = false;
707 }
708
709 Uninitialize(); 682 Uninitialize();
710 WidgetWin::OnDestroy(); 683 WidgetWin::OnDestroy();
711 if (browser_.get()) { 684 if (browser_.get()) {
712 ::DestroyWindow(browser_->window()->GetNativeHandle()); 685 ::DestroyWindow(browser_->window()->GetNativeHandle());
713 } 686 }
714 } 687 }
715 688
716 void ExternalTabContainer::OnFinalMessage(HWND window) { 689 void ExternalTabContainer::OnFinalMessage(HWND window) {
717 // Release the reference which we grabbed in WM_CREATE. 690 // Release the reference which we grabbed in WM_CREATE.
718 Release(); 691 Release();
719 } 692 }
720 693
694 void ExternalTabContainer::RunUnloadHandlers(
695 gfx::NativeWindow notification_window,
696 int notification_message) {
697 DCHECK(::IsWindow(notification_window));
698 if (tab_contents_) {
699 notification_window_ = notification_window;
700 notification_message_ = notification_message;
701
702 if (Browser::RunUnloadEventsHelper(tab_contents_)) {
703 waiting_for_unload_event_ = true;
704 }
705 }
706 if (!waiting_for_unload_event_) {
707 PostMessage(notification_window, notification_message, 0, 0);
708 }
709 }
710
721 //////////////////////////////////////////////////////////////////////////////// 711 ////////////////////////////////////////////////////////////////////////////////
722 // ExternalTabContainer, private: 712 // ExternalTabContainer, private:
723 bool ExternalTabContainer::ProcessUnhandledKeyStroke(HWND window, 713 bool ExternalTabContainer::ProcessUnhandledKeyStroke(HWND window,
724 UINT message, 714 UINT message,
725 WPARAM wparam, 715 WPARAM wparam,
726 LPARAM lparam) { 716 LPARAM lparam) {
727 if (!automation_) { 717 if (!automation_) {
728 return false; 718 return false;
729 } 719 }
730 if ((wparam == VK_TAB) && !win_util::IsCtrlPressed()) { 720 if ((wparam == VK_TAB) && !win_util::IsCtrlPressed()) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 964
975 layout->StartRow(0, 0); 965 layout->StartRow(0, 0);
976 layout->AddView(info_bar_container); 966 layout->AddView(info_bar_container);
977 layout->StartRow(1, 0); 967 layout->StartRow(1, 0);
978 layout->AddView(tab_contents_container_); 968 layout->AddView(tab_contents_container_);
979 SetContentsView(external_tab_view_); 969 SetContentsView(external_tab_view_);
980 // Note that SetTabContents must be called after AddChildView is called 970 // Note that SetTabContents must be called after AddChildView is called
981 tab_contents_container_->ChangeTabContents(tab_contents_); 971 tab_contents_container_->ChangeTabContents(tab_contents_);
982 } 972 }
983 973
OLDNEW
« no previous file with comments | « chrome/browser/external_tab_container_win.h ('k') | chrome/test/automation/automation_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698