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

Side by Side Diff: chrome/browser/extensions/extensions_ui.cc

Issue 126137: Part 1 of merging Extensions and DOMUI (Closed)
Patch Set: add test and rebase Created 11 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/extensions/extensions_ui.h" 5 #include "chrome/browser/extensions/extensions_ui.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/thread.h" 10 #include "base/thread.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 views->Append(view_value); 219 views->Append(view_value);
220 } 220 }
221 extension_data->Set(L"views", views); 221 extension_data->Set(L"views", views);
222 222
223 return extension_data; 223 return extension_data;
224 } 224 }
225 225
226 std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension( 226 std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension(
227 const std::string& extension_id) { 227 const std::string& extension_id) {
228 std::vector<ExtensionPage> result; 228 std::vector<ExtensionPage> result;
229 std::set<ExtensionFunctionDispatcher*>* all_instances =
230 ExtensionFunctionDispatcher::all_instances();
229 231
230 ExtensionMessageService* ems = ExtensionMessageService::GetInstance( 232 for (std::set<ExtensionFunctionDispatcher*>::iterator iter =
231 dom_ui_->GetProfile()->GetOriginalProfile()->GetRequestContext()); 233 all_instances->begin(); iter != all_instances->end(); ++iter) {
232 RenderProcessHost* process_host = ems->GetProcessForExtension(extension_id); 234 RenderViewHost* view = (*iter)->render_view_host();
233 if (!process_host) 235 if ((*iter)->extension_id() == extension_id && view) {
234 return result; 236 result.push_back(ExtensionPage((*iter)->url(),
235 237 view->process()->pid(),
236 RenderProcessHost::listeners_iterator iter; 238 view->routing_id()));
237 for (iter = process_host->listeners_begin();
238 iter != process_host->listeners_end(); ++iter) {
239 // NOTE: This is a bit dangerous. We know that for now, listeners are
240 // always RenderWidgetHosts. But in theory, they don't have to be.
241 RenderWidgetHost* widget = static_cast<RenderWidgetHost*>(iter->second);
242 if (!widget->IsRenderView())
243 continue;
244
245 RenderViewHost* view = static_cast<RenderViewHost*>(widget);
246 ExtensionFunctionDispatcher* efd = view->extension_function_dispatcher();
247 if (efd && efd->extension_id() == extension_id) {
248 ExtensionPage page(view->delegate()->GetURL(),
249 process_host->pid(),
250 view->routing_id());
251 result.push_back(page);
252 } 239 }
253 } 240 }
254 241
255 return result; 242 return result;
256 } 243 }
257 244
258 ExtensionsDOMHandler::~ExtensionsDOMHandler() { 245 ExtensionsDOMHandler::~ExtensionsDOMHandler() {
259 } 246 }
260 247
261 // ExtensionsDOMHandler, public: ----------------------------------------------- 248 // ExtensionsDOMHandler, public: -----------------------------------------------
262 249
263 ExtensionsUI::ExtensionsUI(TabContents* contents) : DOMUI(contents) { 250 ExtensionsUI::ExtensionsUI(TabContents* contents) : DOMUI(contents) {
264 ExtensionsService *exstension_service = 251 ExtensionsService *exstension_service =
265 GetProfile()->GetOriginalProfile()->GetExtensionsService(); 252 GetProfile()->GetOriginalProfile()->GetExtensionsService();
266 253
267 ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(exstension_service); 254 ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(exstension_service);
268 AddMessageHandler(handler); 255 AddMessageHandler(handler);
269 handler->Attach(this); 256 handler->Attach(this);
270 257
271 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); 258 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource();
272 259
273 // Set up the chrome://extensions/ source. 260 // Set up the chrome://extensions/ source.
274 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 261 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
275 NewRunnableMethod(&chrome_url_data_manager, 262 NewRunnableMethod(&chrome_url_data_manager,
276 &ChromeURLDataManager::AddDataSource, html_source)); 263 &ChromeURLDataManager::AddDataSource, html_source));
277 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_startup_unittest.cc ('k') | chrome/browser/external_tab_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698