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

Side by Side Diff: chrome/browser/ui/webui/html_dialog_ui.cc

Issue 7957002: Reland add --use-more-webui runtime flag to toggle WebUI replacements for native dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk. Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/html_dialog_ui.h" 5 #include "chrome/browser/ui/webui/html_dialog_ui.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
(...skipping 11 matching lines...) Expand all
22 // Don't unregister our property. During the teardown of the TabContents, 22 // Don't unregister our property. During the teardown of the TabContents,
23 // this will be deleted, but the TabContents will already be destroyed. 23 // this will be deleted, but the TabContents will already be destroyed.
24 // 24 //
25 // This object is owned indirectly by the TabContents. WebUIs can change, so 25 // This object is owned indirectly by the TabContents. WebUIs can change, so
26 // it's scary if this WebUI is changed out and replaced with something else, 26 // it's scary if this WebUI is changed out and replaced with something else,
27 // 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
28 // 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,
29 // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. 29 // and the HTML dialogs won't swap WebUIs anyway since they don't navigate.
30 } 30 }
31 31
32 void HtmlDialogUI::CloseDialog(const base::ListValue* args) {
33 OnDialogClosed(args);
34 }
35
32 // static 36 // static
33 PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() { 37 PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() {
34 return g_html_dialog_ui_property_accessor.Get(); 38 return g_html_dialog_ui_property_accessor.Get();
35 } 39 }
36 40
37 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
38 // Private: 42 // Private:
39 43
40 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { 44 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) {
41 // Hook up the javascript function calls, also known as chrome.send("foo") 45 // Hook up the javascript function calls, also known as chrome.send("foo")
(...skipping 18 matching lines...) Expand all
60 (*it)->Attach(this); 64 (*it)->Attach(this);
61 AddMessageHandler(*it); 65 AddMessageHandler(*it);
62 } 66 }
63 } 67 }
64 68
65 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { 69 void HtmlDialogUI::OnDialogClosed(const ListValue* args) {
66 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( 70 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty(
67 tab_contents()->property_bag()); 71 tab_contents()->property_bag());
68 if (delegate) { 72 if (delegate) {
69 std::string json_retval; 73 std::string json_retval;
70 if (!args->GetString(0, &json_retval)) 74 if (args && !args->empty() && !args->GetString(0, &json_retval))
71 NOTREACHED() << "Could not read JSON arguments"; 75 NOTREACHED() << "Could not read JSON argument";
72 76
73 (*delegate)->OnDialogClosed(json_retval); 77 (*delegate)->OnDialogClosed(json_retval);
74 } 78 }
75 } 79 }
76 80
77 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) 81 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents)
78 : HtmlDialogUI(tab_contents) { 82 : HtmlDialogUI(tab_contents) {
79 // Non-file based UI needs to not have access to the Web UI bindings 83 // Non-file based UI needs to not have access to the Web UI bindings
80 // for security reasons. The code hosting the dialog should provide 84 // for security reasons. The code hosting the dialog should provide
81 // dialog specific functionality through other bindings and methods 85 // dialog specific functionality through other bindings and methods
82 // that are scoped in duration to the dialogs existence. 86 // that are scoped in duration to the dialogs existence.
83 bindings_ &= ~BindingsPolicy::WEB_UI; 87 bindings_ &= ~BindingsPolicy::WEB_UI;
84 } 88 }
85 89
86 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { 90 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() {
87 } 91 }
88 92
89 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { 93 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) {
90 return false; 94 return false;
91 } 95 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_ui.h ('k') | chrome/browser/ui/webui/hung_renderer_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698