OLD | NEW |
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/extensions/api/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
6 | 6 |
7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "apps/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
10 #include "apps/shell_window.h" | 10 #include "apps/shell_window.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 info->may_disable = system->management_policy()-> | 336 info->may_disable = system->management_policy()-> |
337 UserMayModifySettings(&item, NULL); | 337 UserMayModifySettings(&item, NULL); |
338 info->is_app = item.is_app(); | 338 info->is_app = item.is_app(); |
339 info->views = GetInspectablePagesForExtension(&item, item_is_enabled); | 339 info->views = GetInspectablePagesForExtension(&item, item_is_enabled); |
340 | 340 |
341 return info.Pass(); | 341 return info.Pass(); |
342 } | 342 } |
343 | 343 |
344 void DeveloperPrivateGetItemsInfoFunction:: | 344 void DeveloperPrivateGetItemsInfoFunction:: |
345 GetInspectablePagesForExtensionProcess( | 345 GetInspectablePagesForExtensionProcess( |
| 346 const Extension* extension, |
346 const std::set<content::RenderViewHost*>& views, | 347 const std::set<content::RenderViewHost*>& views, |
347 ItemInspectViewList* result) { | 348 ItemInspectViewList* result) { |
| 349 bool has_generated_background_page = |
| 350 BackgroundInfo::HasGeneratedBackgroundPage(extension); |
348 for (std::set<content::RenderViewHost*>::const_iterator iter = views.begin(); | 351 for (std::set<content::RenderViewHost*>::const_iterator iter = views.begin(); |
349 iter != views.end(); ++iter) { | 352 iter != views.end(); ++iter) { |
350 content::RenderViewHost* host = *iter; | 353 content::RenderViewHost* host = *iter; |
351 content::WebContents* web_contents = | 354 content::WebContents* web_contents = |
352 content::WebContents::FromRenderViewHost(host); | 355 content::WebContents::FromRenderViewHost(host); |
353 ViewType host_type = GetViewType(web_contents); | 356 ViewType host_type = GetViewType(web_contents); |
354 if (VIEW_TYPE_EXTENSION_POPUP == host_type || | 357 if (VIEW_TYPE_EXTENSION_POPUP == host_type || |
355 VIEW_TYPE_EXTENSION_DIALOG == host_type) | 358 VIEW_TYPE_EXTENSION_DIALOG == host_type) |
356 continue; | 359 continue; |
357 | 360 |
358 content::RenderProcessHost* process = host->GetProcess(); | 361 content::RenderProcessHost* process = host->GetProcess(); |
359 result->push_back( | 362 bool is_background_page = |
360 constructInspectView(web_contents->GetURL(), | 363 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension)); |
361 process->GetID(), | 364 result->push_back(constructInspectView( |
362 host->GetRoutingID(), | 365 web_contents->GetURL(), |
363 process->GetBrowserContext()->IsOffTheRecord(), | 366 process->GetID(), |
364 false)); | 367 host->GetRoutingID(), |
| 368 process->GetBrowserContext()->IsOffTheRecord(), |
| 369 is_background_page && has_generated_background_page)); |
365 } | 370 } |
366 } | 371 } |
367 | 372 |
368 void DeveloperPrivateGetItemsInfoFunction:: | 373 void DeveloperPrivateGetItemsInfoFunction:: |
369 GetShellWindowPagesForExtensionProfile( | 374 GetShellWindowPagesForExtensionProfile( |
370 const Extension* extension, | 375 const Extension* extension, |
371 ItemInspectViewList* result) { | 376 ItemInspectViewList* result) { |
372 ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile()); | 377 ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile()); |
373 if (!registry) return; | 378 if (!registry) return; |
374 | 379 |
375 const ShellWindowRegistry::ShellWindowList windows = | 380 const ShellWindowRegistry::ShellWindowList windows = |
376 registry->GetShellWindowsForApp(extension->id()); | 381 registry->GetShellWindowsForApp(extension->id()); |
377 | 382 |
| 383 bool has_generated_background_page = |
| 384 BackgroundInfo::HasGeneratedBackgroundPage(extension); |
378 for (ShellWindowRegistry::const_iterator it = windows.begin(); | 385 for (ShellWindowRegistry::const_iterator it = windows.begin(); |
379 it != windows.end(); ++it) { | 386 it != windows.end(); ++it) { |
380 content::WebContents* web_contents = (*it)->web_contents(); | 387 content::WebContents* web_contents = (*it)->web_contents(); |
381 RenderViewHost* host = web_contents->GetRenderViewHost(); | 388 RenderViewHost* host = web_contents->GetRenderViewHost(); |
382 content::RenderProcessHost* process = host->GetProcess(); | 389 content::RenderProcessHost* process = host->GetProcess(); |
383 result->push_back( | 390 bool is_background_page = |
384 constructInspectView(web_contents->GetURL(), | 391 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension)); |
385 process->GetID(), | 392 result->push_back(constructInspectView( |
386 host->GetRoutingID(), | 393 web_contents->GetURL(), |
387 process->GetBrowserContext()->IsOffTheRecord(), | 394 process->GetID(), |
388 false)); | 395 host->GetRoutingID(), |
| 396 process->GetBrowserContext()->IsOffTheRecord(), |
| 397 is_background_page && has_generated_background_page)); |
389 } | 398 } |
390 } | 399 } |
391 | 400 |
392 linked_ptr<developer::ItemInspectView> DeveloperPrivateGetItemsInfoFunction:: | 401 linked_ptr<developer::ItemInspectView> DeveloperPrivateGetItemsInfoFunction:: |
393 constructInspectView( | 402 constructInspectView( |
394 const GURL& url, | 403 const GURL& url, |
395 int render_process_id, | 404 int render_process_id, |
396 int render_view_id, | 405 int render_view_id, |
397 bool incognito, | 406 bool incognito, |
398 bool generated_background_page) { | 407 bool generated_background_page) { |
(...skipping 17 matching lines...) Expand all Loading... |
416 ItemInspectViewList DeveloperPrivateGetItemsInfoFunction:: | 425 ItemInspectViewList DeveloperPrivateGetItemsInfoFunction:: |
417 GetInspectablePagesForExtension( | 426 GetInspectablePagesForExtension( |
418 const Extension* extension, | 427 const Extension* extension, |
419 bool extension_is_enabled) { | 428 bool extension_is_enabled) { |
420 | 429 |
421 ItemInspectViewList result; | 430 ItemInspectViewList result; |
422 // Get the extension process's active views. | 431 // Get the extension process's active views. |
423 ExtensionProcessManager* process_manager = | 432 ExtensionProcessManager* process_manager = |
424 ExtensionSystem::Get(profile())->process_manager(); | 433 ExtensionSystem::Get(profile())->process_manager(); |
425 GetInspectablePagesForExtensionProcess( | 434 GetInspectablePagesForExtensionProcess( |
| 435 extension, |
426 process_manager->GetRenderViewHostsForExtension(extension->id()), | 436 process_manager->GetRenderViewHostsForExtension(extension->id()), |
427 &result); | 437 &result); |
428 | 438 |
429 // Get shell window views | 439 // Get shell window views |
430 GetShellWindowPagesForExtensionProfile(extension, &result); | 440 GetShellWindowPagesForExtensionProfile(extension, &result); |
431 | 441 |
432 // Include a link to start the lazy background page, if applicable. | 442 // Include a link to start the lazy background page, if applicable. |
433 if (BackgroundInfo::HasLazyBackgroundPage(extension) && | 443 if (BackgroundInfo::HasLazyBackgroundPage(extension) && |
434 extension_is_enabled && | 444 extension_is_enabled && |
435 !process_manager->GetBackgroundHostForExtension(extension->id())) { | 445 !process_manager->GetBackgroundHostForExtension(extension->id())) { |
436 result.push_back(constructInspectView( | 446 result.push_back(constructInspectView( |
437 BackgroundInfo::GetBackgroundURL(extension), | 447 BackgroundInfo::GetBackgroundURL(extension), |
438 -1, | 448 -1, |
439 -1, | 449 -1, |
440 false, | 450 false, |
441 BackgroundInfo::HasGeneratedBackgroundPage(extension))); | 451 BackgroundInfo::HasGeneratedBackgroundPage(extension))); |
442 } | 452 } |
443 | 453 |
444 ExtensionService* service = profile()->GetExtensionService(); | 454 ExtensionService* service = profile()->GetExtensionService(); |
445 // Repeat for the incognito process, if applicable. Don't try to get | 455 // Repeat for the incognito process, if applicable. Don't try to get |
446 // shell windows for incognito process. | 456 // shell windows for incognito process. |
447 if (service->profile()->HasOffTheRecordProfile() && | 457 if (service->profile()->HasOffTheRecordProfile() && |
448 IncognitoInfo::IsSplitMode(extension)) { | 458 IncognitoInfo::IsSplitMode(extension)) { |
449 process_manager = ExtensionSystem::Get( | 459 process_manager = ExtensionSystem::Get( |
450 service->profile()->GetOffTheRecordProfile())->process_manager(); | 460 service->profile()->GetOffTheRecordProfile())->process_manager(); |
451 GetInspectablePagesForExtensionProcess( | 461 GetInspectablePagesForExtensionProcess( |
| 462 extension, |
452 process_manager->GetRenderViewHostsForExtension(extension->id()), | 463 process_manager->GetRenderViewHostsForExtension(extension->id()), |
453 &result); | 464 &result); |
454 | 465 |
455 if (BackgroundInfo::HasLazyBackgroundPage(extension) && | 466 if (BackgroundInfo::HasLazyBackgroundPage(extension) && |
456 extension_is_enabled && | 467 extension_is_enabled && |
457 !process_manager->GetBackgroundHostForExtension(extension->id())) { | 468 !process_manager->GetBackgroundHostForExtension(extension->id())) { |
458 result.push_back(constructInspectView( | 469 result.push_back(constructInspectView( |
459 BackgroundInfo::GetBackgroundURL(extension), | 470 BackgroundInfo::GetBackgroundURL(extension), |
460 -1, | 471 -1, |
461 -1, | 472 -1, |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 | 1280 |
1270 #undef SET_STRING | 1281 #undef SET_STRING |
1271 return true; | 1282 return true; |
1272 } | 1283 } |
1273 | 1284 |
1274 DeveloperPrivateGetStringsFunction::~DeveloperPrivateGetStringsFunction() {} | 1285 DeveloperPrivateGetStringsFunction::~DeveloperPrivateGetStringsFunction() {} |
1275 | 1286 |
1276 } // namespace api | 1287 } // namespace api |
1277 | 1288 |
1278 } // namespace extensions | 1289 } // namespace extensions |
OLD | NEW |