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/automation/automation_util.h" | 5 #include "chrome/browser/automation/automation_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 break; | 431 break; |
432 } | 432 } |
433 // Since these extension views do not permit navigation, using the | 433 // Since these extension views do not permit navigation, using the |
434 // renderer process and view ID should suffice. | 434 // renderer process and view ID should suffice. |
435 std::string id = base::StringPrintf("%d|%d", | 435 std::string id = base::StringPrintf("%d|%d", |
436 render_view_host->GetRoutingID(), | 436 render_view_host->GetRoutingID(), |
437 render_view_host->GetProcess()->GetID()); | 437 render_view_host->GetProcess()->GetID()); |
438 return AutomationId(type, id); | 438 return AutomationId(type, id); |
439 } | 439 } |
440 | 440 |
441 AutomationId GetIdForExtension(const Extension* extension) { | 441 AutomationId GetIdForExtension(const extensions::Extension* extension) { |
442 return AutomationId(AutomationId::kTypeExtension, extension->id()); | 442 return AutomationId(AutomationId::kTypeExtension, extension->id()); |
443 } | 443 } |
444 | 444 |
445 bool GetTabForId(const AutomationId& id, WebContents** tab) { | 445 bool GetTabForId(const AutomationId& id, WebContents** tab) { |
446 if (id.type() != AutomationId::kTypeTab) | 446 if (id.type() != AutomationId::kTypeTab) |
447 return false; | 447 return false; |
448 | 448 |
449 printing::PrintPreviewTabController* preview_controller = | 449 printing::PrintPreviewTabController* preview_controller = |
450 printing::PrintPreviewTabController::GetInstance(); | 450 printing::PrintPreviewTabController::GetInstance(); |
451 BrowserList::const_iterator iter = BrowserList::begin(); | 451 BrowserList::const_iterator iter = BrowserList::begin(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 break; | 519 break; |
520 default: | 520 default: |
521 return false; | 521 return false; |
522 } | 522 } |
523 return true; | 523 return true; |
524 } | 524 } |
525 | 525 |
526 bool GetExtensionForId( | 526 bool GetExtensionForId( |
527 const AutomationId& id, | 527 const AutomationId& id, |
528 Profile* profile, | 528 Profile* profile, |
529 const Extension** extension) { | 529 const extensions::Extension** extension) { |
530 if (id.type() != AutomationId::kTypeExtension) | 530 if (id.type() != AutomationId::kTypeExtension) |
531 return false; | 531 return false; |
532 ExtensionService* service = profile->GetExtensionService(); | 532 ExtensionService* service = profile->GetExtensionService(); |
533 const Extension* installed_extension = | 533 const extensions::Extension* installed_extension = |
534 service->GetInstalledExtension(id.id()); | 534 service->GetInstalledExtension(id.id()); |
535 if (installed_extension) | 535 if (installed_extension) |
536 *extension = installed_extension; | 536 *extension = installed_extension; |
537 return !!installed_extension; | 537 return !!installed_extension; |
538 } | 538 } |
539 | 539 |
540 bool DoesObjectWithIdExist(const AutomationId& id, Profile* profile) { | 540 bool DoesObjectWithIdExist(const AutomationId& id, Profile* profile) { |
541 switch (id.type()) { | 541 switch (id.type()) { |
542 case AutomationId::kTypeTab: { | 542 case AutomationId::kTypeTab: { |
543 WebContents* tab; | 543 WebContents* tab; |
544 return GetTabForId(id, &tab); | 544 return GetTabForId(id, &tab); |
545 } | 545 } |
546 case AutomationId::kTypeExtensionPopup: | 546 case AutomationId::kTypeExtensionPopup: |
547 case AutomationId::kTypeExtensionBgPage: | 547 case AutomationId::kTypeExtensionBgPage: |
548 case AutomationId::kTypeExtensionInfobar: { | 548 case AutomationId::kTypeExtensionInfobar: { |
549 RenderViewHost* rvh; | 549 RenderViewHost* rvh; |
550 return GetExtensionRenderViewForId(id, profile, &rvh); | 550 return GetExtensionRenderViewForId(id, profile, &rvh); |
551 } | 551 } |
552 case AutomationId::kTypeExtension: { | 552 case AutomationId::kTypeExtension: { |
553 const Extension* extension; | 553 const extensions::Extension* extension; |
554 return GetExtensionForId(id, profile, &extension); | 554 return GetExtensionForId(id, profile, &extension); |
555 } | 555 } |
556 default: | 556 default: |
557 break; | 557 break; |
558 } | 558 } |
559 return false; | 559 return false; |
560 } | 560 } |
561 | 561 |
562 } // namespace automation_util | 562 } // namespace automation_util |
OLD | NEW |