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

Side by Side Diff: chrome/browser/dom_ui/html_dialog_ui.cc

Issue 131094: Add GetMessageHandlers to HtmlDialogUIDelegate to allow... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/browser/dom_ui/html_dialog_ui.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | 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/dom_ui/html_dialog_ui.h" 5 #include "chrome/browser/dom_ui/html_dialog_ui.h"
6 6
7 #include "base/singleton.h" 7 #include "base/singleton.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/browser/renderer_host/render_view_host.h" 10 #include "chrome/browser/renderer_host/render_view_host.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { 56 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) {
57 // Hook up the javascript function calls, also known as chrome.send("foo") 57 // Hook up the javascript function calls, also known as chrome.send("foo")
58 // calls in the HTML, to the actual C++ functions. 58 // calls in the HTML, to the actual C++ functions.
59 RegisterMessageCallback("DialogClose", 59 RegisterMessageCallback("DialogClose",
60 NewCallback(this, &HtmlDialogUI::OnDialogClosed)); 60 NewCallback(this, &HtmlDialogUI::OnDialogClosed));
61 61
62 // Pass the arguments to the renderer supplied by the delegate. 62 // Pass the arguments to the renderer supplied by the delegate.
63 std::string dialog_args; 63 std::string dialog_args;
64 std::vector<DOMMessageHandler*> handlers;
64 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( 65 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty(
65 tab_contents()->property_bag()); 66 tab_contents()->property_bag());
66 if (delegate) 67 if (delegate) {
67 dialog_args = (*delegate)->GetDialogArgs(); 68 dialog_args = (*delegate)->GetDialogArgs();
69 (*delegate)->GetDOMMessageHandlers(&handlers);
70 }
71
68 render_view_host->SetDOMUIProperty("dialogArguments", dialog_args); 72 render_view_host->SetDOMUIProperty("dialogArguments", dialog_args);
73 for (std::vector<DOMMessageHandler*>::iterator it = handlers.begin();
74 it != handlers.end(); ++it) {
75 (*it)->Attach(this);
76 AddMessageHandler(*it);
77 }
69 } 78 }
70 79
71 void HtmlDialogUI::OnDialogClosed(const Value* content) { 80 void HtmlDialogUI::OnDialogClosed(const Value* content) {
72 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( 81 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty(
73 tab_contents()->property_bag()); 82 tab_contents()->property_bag());
74 if (delegate) 83 if (delegate)
75 (*delegate)->OnDialogClosed(GetJsonResponse(content)); 84 (*delegate)->OnDialogClosed(GetJsonResponse(content));
76 } 85 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/html_dialog_ui.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698