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

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

Issue 10332231: Remove chrome::NOTIFICATION_WEB_DIALOG_SHOWN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add web_dialog_observer.h to chrome_browser.gypi Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/constrained_web_dialog_ui.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/property_bag.h" 13 #include "base/property_bag.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/ui/webui/web_dialog_delegate.h" 15 #include "chrome/browser/ui/webui/web_dialog_delegate.h"
16 #include "chrome/browser/ui/webui/web_dialog_ui.h" 16 #include "chrome/browser/ui/webui/web_dialog_ui.h"
17 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
22 21
23 using content::RenderViewHost; 22 using content::RenderViewHost;
24 using content::WebContents; 23 using content::WebContents;
25 using content::WebUIMessageHandler; 24 using content::WebUIMessageHandler;
26 25
27 static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> > 26 static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> >
(...skipping 20 matching lines...) Expand all
48 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 47 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
49 it != handlers.end(); ++it) { 48 it != handlers.end(); ++it) {
50 web_ui()->AddMessageHandler(*it); 49 web_ui()->AddMessageHandler(*it);
51 } 50 }
52 51
53 // Add a "DialogClose" callback which matches WebDialogUI behavior. 52 // Add a "DialogClose" callback which matches WebDialogUI behavior.
54 web_ui()->RegisterMessageCallback("DialogClose", 53 web_ui()->RegisterMessageCallback("DialogClose",
55 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage, 54 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage,
56 base::Unretained(this))); 55 base::Unretained(this)));
57 56
58 content::NotificationService::current()->Notify( 57 dialog_delegate->OnDialogShown(web_ui(), render_view_host);
59 chrome::NOTIFICATION_WEB_DIALOG_SHOWN,
60 content::Source<content::WebUI>(web_ui()),
61 content::Details<RenderViewHost>(render_view_host));
62 } 58 }
63 59
64 void ConstrainedWebDialogUI::OnDialogCloseMessage(const ListValue* args) { 60 void ConstrainedWebDialogUI::OnDialogCloseMessage(const ListValue* args) {
65 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 61 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
66 if (!delegate) 62 if (!delegate)
67 return; 63 return;
68 64
69 std::string json_retval; 65 std::string json_retval;
70 if (!args->empty() && !args->GetString(0, &json_retval)) 66 if (!args->empty() && !args->GetString(0, &json_retval))
71 NOTREACHED() << "Could not read JSON argument"; 67 NOTREACHED() << "Could not read JSON argument";
72 delegate->GetWebDialogDelegate()->OnDialogClosed(json_retval); 68 delegate->GetWebDialogDelegate()->OnDialogClosed(json_retval);
73 delegate->OnDialogCloseFromWebUI(); 69 delegate->OnDialogCloseFromWebUI();
74 } 70 }
75 71
76 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { 72 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() {
77 ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty( 73 ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty(
78 web_ui()->GetWebContents()->GetPropertyBag()); 74 web_ui()->GetWebContents()->GetPropertyBag());
79 return property ? *property : NULL; 75 return property ? *property : NULL;
80 } 76 }
81 77
82 // static 78 // static
83 base::PropertyAccessor<ConstrainedWebDialogDelegate*>& 79 base::PropertyAccessor<ConstrainedWebDialogDelegate*>&
84 ConstrainedWebDialogUI::GetPropertyAccessor() { 80 ConstrainedWebDialogUI::GetPropertyAccessor() {
85 return g_constrained_web_dialog_ui_property_accessor.Get(); 81 return g_constrained_web_dialog_ui_property_accessor.Get();
86 } 82 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/certificate_viewer_webui.cc ('k') | chrome/browser/ui/webui/web_dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698