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

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

Issue 8113018: [web-ui] Migrate RegisterMessageCallback usage to base::bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/constrained_html_ui.h" 5 #include "chrome/browser/ui/webui/constrained_html_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
10 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
11 #include "base/values.h" 13 #include "base/values.h"
12 #include "chrome/browser/ui/webui/html_dialog_ui.h" 14 #include "chrome/browser/ui/webui/html_dialog_ui.h"
13 #include "content/browser/renderer_host/render_view_host.h" 15 #include "content/browser/renderer_host/render_view_host.h"
14 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
15 17
16 static base::LazyInstance<PropertyAccessor<ConstrainedHtmlUIDelegate*> > 18 static base::LazyInstance<PropertyAccessor<ConstrainedHtmlUIDelegate*> >
17 g_constrained_html_ui_property_accessor(base::LINKER_INITIALIZED); 19 g_constrained_html_ui_property_accessor(base::LINKER_INITIALIZED);
18 20
19 ConstrainedHtmlUI::ConstrainedHtmlUI(TabContents* contents) 21 ConstrainedHtmlUI::ConstrainedHtmlUI(TabContents* contents)
(...skipping 14 matching lines...) Expand all
34 render_view_host->SetWebUIProperty("dialogArguments", 36 render_view_host->SetWebUIProperty("dialogArguments",
35 dialog_delegate->GetDialogArgs()); 37 dialog_delegate->GetDialogArgs());
36 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 38 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
37 it != handlers.end(); ++it) { 39 it != handlers.end(); ++it) {
38 (*it)->Attach(this); 40 (*it)->Attach(this);
39 AddMessageHandler(*it); 41 AddMessageHandler(*it);
40 } 42 }
41 43
42 // Add a "DialogClose" callback which matches HTMLDialogUI behavior. 44 // Add a "DialogClose" callback which matches HTMLDialogUI behavior.
43 RegisterMessageCallback("DialogClose", 45 RegisterMessageCallback("DialogClose",
44 NewCallback(this, &ConstrainedHtmlUI::OnDialogCloseMessage)); 46 base::Bind(&ConstrainedHtmlUI::OnDialogCloseMessage,
47 base::Unretained(this)));
45 } 48 }
46 49
47 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { 50 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) {
48 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); 51 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate();
49 if (!delegate) 52 if (!delegate)
50 return; 53 return;
51 54
52 std::string json_retval; 55 std::string json_retval;
53 if (!args->empty() && !args->GetString(0, &json_retval)) 56 if (!args->empty() && !args->GetString(0, &json_retval))
54 NOTREACHED() << "Could not read JSON argument"; 57 NOTREACHED() << "Could not read JSON argument";
55 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); 58 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval);
56 delegate->OnDialogCloseFromWebUI(); 59 delegate->OnDialogCloseFromWebUI();
57 } 60 }
58 61
59 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { 62 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() {
60 ConstrainedHtmlUIDelegate** property = 63 ConstrainedHtmlUIDelegate** property =
61 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); 64 GetPropertyAccessor().GetProperty(tab_contents()->property_bag());
62 return property ? *property : NULL; 65 return property ? *property : NULL;
63 } 66 }
64 67
65 // static 68 // static
66 PropertyAccessor<ConstrainedHtmlUIDelegate*>& 69 PropertyAccessor<ConstrainedHtmlUIDelegate*>&
67 ConstrainedHtmlUI::GetPropertyAccessor() { 70 ConstrainedHtmlUI::GetPropertyAccessor() {
68 return g_constrained_html_ui_property_accessor.Get(); 71 return g_constrained_html_ui_property_accessor.Get();
69 } 72 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/collected_cookies_ui_delegate.cc ('k') | chrome/browser/ui/webui/cookies_tree_model_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698