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 "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/automation/automation_provider.h" | 18 #include "chrome/browser/automation/automation_provider.h" |
19 #include "chrome/browser/automation/automation_provider_json.h" | 19 #include "chrome/browser/automation/automation_provider_json.h" |
20 #include "chrome/browser/extensions/extension_process_manager.h" | 20 #include "chrome/browser/extensions/extension_process_manager.h" |
21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
23 #include "chrome/browser/printing/print_preview_dialog_controller.h" | |
24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/sessions/session_id.h" | 24 #include "chrome/browser/sessions/session_id.h" |
26 #include "chrome/browser/sessions/session_tab_helper.h" | 25 #include "chrome/browser/sessions/session_tab_helper.h" |
27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 26 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
28 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_iterator.h" | 28 #include "chrome/browser/ui/browser_iterator.h" |
30 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
31 #include "chrome/browser/ui/host_desktop.h" | 30 #include "chrome/browser/ui/host_desktop.h" |
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
33 #include "chrome/common/automation_id.h" | 32 #include "chrome/common/automation_id.h" |
(...skipping 11 matching lines...) Expand all Loading... |
45 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
46 | 45 |
47 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
48 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 47 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
49 #include "chrome/browser/chromeos/login/login_display.h" | 48 #include "chrome/browser/chromeos/login/login_display.h" |
50 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 49 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
51 #include "chrome/browser/chromeos/login/webui_login_display.h" | 50 #include "chrome/browser/chromeos/login/webui_login_display.h" |
52 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 51 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
53 #endif | 52 #endif |
54 | 53 |
| 54 #if defined(ENABLE_FULL_PRINTING) |
| 55 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 56 #endif |
| 57 |
55 using content::BrowserThread; | 58 using content::BrowserThread; |
56 using content::RenderViewHost; | 59 using content::RenderViewHost; |
57 using content::WebContents; | 60 using content::WebContents; |
58 | 61 |
59 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
60 using chromeos::ExistingUserController; | 63 using chromeos::ExistingUserController; |
61 using chromeos::User; | 64 using chromeos::User; |
62 using chromeos::UserManager; | 65 using chromeos::UserManager; |
63 #endif | 66 #endif |
64 | 67 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 513 } |
511 | 514 |
512 AutomationId GetIdForExtension(const extensions::Extension* extension) { | 515 AutomationId GetIdForExtension(const extensions::Extension* extension) { |
513 return AutomationId(AutomationId::kTypeExtension, extension->id()); | 516 return AutomationId(AutomationId::kTypeExtension, extension->id()); |
514 } | 517 } |
515 | 518 |
516 bool GetTabForId(const AutomationId& id, WebContents** tab) { | 519 bool GetTabForId(const AutomationId& id, WebContents** tab) { |
517 if (id.type() != AutomationId::kTypeTab) | 520 if (id.type() != AutomationId::kTypeTab) |
518 return false; | 521 return false; |
519 | 522 |
| 523 #if defined(ENABLE_FULL_PRINTING) |
520 printing::PrintPreviewDialogController* preview_controller = | 524 printing::PrintPreviewDialogController* preview_controller = |
521 printing::PrintPreviewDialogController::GetInstance(); | 525 printing::PrintPreviewDialogController::GetInstance(); |
| 526 #endif |
522 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 527 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
523 Browser* browser = *it; | 528 Browser* browser = *it; |
524 for (int tab_index = 0; | 529 for (int tab_index = 0; |
525 tab_index < browser->tab_strip_model()->count(); | 530 tab_index < browser->tab_strip_model()->count(); |
526 ++tab_index) { | 531 ++tab_index) { |
527 WebContents* web_contents = | 532 WebContents* web_contents = |
528 browser->tab_strip_model()->GetWebContentsAt(tab_index); | 533 browser->tab_strip_model()->GetWebContentsAt(tab_index); |
529 SessionTabHelper* session_tab_helper = | 534 SessionTabHelper* session_tab_helper = |
530 SessionTabHelper::FromWebContents(web_contents); | 535 SessionTabHelper::FromWebContents(web_contents); |
531 if (base::IntToString( | 536 if (base::IntToString( |
532 session_tab_helper->session_id().id()) == id.id()) { | 537 session_tab_helper->session_id().id()) == id.id()) { |
533 *tab = web_contents; | 538 *tab = web_contents; |
534 return true; | 539 return true; |
535 } | 540 } |
| 541 |
| 542 #if defined(ENABLE_FULL_PRINTING) |
536 if (preview_controller) { | 543 if (preview_controller) { |
537 WebContents* print_preview_contents = | 544 WebContents* print_preview_contents = |
538 preview_controller->GetPrintPreviewForContents(web_contents); | 545 preview_controller->GetPrintPreviewForContents(web_contents); |
539 if (print_preview_contents) { | 546 if (print_preview_contents) { |
540 SessionTabHelper* preview_session_tab_helper = | 547 SessionTabHelper* preview_session_tab_helper = |
541 SessionTabHelper::FromWebContents(print_preview_contents); | 548 SessionTabHelper::FromWebContents(print_preview_contents); |
542 std::string preview_id = base::IntToString( | 549 std::string preview_id = base::IntToString( |
543 preview_session_tab_helper->session_id().id()); | 550 preview_session_tab_helper->session_id().id()); |
544 if (preview_id == id.id()) { | 551 if (preview_id == id.id()) { |
545 *tab = print_preview_contents; | 552 *tab = print_preview_contents; |
546 return true; | 553 return true; |
547 } | 554 } |
548 } | 555 } |
549 } | 556 } |
| 557 #endif |
550 } | 558 } |
551 } | 559 } |
552 return false; | 560 return false; |
553 } | 561 } |
554 | 562 |
555 namespace { | 563 namespace { |
556 | 564 |
557 bool GetExtensionRenderViewForId( | 565 bool GetExtensionRenderViewForId( |
558 const AutomationId& id, | 566 const AutomationId& id, |
559 Profile* profile, | 567 Profile* profile, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 const extensions::Extension* extension; | 641 const extensions::Extension* extension; |
634 return GetExtensionForId(id, profile, &extension); | 642 return GetExtensionForId(id, profile, &extension); |
635 } | 643 } |
636 default: | 644 default: |
637 break; | 645 break; |
638 } | 646 } |
639 return false; | 647 return false; |
640 } | 648 } |
641 | 649 |
642 } // namespace automation_util | 650 } // namespace automation_util |
OLD | NEW |