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/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "base/time.h" | 16 #include "base/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" | 23 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/sessions/session_id.h" | 25 #include "chrome/browser/sessions/session_id.h" |
26 #include "chrome/browser/sessions/session_tab_helper.h" | 26 #include "chrome/browser/sessions/session_tab_helper.h" |
27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_iterator.h" |
29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/view_type_utils.h" | 32 #include "chrome/browser/view_type_utils.h" |
32 #include "chrome/common/automation_id.h" | 33 #include "chrome/common/automation_id.h" |
33 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
36 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
37 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
38 #include "net/cookies/canonical_cookie.h" | 39 #include "net/cookies/canonical_cookie.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return NULL; | 198 return NULL; |
198 } | 199 } |
199 return Profile::FromBrowserContext( | 200 return Profile::FromBrowserContext( |
200 shell->delegate()->GetCurrentBrowserContext()); | 201 shell->delegate()->GetCurrentBrowserContext()); |
201 } | 202 } |
202 return NULL; | 203 return NULL; |
203 } | 204 } |
204 #endif // defined(OS_CHROMEOS) | 205 #endif // defined(OS_CHROMEOS) |
205 | 206 |
206 Browser* GetBrowserForTab(WebContents* tab) { | 207 Browser* GetBrowserForTab(WebContents* tab) { |
207 BrowserList::const_iterator browser_iter = BrowserList::begin(); | 208 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
208 for (; browser_iter != BrowserList::end(); ++browser_iter) { | 209 Browser* browser = *it; |
209 Browser* browser = *browser_iter; | |
210 for (int tab_index = 0; | 210 for (int tab_index = 0; |
211 tab_index < browser->tab_strip_model()->count(); | 211 tab_index < browser->tab_strip_model()->count(); |
212 ++tab_index) { | 212 ++tab_index) { |
213 if (browser->tab_strip_model()->GetWebContentsAt(tab_index) == tab) | 213 if (browser->tab_strip_model()->GetWebContentsAt(tab_index) == tab) |
214 return browser; | 214 return browser; |
215 } | 215 } |
216 } | 216 } |
217 return NULL; | 217 return NULL; |
218 } | 218 } |
219 | 219 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 AutomationId GetIdForExtension(const extensions::Extension* extension) { | 502 AutomationId GetIdForExtension(const extensions::Extension* extension) { |
503 return AutomationId(AutomationId::kTypeExtension, extension->id()); | 503 return AutomationId(AutomationId::kTypeExtension, extension->id()); |
504 } | 504 } |
505 | 505 |
506 bool GetTabForId(const AutomationId& id, WebContents** tab) { | 506 bool GetTabForId(const AutomationId& id, WebContents** tab) { |
507 if (id.type() != AutomationId::kTypeTab) | 507 if (id.type() != AutomationId::kTypeTab) |
508 return false; | 508 return false; |
509 | 509 |
510 printing::PrintPreviewDialogController* preview_controller = | 510 printing::PrintPreviewDialogController* preview_controller = |
511 printing::PrintPreviewDialogController::GetInstance(); | 511 printing::PrintPreviewDialogController::GetInstance(); |
512 BrowserList::const_iterator iter = BrowserList::begin(); | 512 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
513 for (; iter != BrowserList::end(); ++iter) { | 513 Browser* browser = *it; |
514 Browser* browser = *iter; | |
515 for (int tab_index = 0; | 514 for (int tab_index = 0; |
516 tab_index < browser->tab_strip_model()->count(); | 515 tab_index < browser->tab_strip_model()->count(); |
517 ++tab_index) { | 516 ++tab_index) { |
518 WebContents* web_contents = | 517 WebContents* web_contents = |
519 browser->tab_strip_model()->GetWebContentsAt(tab_index); | 518 browser->tab_strip_model()->GetWebContentsAt(tab_index); |
520 SessionTabHelper* session_tab_helper = | 519 SessionTabHelper* session_tab_helper = |
521 SessionTabHelper::FromWebContents(web_contents); | 520 SessionTabHelper::FromWebContents(web_contents); |
522 if (base::IntToString( | 521 if (base::IntToString( |
523 session_tab_helper->session_id().id()) == id.id()) { | 522 session_tab_helper->session_id().id()) == id.id()) { |
524 *tab = web_contents; | 523 *tab = web_contents; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 const extensions::Extension* extension; | 623 const extensions::Extension* extension; |
625 return GetExtensionForId(id, profile, &extension); | 624 return GetExtensionForId(id, profile, &extension); |
626 } | 625 } |
627 default: | 626 default: |
628 break; | 627 break; |
629 } | 628 } |
630 return false; | 629 return false; |
631 } | 630 } |
632 | 631 |
633 } // namespace automation_util | 632 } // namespace automation_util |
OLD | NEW |