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

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

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: 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 "ui/web_dialogs/web_dialog_delegate.h"
16 #include "chrome/browser/ui/webui/web_dialog_ui.h" 16 #include "ui/web_dialogs/web_dialog_ui.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_ui.h" 21 #include "content/public/browser/web_ui.h"
22 22
23 using content::RenderViewHost; 23 using content::RenderViewHost;
24 using content::WebContents; 24 using content::WebContents;
25 using content::WebUIMessageHandler; 25 using content::WebUIMessageHandler;
26 26
27 static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> > 27 static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> >
28 g_constrained_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; 28 g_constrained_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER;
29 29
30 ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui) 30 ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui)
31 : WebUIController(web_ui) { 31 : WebUIController(web_ui) {
32 } 32 }
33 33
34 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { 34 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() {
35 } 35 }
36 36
37 void ConstrainedWebDialogUI::RenderViewCreated( 37 void ConstrainedWebDialogUI::RenderViewCreated(
38 RenderViewHost* render_view_host) { 38 RenderViewHost* render_view_host) {
39 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 39 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
40 if (!delegate) 40 if (!delegate)
41 return; 41 return;
42 42
43 WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); 43 web_dialogs::WebDialogDelegate* dialog_delegate =
44 delegate->GetWebDialogDelegate();
44 std::vector<WebUIMessageHandler*> handlers; 45 std::vector<WebUIMessageHandler*> handlers;
45 dialog_delegate->GetWebUIMessageHandlers(&handlers); 46 dialog_delegate->GetWebUIMessageHandlers(&handlers);
46 render_view_host->SetWebUIProperty("dialogArguments", 47 render_view_host->SetWebUIProperty("dialogArguments",
47 dialog_delegate->GetDialogArgs()); 48 dialog_delegate->GetDialogArgs());
48 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 49 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
49 it != handlers.end(); ++it) { 50 it != handlers.end(); ++it) {
50 web_ui()->AddMessageHandler(*it); 51 web_ui()->AddMessageHandler(*it);
51 } 52 }
52 53
53 // Add a "DialogClose" callback which matches WebDialogUI behavior. 54 // Add a "DialogClose" callback which matches WebDialogUI behavior.
(...skipping 23 matching lines...) Expand all
77 ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty( 78 ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty(
78 web_ui()->GetWebContents()->GetPropertyBag()); 79 web_ui()->GetWebContents()->GetPropertyBag());
79 return property ? *property : NULL; 80 return property ? *property : NULL;
80 } 81 }
81 82
82 // static 83 // static
83 base::PropertyAccessor<ConstrainedWebDialogDelegate*>& 84 base::PropertyAccessor<ConstrainedWebDialogDelegate*>&
84 ConstrainedWebDialogUI::GetPropertyAccessor() { 85 ConstrainedWebDialogUI::GetPropertyAccessor() {
85 return g_constrained_web_dialog_ui_property_accessor.Get(); 86 return g_constrained_web_dialog_ui_property_accessor.Get();
86 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698