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

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

Issue 7861024: Adds testing infrastructure to web_ui_browsertest to support testing HtmlDialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove inline override function declaration for clang. 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
« no previous file with comments | « chrome/browser/ui/webui/chrome_web_ui.cc ('k') | chrome/browser/ui/webui/web_ui_browsertest.h » ('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) 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 "chrome/common/chrome_notification_types.h"
10 #include "content/browser/renderer_host/render_view_host.h" 11 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/tab_contents/tab_contents.h" 12 #include "content/browser/tab_contents/tab_contents.h"
12 #include "content/common/bindings_policy.h" 13 #include "content/common/bindings_policy.h"
14 #include "content/common/notification_service.h"
13 15
14 static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > 16 static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> >
15 g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); 17 g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED);
16 18
17 HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents) 19 HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents)
18 : ChromeWebUI(tab_contents) { 20 : ChromeWebUI(tab_contents) {
19 } 21 }
20 22
21 HtmlDialogUI::~HtmlDialogUI() { 23 HtmlDialogUI::~HtmlDialogUI() {
22 // Don't unregister our property. During the teardown of the TabContents, 24 // Don't unregister our property. During the teardown of the TabContents,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 (*delegate)->GetWebUIMessageHandlers(&handlers); 59 (*delegate)->GetWebUIMessageHandlers(&handlers);
58 } 60 }
59 61
60 if (0 != (bindings_ & BindingsPolicy::WEB_UI)) 62 if (0 != (bindings_ & BindingsPolicy::WEB_UI))
61 render_view_host->SetWebUIProperty("dialogArguments", dialog_args); 63 render_view_host->SetWebUIProperty("dialogArguments", dialog_args);
62 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 64 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
63 it != handlers.end(); ++it) { 65 it != handlers.end(); ++it) {
64 (*it)->Attach(this); 66 (*it)->Attach(this);
65 AddMessageHandler(*it); 67 AddMessageHandler(*it);
66 } 68 }
69
70 NotificationService::current()->Notify(
71 chrome::NOTIFICATION_HTML_DIALOG_SHOWN,
72 Source<HtmlDialogUI>(this),
73 NotificationService::NoDetails());
67 } 74 }
68 75
69 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { 76 void HtmlDialogUI::OnDialogClosed(const ListValue* args) {
70 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( 77 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty(
71 tab_contents()->property_bag()); 78 tab_contents()->property_bag());
72 if (delegate) { 79 if (delegate) {
73 std::string json_retval; 80 std::string json_retval;
74 if (args && !args->empty() && !args->GetString(0, &json_retval)) 81 if (args && !args->empty() && !args->GetString(0, &json_retval))
75 NOTREACHED() << "Could not read JSON argument"; 82 NOTREACHED() << "Could not read JSON argument";
76 83
77 (*delegate)->OnDialogClosed(json_retval); 84 (*delegate)->OnDialogClosed(json_retval);
78 } 85 }
79 } 86 }
80 87
81 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) 88 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents)
82 : HtmlDialogUI(tab_contents) { 89 : HtmlDialogUI(tab_contents) {
83 // Non-file based UI needs to not have access to the Web UI bindings 90 // Non-file based UI needs to not have access to the Web UI bindings
84 // for security reasons. The code hosting the dialog should provide 91 // for security reasons. The code hosting the dialog should provide
85 // dialog specific functionality through other bindings and methods 92 // dialog specific functionality through other bindings and methods
86 // that are scoped in duration to the dialogs existence. 93 // that are scoped in duration to the dialogs existence.
87 bindings_ &= ~BindingsPolicy::WEB_UI; 94 bindings_ &= ~BindingsPolicy::WEB_UI;
88 } 95 }
89 96
90 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { 97 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() {
91 } 98 }
92 99
93 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { 100 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) {
94 return false; 101 return false;
95 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_web_ui.cc ('k') | chrome/browser/ui/webui/web_ui_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698