OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 // Overridden from View: | 52 // Overridden from View: |
53 void Init() override; | 53 void Init() override; |
54 | 54 |
55 protected: | 55 protected: |
56 using ResourcesMap = | 56 using ResourcesMap = |
57 base::hash_map<std::string, scoped_refptr<base::RefCountedMemory>>; | 57 base::hash_map<std::string, scoped_refptr<base::RefCountedMemory>>; |
58 | 58 |
59 content::WebUI* web_ui() { return web_ui_; } | 59 content::WebUI* web_ui() { return web_ui_; } |
60 | 60 |
61 template <typename T> | 61 template <typename T, typename... Args> |
62 void AddCallback(const std::string& name, void (T::*method)()) { | 62 void AddCallback(const std::string& name, void (T::*method)(Args...)) { |
63 base::Callback<void()> callback = | 63 base::Callback<void(Args...)> callback = |
64 base::Bind(method, base::Unretained(static_cast<T*>(this))); | 64 base::Bind(method, base::Unretained(static_cast<T*>(this))); |
65 web_ui_->RegisterMessageCallback( | 65 web_ui_->RegisterMessageCallback( |
66 name, base::Bind(&::login::CallbackWrapper0, callback)); | 66 name, base::Bind(&::login::CallbackWrapper<Args...>, callback)); |
67 } | |
68 | |
69 template <typename T, typename A1> | |
70 void AddCallback(const std::string& name, void (T::*method)(A1 arg1)) { | |
71 base::Callback<void(A1)> callback = | |
72 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
73 web_ui_->RegisterMessageCallback( | |
74 name, base::Bind(&::login::CallbackWrapper1<A1>, callback)); | |
75 } | 67 } |
76 | 68 |
77 // Overridden from View: | 69 // Overridden from View: |
78 void OnReady() override; | 70 void OnReady() override; |
79 void OnContextChanged(const base::DictionaryValue& diff) override; | 71 void OnContextChanged(const base::DictionaryValue& diff) override; |
80 | 72 |
81 virtual void AddLocalizedValues(::login::LocalizedValuesBuilder* builder) = 0; | 73 virtual void AddLocalizedValues(::login::LocalizedValuesBuilder* builder) = 0; |
82 virtual void AddResources(ResourcesMap* resources_map) = 0; | 74 virtual void AddResources(ResourcesMap* resources_map) = 0; |
83 | 75 |
84 private: | 76 private: |
(...skipping 22 matching lines...) Expand all Loading... |
107 bool html_ready_; | 99 bool html_ready_; |
108 bool view_bound_; | 100 bool view_bound_; |
109 scoped_ptr<Context> pending_context_changes_; | 101 scoped_ptr<Context> pending_context_changes_; |
110 | 102 |
111 DISALLOW_COPY_AND_ASSIGN(WebUIView); | 103 DISALLOW_COPY_AND_ASSIGN(WebUIView); |
112 }; | 104 }; |
113 | 105 |
114 } // namespace webui_generator | 106 } // namespace webui_generator |
115 | 107 |
116 #endif // CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ | 108 #endif // CHROME_BROWSER_UI_WEBUI_WUG_WEB_UI_VIEW_H_ |
OLD | NEW |