OLD | NEW |
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/conflicts_ui.h" | 5 #include "chrome/browser/ui/webui/conflicts_ui.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/enumerate_modules_model_win.h" | 14 #include "chrome/browser/enumerate_modules_model_win.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/jstemplate_builder.h" | 18 #include "chrome/common/jstemplate_builder.h" |
18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
19 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
20 #include "content/browser/user_metrics.h" | 21 #include "content/browser/user_metrics.h" |
21 #include "content/common/notification_observer.h" | 22 #include "content/common/notification_observer.h" |
22 #include "content/common/notification_registrar.h" | 23 #include "content/common/notification_registrar.h" |
23 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
24 #include "grit/browser_resources.h" | 25 #include "grit/browser_resources.h" |
25 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 // WebUIMessageHandler implementation. | 123 // WebUIMessageHandler implementation. |
123 virtual void RegisterMessages(); | 124 virtual void RegisterMessages(); |
124 | 125 |
125 // Callback for the "requestModuleList" message. | 126 // Callback for the "requestModuleList" message. |
126 void HandleRequestModuleList(const ListValue* args); | 127 void HandleRequestModuleList(const ListValue* args); |
127 | 128 |
128 private: | 129 private: |
129 void SendModuleList(); | 130 void SendModuleList(); |
130 | 131 |
131 void Observe(NotificationType type, | 132 void Observe(int type, |
132 const NotificationSource& source, | 133 const NotificationSource& source, |
133 const NotificationDetails& details); | 134 const NotificationDetails& details); |
134 | 135 |
135 NotificationRegistrar registrar_; | 136 NotificationRegistrar registrar_; |
136 | 137 |
137 DISALLOW_COPY_AND_ASSIGN(ConflictsDOMHandler); | 138 DISALLOW_COPY_AND_ASSIGN(ConflictsDOMHandler); |
138 }; | 139 }; |
139 | 140 |
140 void ConflictsDOMHandler::RegisterMessages() { | 141 void ConflictsDOMHandler::RegisterMessages() { |
141 web_ui_->RegisterMessageCallback("requestModuleList", | 142 web_ui_->RegisterMessageCallback("requestModuleList", |
142 NewCallback(this, &ConflictsDOMHandler::HandleRequestModuleList)); | 143 NewCallback(this, &ConflictsDOMHandler::HandleRequestModuleList)); |
143 } | 144 } |
144 | 145 |
145 void ConflictsDOMHandler::HandleRequestModuleList(const ListValue* args) { | 146 void ConflictsDOMHandler::HandleRequestModuleList(const ListValue* args) { |
146 // This request is handled asynchronously. See Observe for when we reply back. | 147 // This request is handled asynchronously. See Observe for when we reply back. |
147 registrar_.Add(this, NotificationType::MODULE_LIST_ENUMERATED, | 148 registrar_.Add(this, chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, |
148 NotificationService::AllSources()); | 149 NotificationService::AllSources()); |
149 EnumerateModulesModel::GetInstance()->ScanNow(); | 150 EnumerateModulesModel::GetInstance()->ScanNow(); |
150 } | 151 } |
151 | 152 |
152 void ConflictsDOMHandler::SendModuleList() { | 153 void ConflictsDOMHandler::SendModuleList() { |
153 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); | 154 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); |
154 ListValue* list = loaded_modules->GetModuleList(); | 155 ListValue* list = loaded_modules->GetModuleList(); |
155 DictionaryValue results; | 156 DictionaryValue results; |
156 results.Set("moduleList", list); | 157 results.Set("moduleList", list); |
157 | 158 |
(...skipping 10 matching lines...) Expand all Loading... |
168 IDS_CONFLICTS_CHECK_PAGE_TABLE_TITLE_SUFFIX_TWO, | 169 IDS_CONFLICTS_CHECK_PAGE_TABLE_TITLE_SUFFIX_TWO, |
169 base::IntToString16(list->GetSize()), | 170 base::IntToString16(list->GetSize()), |
170 base::IntToString16(confirmed_bad), | 171 base::IntToString16(confirmed_bad), |
171 base::IntToString16(suspected_bad)); | 172 base::IntToString16(suspected_bad)); |
172 } | 173 } |
173 results.SetString("modulesTableTitle", table_title); | 174 results.SetString("modulesTableTitle", table_title); |
174 | 175 |
175 web_ui_->CallJavascriptFunction("returnModuleList", results); | 176 web_ui_->CallJavascriptFunction("returnModuleList", results); |
176 } | 177 } |
177 | 178 |
178 void ConflictsDOMHandler::Observe(NotificationType type, | 179 void ConflictsDOMHandler::Observe(int type, |
179 const NotificationSource& source, | 180 const NotificationSource& source, |
180 const NotificationDetails& details) { | 181 const NotificationDetails& details) { |
181 switch (type.value) { | 182 switch (type) { |
182 case NotificationType::MODULE_LIST_ENUMERATED: | 183 case chrome::NOTIFICATION_MODULE_LIST_ENUMERATED: |
183 SendModuleList(); | 184 SendModuleList(); |
184 registrar_.RemoveAll(); | 185 registrar_.RemoveAll(); |
185 break; | 186 break; |
186 default: | 187 default: |
187 NOTREACHED(); | 188 NOTREACHED(); |
188 break; | 189 break; |
189 } | 190 } |
190 } | 191 } |
191 | 192 |
192 } // namespace | 193 } // namespace |
(...skipping 16 matching lines...) Expand all Loading... |
209 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 210 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
210 } | 211 } |
211 | 212 |
212 // static | 213 // static |
213 RefCountedMemory* ConflictsUI::GetFaviconResourceBytes() { | 214 RefCountedMemory* ConflictsUI::GetFaviconResourceBytes() { |
214 return ResourceBundle::GetSharedInstance(). | 215 return ResourceBundle::GetSharedInstance(). |
215 LoadDataResourceBytes(IDR_CONFLICT_FAVICON); | 216 LoadDataResourceBytes(IDR_CONFLICT_FAVICON); |
216 } | 217 } |
217 | 218 |
218 #endif | 219 #endif |
OLD | NEW |