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

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

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interactive_ui_tests Created 8 years, 8 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
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_host.h"
19 #include "chrome/browser/extensions/extension_process_manager.h" 18 #include "chrome/browser/extensions/extension_process_manager.h"
20 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/printing/print_preview_tab_controller.h" 20 #include "chrome/browser/printing/print_preview_tab_controller.h"
22 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/sessions/restore_tab_helper.h" 22 #include "chrome/browser/sessions/restore_tab_helper.h"
24 #include "chrome/browser/sessions/session_id.h" 23 #include "chrome/browser/sessions/session_id.h"
25 #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"
26 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
29 #include "chrome/common/automation_id.h" 28 #include "chrome/common/automation_id.h"
30 #include "chrome/common/chrome_view_type.h" 29 #include "chrome/common/chrome_view_type.h"
31 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
32 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/render_view_host_delegate.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "net/cookies/cookie_monster.h" 36 #include "net/cookies/cookie_monster.h"
37 #include "net/cookies/cookie_store.h" 37 #include "net/cookies/cookie_store.h"
38 #include "net/url_request/url_request_context.h" 38 #include "net/url_request/url_request_context.h"
39 #include "net/url_request/url_request_context_getter.h" 39 #include "net/url_request/url_request_context_getter.h"
40 40
41 using content::BrowserThread; 41 using content::BrowserThread;
42 using content::RenderViewHost; 42 using content::RenderViewHost;
43 using content::WebContents; 43 using content::WebContents;
44 44
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 return active; 407 return active;
408 } 408 }
409 409
410 AutomationId GetIdForTab(const TabContentsWrapper* tab) { 410 AutomationId GetIdForTab(const TabContentsWrapper* tab) {
411 return AutomationId( 411 return AutomationId(
412 AutomationId::kTypeTab, 412 AutomationId::kTypeTab,
413 base::IntToString(tab->restore_tab_helper()->session_id().id())); 413 base::IntToString(tab->restore_tab_helper()->session_id().id()));
414 } 414 }
415 415
416 AutomationId GetIdForExtensionView(const ExtensionHost* ext_host) { 416 AutomationId GetIdForExtensionView(
417 const content::RenderViewHost* render_view_host) {
417 AutomationId::Type type; 418 AutomationId::Type type;
418 switch (ext_host->extension_host_type()) { 419 switch (render_view_host->GetDelegate()->GetRenderViewType()) {
419 case chrome::VIEW_TYPE_EXTENSION_POPUP: 420 case chrome::VIEW_TYPE_EXTENSION_POPUP:
420 type = AutomationId::kTypeExtensionPopup; 421 type = AutomationId::kTypeExtensionPopup;
421 break; 422 break;
422 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: 423 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE:
423 type = AutomationId::kTypeExtensionBgPage; 424 type = AutomationId::kTypeExtensionBgPage;
424 break; 425 break;
425 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: 426 case chrome::VIEW_TYPE_EXTENSION_INFOBAR:
426 type = AutomationId::kTypeExtensionInfobar; 427 type = AutomationId::kTypeExtensionInfobar;
427 break; 428 break;
428 default: 429 default:
429 type = AutomationId::kTypeInvalid; 430 type = AutomationId::kTypeInvalid;
430 break; 431 break;
431 } 432 }
432 // Since these extension views do not permit navigation, using the 433 // Since these extension views do not permit navigation, using the
433 // renderer process and view ID should suffice. 434 // renderer process and view ID should suffice.
434 std::string id = base::StringPrintf("%d|%d", 435 std::string id = base::StringPrintf("%d|%d",
435 ext_host->render_view_host()->GetRoutingID(), 436 render_view_host->GetRoutingID(),
436 ext_host->render_process_host()->GetID()); 437 render_view_host->GetProcess()->GetID());
437 return AutomationId(type, id); 438 return AutomationId(type, id);
438 } 439 }
439 440
440 AutomationId GetIdForExtension(const Extension* extension) { 441 AutomationId GetIdForExtension(const Extension* extension) {
441 return AutomationId(AutomationId::kTypeExtension, extension->id()); 442 return AutomationId(AutomationId::kTypeExtension, extension->id());
442 } 443 }
443 444
444 bool GetTabForId(const AutomationId& id, WebContents** tab) { 445 bool GetTabForId(const AutomationId& id, WebContents** tab) {
445 if (id.type() != AutomationId::kTypeTab) 446 if (id.type() != AutomationId::kTypeTab)
446 return false; 447 return false;
(...skipping 28 matching lines...) Expand all
475 } 476 }
476 477
477 namespace { 478 namespace {
478 479
479 bool GetExtensionRenderViewForId( 480 bool GetExtensionRenderViewForId(
480 const AutomationId& id, 481 const AutomationId& id,
481 Profile* profile, 482 Profile* profile,
482 RenderViewHost** rvh) { 483 RenderViewHost** rvh) {
483 ExtensionProcessManager* extension_mgr = 484 ExtensionProcessManager* extension_mgr =
484 profile->GetExtensionProcessManager(); 485 profile->GetExtensionProcessManager();
485 ExtensionProcessManager::const_iterator iter; 486 const ExtensionProcessManager::ContentsSet contents_set =
486 for (iter = extension_mgr->begin(); iter != extension_mgr->end(); 487 extension_mgr->GetAllContents();
488 for (ExtensionProcessManager::ContentsSet::const_iterator iter =
489 contents_set.begin(); iter != contents_set.end();
487 ++iter) { 490 ++iter) {
488 ExtensionHost* host = *iter; 491 content::WebContents* contents = *iter;
492 RenderViewHost* host = contents->GetRenderViewHost();
Charlie Reis 2012/04/19 21:42:10 We need to be very careful here. GetRenderViewHos
Aaron Boodman 2012/04/20 01:00:55 Good point. My bad, I forgot that WebContents enca
489 AutomationId this_id = GetIdForExtensionView(host); 493 AutomationId this_id = GetIdForExtensionView(host);
490 if (id == this_id) { 494 if (id == this_id) {
491 *rvh = host->render_view_host(); 495 *rvh = host;
492 return true; 496 return true;
493 } 497 }
494 } 498 }
495 return false; 499 return false;
496 } 500 }
497 501
498 } // namespace 502 } // namespace
499 503
500 bool GetRenderViewForId( 504 bool GetRenderViewForId(
501 const AutomationId& id, 505 const AutomationId& id,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 const Extension* extension; 555 const Extension* extension;
552 return GetExtensionForId(id, profile, &extension); 556 return GetExtensionForId(id, profile, &extension);
553 } 557 }
554 default: 558 default:
555 break; 559 break;
556 } 560 }
557 return false; 561 return false;
558 } 562 }
559 563
560 } // namespace automation_util 564 } // namespace automation_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698