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

Side by Side Diff: chrome/browser/automation/automation_util.cc

Issue 10536058: TabContentsWrapper -> TabContents, part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GetOwningTabContentsForWebContents Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/automation/automation_provider.h" 16 #include "chrome/browser/automation/automation_provider.h"
17 #include "chrome/browser/automation/automation_provider_json.h" 17 #include "chrome/browser/automation/automation_provider_json.h"
18 #include "chrome/browser/extensions/extension_process_manager.h" 18 #include "chrome/browser/extensions/extension_process_manager.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/printing/print_preview_tab_controller.h" 20 #include "chrome/browser/printing/print_preview_tab_controller.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/sessions/restore_tab_helper.h" 22 #include "chrome/browser/sessions/restore_tab_helper.h"
23 #include "chrome/browser/sessions/session_id.h" 23 #include "chrome/browser/sessions/session_id.h"
24 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 24 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents.h"
28 #include "chrome/browser/view_type_utils.h" 28 #include "chrome/browser/view_type_utils.h"
29 #include "chrome/common/automation_id.h" 29 #include "chrome/common/automation_id.h"
30 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
33 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "net/cookies/cookie_monster.h" 35 #include "net/cookies/cookie_monster.h"
36 #include "net/cookies/cookie_store.h" 36 #include "net/cookies/cookie_store.h"
37 #include "net/url_request/url_request_context.h" 37 #include "net/url_request/url_request_context.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 bool SendErrorIfModalDialogActive(AutomationProvider* provider, 399 bool SendErrorIfModalDialogActive(AutomationProvider* provider,
400 IPC::Message* message) { 400 IPC::Message* message) {
401 bool active = AppModalDialogQueue::GetInstance()->HasActiveDialog(); 401 bool active = AppModalDialogQueue::GetInstance()->HasActiveDialog();
402 if (active) { 402 if (active) {
403 AutomationJSONReply(provider, message).SendErrorCode( 403 AutomationJSONReply(provider, message).SendErrorCode(
404 automation::kBlockedByModalDialog); 404 automation::kBlockedByModalDialog);
405 } 405 }
406 return active; 406 return active;
407 } 407 }
408 408
409 AutomationId GetIdForTab(const TabContentsWrapper* tab) { 409 AutomationId GetIdForTab(const TabContents* tab) {
410 return AutomationId( 410 return AutomationId(
411 AutomationId::kTypeTab, 411 AutomationId::kTypeTab,
412 base::IntToString(tab->restore_tab_helper()->session_id().id())); 412 base::IntToString(tab->restore_tab_helper()->session_id().id()));
413 } 413 }
414 414
415 AutomationId GetIdForExtensionView( 415 AutomationId GetIdForExtensionView(
416 const content::RenderViewHost* render_view_host) { 416 const content::RenderViewHost* render_view_host) {
417 AutomationId::Type type; 417 AutomationId::Type type;
418 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); 418 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host);
419 switch (chrome::GetViewType(web_contents)) { 419 switch (chrome::GetViewType(web_contents)) {
(...skipping 25 matching lines...) Expand all
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();
452 for (; iter != BrowserList::end(); ++iter) { 452 for (; iter != BrowserList::end(); ++iter) {
453 Browser* browser = *iter; 453 Browser* browser = *iter;
454 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { 454 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) {
455 TabContentsWrapper* wrapper = browser->GetTabContentsWrapperAt(tab_index); 455 TabContents* tab_contents = browser->GetTabContentsAt(tab_index);
456 if (base::IntToString(wrapper->restore_tab_helper()->session_id().id()) == 456 if (base::IntToString(
457 id.id()) { 457 tab_contents->restore_tab_helper()->session_id().id()) ==
458 *tab = wrapper->web_contents(); 458 id.id()) {
459 *tab = tab_contents->web_contents();
459 return true; 460 return true;
460 } 461 }
461 if (preview_controller) { 462 if (preview_controller) {
462 TabContentsWrapper* preview_wrapper = 463 TabContents* preview_tab_contents =
463 preview_controller->GetPrintPreviewForTab(wrapper); 464 preview_controller->GetPrintPreviewForTab(tab_contents);
464 if (preview_wrapper) { 465 if (preview_tab_contents) {
465 std::string preview_id = base::IntToString( 466 std::string preview_id = base::IntToString(
466 preview_wrapper->restore_tab_helper()->session_id().id()); 467 preview_tab_contents->restore_tab_helper()->session_id().id());
467 if (preview_id == id.id()) { 468 if (preview_id == id.id()) {
468 *tab = preview_wrapper->web_contents(); 469 *tab = preview_tab_contents->web_contents();
469 return true; 470 return true;
470 } 471 }
471 } 472 }
472 } 473 }
473 } 474 }
474 } 475 }
475 return false; 476 return false;
476 } 477 }
477 478
478 namespace { 479 namespace {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 const extensions::Extension* extension; 554 const extensions::Extension* extension;
554 return GetExtensionForId(id, profile, &extension); 555 return GetExtensionForId(id, profile, &extension);
555 } 556 }
556 default: 557 default:
557 break; 558 break;
558 } 559 }
559 return false; 560 return false;
560 } 561 }
561 562
562 } // namespace automation_util 563 } // namespace automation_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698