OLD | NEW |
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/dom_ui/html_dialog_ui.h" | 5 #include "chrome/browser/dom_ui/html_dialog_ui.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/singleton.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/dom_ui/dom_ui_util.h" | 10 #include "chrome/browser/dom_ui/dom_ui_util.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/browser/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
13 #include "chrome/common/bindings_policy.h" | 13 #include "chrome/common/bindings_policy.h" |
14 | 14 |
| 15 static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > |
| 16 g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); |
| 17 |
15 HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents) : DOMUI(tab_contents) { | 18 HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents) : DOMUI(tab_contents) { |
16 } | 19 } |
17 | 20 |
18 HtmlDialogUI::~HtmlDialogUI() { | 21 HtmlDialogUI::~HtmlDialogUI() { |
19 // Don't unregister our property. During the teardown of the TabContents, | 22 // Don't unregister our property. During the teardown of the TabContents, |
20 // this will be deleted, but the TabContents will already be destroyed. | 23 // this will be deleted, but the TabContents will already be destroyed. |
21 // | 24 // |
22 // This object is owned indirectly by the TabContents. DOMUIs can change, so | 25 // This object is owned indirectly by the TabContents. DOMUIs can change, so |
23 // it's scary if this DOMUI is changed out and replaced with something else, | 26 // it's scary if this DOMUI is changed out and replaced with something else, |
24 // since the property will still point to the old delegate. But the delegate | 27 // since the property will still point to the old delegate. But the delegate |
25 // is itself the owner of the TabContents for a dialog so will be in scope, | 28 // is itself the owner of the TabContents for a dialog so will be in scope, |
26 // and the HTML dialogs won't swap DOMUIs anyway since they don't navigate. | 29 // and the HTML dialogs won't swap DOMUIs anyway since they don't navigate. |
27 } | 30 } |
28 | 31 |
29 // static | 32 // static |
30 PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() { | 33 PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() { |
31 return *Singleton< PropertyAccessor<HtmlDialogUIDelegate*> >::get(); | 34 return g_html_dialog_ui_property_accessor.Get(); |
32 } | 35 } |
33 | 36 |
34 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
35 // Private: | 38 // Private: |
36 | 39 |
37 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { | 40 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { |
38 // Hook up the javascript function calls, also known as chrome.send("foo") | 41 // Hook up the javascript function calls, also known as chrome.send("foo") |
39 // calls in the HTML, to the actual C++ functions. | 42 // calls in the HTML, to the actual C++ functions. |
40 RegisterMessageCallback("DialogClose", | 43 RegisterMessageCallback("DialogClose", |
41 NewCallback(this, &HtmlDialogUI::OnDialogClosed)); | 44 NewCallback(this, &HtmlDialogUI::OnDialogClosed)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // that are scoped in duration to the dialogs existence. | 79 // that are scoped in duration to the dialogs existence. |
77 bindings_ &= ~BindingsPolicy::DOM_UI; | 80 bindings_ &= ~BindingsPolicy::DOM_UI; |
78 } | 81 } |
79 | 82 |
80 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { | 83 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { |
81 } | 84 } |
82 | 85 |
83 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { | 86 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { |
84 return false; | 87 return false; |
85 } | 88 } |
OLD | NEW |