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

Side by Side Diff: chrome/browser/views/html_dialog_view.cc

Issue 220011: There is a race condition when the HtmlDialogView is closed which causes a cr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/html_dialog_view.h" 5 #include "chrome/browser/views/html_dialog_view.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "views/widget/root_view.h" 9 #include "views/widget/root_view.h"
10 #include "views/widget/widget.h" 10 #include "views/widget/widget.h"
11 #include "views/window/window.h" 11 #include "views/window/window.h"
12 12
13 namespace browser { 13 namespace browser {
14 14
15 // Declared in browser_dialogs.h so that others don't need to depend on our .h. 15 // Declared in browser_dialogs.h so that others don't need to depend on our .h.
16 void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser, 16 void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser,
17 HtmlDialogUIDelegate* delegate) { 17 HtmlDialogUIDelegate* delegate) {
18 HtmlDialogView* html_view = new HtmlDialogView(browser, delegate); 18 HtmlDialogView* html_view = new HtmlDialogView(browser, delegate);
19 views::Window::CreateChromeWindow(parent, gfx::Rect(), html_view); 19 views::Window::CreateChromeWindow(parent, gfx::Rect(), html_view);
20 html_view->InitDialog(); 20 html_view->InitDialog();
21 html_view->window()->Show(); 21 html_view->window()->Show();
22 } 22 }
23 23
24 } // namespace browser 24 } // namespace browser
25 25
(...skipping 10 matching lines...) Expand all
36 } 36 }
37 37
38 HtmlDialogView::~HtmlDialogView() { 38 HtmlDialogView::~HtmlDialogView() {
39 } 39 }
40 40
41 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
42 // HtmlDialogView, views::View implementation: 42 // HtmlDialogView, views::View implementation:
43 43
44 gfx::Size HtmlDialogView::GetPreferredSize() { 44 gfx::Size HtmlDialogView::GetPreferredSize() {
45 gfx::Size out; 45 gfx::Size out;
46 delegate_->GetDialogSize(&out); 46 if (delegate_)
47 delegate_->GetDialogSize(&out);
47 return out; 48 return out;
48 } 49 }
49 50
50 //////////////////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////////////////
51 // HtmlDialogView, views::WindowDelegate implementation: 52 // HtmlDialogView, views::WindowDelegate implementation:
52 53
53 bool HtmlDialogView::CanResize() const { 54 bool HtmlDialogView::CanResize() const {
54 return true; 55 return true;
55 } 56 }
56 57
57 bool HtmlDialogView::IsModal() const { 58 bool HtmlDialogView::IsModal() const {
58 return delegate_->IsDialogModal(); 59 if (delegate_)
60 return delegate_->IsDialogModal();
61 else
62 return false;
59 } 63 }
60 64
61 std::wstring HtmlDialogView::GetWindowTitle() const { 65 std::wstring HtmlDialogView::GetWindowTitle() const {
62 return delegate_->GetDialogTitle(); 66 if (delegate_)
67 return delegate_->GetDialogTitle();
68 else
69 return std::wstring();
63 } 70 }
64 71
65 void HtmlDialogView::WindowClosing() { 72 void HtmlDialogView::WindowClosing() {
66 // If we still have a delegate that means we haven't notified it of the 73 // If we still have a delegate that means we haven't notified it of the
67 // dialog closing. This happens if the user clicks the Close button on the 74 // dialog closing. This happens if the user clicks the Close button on the
68 // dialog. 75 // dialog.
69 if (delegate_) 76 if (delegate_)
70 OnDialogClosed(""); 77 OnDialogClosed("");
71 } 78 }
72 79
(...skipping 10 matching lines...) Expand all
83 90
84 bool HtmlDialogView::IsDialogModal() const { 91 bool HtmlDialogView::IsDialogModal() const {
85 return IsModal(); 92 return IsModal();
86 } 93 }
87 94
88 std::wstring HtmlDialogView::GetDialogTitle() const { 95 std::wstring HtmlDialogView::GetDialogTitle() const {
89 return GetWindowTitle(); 96 return GetWindowTitle();
90 } 97 }
91 98
92 GURL HtmlDialogView::GetDialogContentURL() const { 99 GURL HtmlDialogView::GetDialogContentURL() const {
93 return delegate_->GetDialogContentURL(); 100 if (delegate_)
101 return delegate_->GetDialogContentURL();
102 else
103 return GURL();
94 } 104 }
95 105
96 void HtmlDialogView::GetDOMMessageHandlers( 106 void HtmlDialogView::GetDOMMessageHandlers(
97 std::vector<DOMMessageHandler*>* handlers) const { 107 std::vector<DOMMessageHandler*>* handlers) const {
98 delegate_->GetDOMMessageHandlers(handlers); 108 if (delegate_)
109 delegate_->GetDOMMessageHandlers(handlers);
99 } 110 }
100 111
101 void HtmlDialogView::GetDialogSize(gfx::Size* size) const { 112 void HtmlDialogView::GetDialogSize(gfx::Size* size) const {
102 delegate_->GetDialogSize(size); 113 if (delegate_)
114 delegate_->GetDialogSize(size);
103 } 115 }
104 116
105 std::string HtmlDialogView::GetDialogArgs() const { 117 std::string HtmlDialogView::GetDialogArgs() const {
106 return delegate_->GetDialogArgs(); 118 if (delegate_)
119 return delegate_->GetDialogArgs();
120 else
121 return std::string();
107 } 122 }
108 123
109 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { 124 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
110 delegate_->OnDialogClosed(json_retval); 125 HtmlDialogUIDelegate* dialog_delegate = delegate_;
111 delegate_ = NULL; // We will not communicate further with the delegate. 126 delegate_ = NULL; // We will not communicate further with the delegate.
127 dialog_delegate->OnDialogClosed(json_retval);
112 window()->Close(); 128 window()->Close();
113 } 129 }
114 130
115 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
116 // TabContentsDelegate implementation: 132 // TabContentsDelegate implementation:
117 133
118 void HtmlDialogView::OpenURLFromTab(TabContents* source, 134 void HtmlDialogView::OpenURLFromTab(TabContents* source,
119 const GURL& url, 135 const GURL& url,
120 const GURL& referrer, 136 const GURL& referrer,
121 WindowOpenDisposition disposition, 137 WindowOpenDisposition disposition,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 211
196 tab_contents_->set_delegate(this); 212 tab_contents_->set_delegate(this);
197 213
198 // Set the delegate. This must be done before loading the page. See 214 // Set the delegate. This must be done before loading the page. See
199 // the comment above HtmlDialogUI in its header file for why. 215 // the comment above HtmlDialogUI in its header file for why.
200 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), 216 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(),
201 this); 217 this);
202 218
203 DOMView::LoadURL(delegate_->GetDialogContentURL()); 219 DOMView::LoadURL(delegate_->GetDialogContentURL());
204 } 220 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698