OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 36 matching lines...) Loading... |
47 #include "chrome/browser/platform_util.h" | 47 #include "chrome/browser/platform_util.h" |
48 #include "chrome/browser/prefs/pref_service.h" | 48 #include "chrome/browser/prefs/pref_service.h" |
49 #include "chrome/browser/profile_manager.h" | 49 #include "chrome/browser/profile_manager.h" |
50 #include "chrome/browser/renderer_host/render_process_host.h" | 50 #include "chrome/browser/renderer_host/render_process_host.h" |
51 #include "chrome/browser/renderer_host/render_view_host.h" | 51 #include "chrome/browser/renderer_host/render_view_host.h" |
52 #include "chrome/browser/search_engines/keyword_editor_controller.h" | 52 #include "chrome/browser/search_engines/keyword_editor_controller.h" |
53 #include "chrome/browser/search_engines/template_url.h" | 53 #include "chrome/browser/search_engines/template_url.h" |
54 #include "chrome/browser/search_engines/template_url_model.h" | 54 #include "chrome/browser/search_engines/template_url_model.h" |
55 #include "chrome/browser/tab_contents/infobar_delegate.h" | 55 #include "chrome/browser/tab_contents/infobar_delegate.h" |
56 #include "chrome/browser/tab_contents/interstitial_page.h" | 56 #include "chrome/browser/tab_contents/interstitial_page.h" |
57 #include "chrome/browser/tab_contents/tab_contents.h" | 57 #include "chrome/browser/tab_contents_wrapper.h" |
58 #include "chrome/browser/translate/translate_infobar_delegate.h" | 58 #include "chrome/browser/translate/translate_infobar_delegate.h" |
59 #include "chrome/common/chrome_constants.h" | 59 #include "chrome/common/chrome_constants.h" |
60 #include "chrome/common/chrome_paths.h" | 60 #include "chrome/common/chrome_paths.h" |
61 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
62 #include "chrome/common/net/url_request_context_getter.h" | 62 #include "chrome/common/net/url_request_context_getter.h" |
63 #include "chrome/common/notification_service.h" | 63 #include "chrome/common/notification_service.h" |
64 #include "chrome/common/url_constants.h" | 64 #include "chrome/common/url_constants.h" |
65 #include "chrome/browser/notifications/balloon.h" | 65 #include "chrome/browser/notifications/balloon.h" |
66 #include "chrome/browser/notifications/balloon_collection.h" | 66 #include "chrome/browser/notifications/balloon_collection.h" |
67 #include "chrome/browser/notifications/notification.h" | 67 #include "chrome/browser/notifications/notification.h" |
(...skipping 408 matching lines...) Loading... |
476 } | 476 } |
477 | 477 |
478 void TestingAutomationProvider::AppendTab(int handle, const GURL& url, | 478 void TestingAutomationProvider::AppendTab(int handle, const GURL& url, |
479 IPC::Message* reply_message) { | 479 IPC::Message* reply_message) { |
480 int append_tab_response = -1; // -1 is the error code | 480 int append_tab_response = -1; // -1 is the error code |
481 NotificationObserver* observer = NULL; | 481 NotificationObserver* observer = NULL; |
482 | 482 |
483 if (browser_tracker_->ContainsHandle(handle)) { | 483 if (browser_tracker_->ContainsHandle(handle)) { |
484 Browser* browser = browser_tracker_->GetResource(handle); | 484 Browser* browser = browser_tracker_->GetResource(handle); |
485 observer = AddTabStripObserver(browser, reply_message); | 485 observer = AddTabStripObserver(browser, reply_message); |
486 TabContents* contents = | 486 TabContentsWrapper* contents = |
487 browser->AddSelectedTabWithURL(url, PageTransition::TYPED); | 487 browser->AddSelectedTabWithURL(url, PageTransition::TYPED); |
488 if (contents) { | 488 if (contents) { |
489 append_tab_response = | 489 append_tab_response = |
490 GetIndexForNavigationController(&contents->controller(), browser); | 490 GetIndexForNavigationController(&contents->controller(), browser); |
491 } | 491 } |
492 } | 492 } |
493 | 493 |
494 if (append_tab_response < 0) { | 494 if (append_tab_response < 0) { |
495 // The append tab failed. Remove the TabStripObserver | 495 // The append tab failed. Remove the TabStripObserver |
496 if (observer) { | 496 if (observer) { |
(...skipping 457 matching lines...) Loading... |
954 } | 954 } |
955 } | 955 } |
956 | 956 |
957 void TestingAutomationProvider::GetTab(int win_handle, | 957 void TestingAutomationProvider::GetTab(int win_handle, |
958 int tab_index, | 958 int tab_index, |
959 int* tab_handle) { | 959 int* tab_handle) { |
960 *tab_handle = 0; | 960 *tab_handle = 0; |
961 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { | 961 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { |
962 Browser* browser = browser_tracker_->GetResource(win_handle); | 962 Browser* browser = browser_tracker_->GetResource(win_handle); |
963 if (tab_index < browser->tab_count()) { | 963 if (tab_index < browser->tab_count()) { |
964 TabContents* tab_contents = | 964 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); |
965 browser->GetTabContentsAt(tab_index); | |
966 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); | 965 *tab_handle = tab_tracker_->Add(&tab_contents->controller()); |
967 } | 966 } |
968 } | 967 } |
969 } | 968 } |
970 | 969 |
971 void TestingAutomationProvider::GetTabProcessID(int handle, int* process_id) { | 970 void TestingAutomationProvider::GetTabProcessID(int handle, int* process_id) { |
972 *process_id = -1; | 971 *process_id = -1; |
973 | 972 |
974 if (tab_tracker_->ContainsHandle(handle)) { | 973 if (tab_tracker_->ContainsHandle(handle)) { |
975 *process_id = 0; | 974 *process_id = 0; |
(...skipping 3477 matching lines...) Loading... |
4453 DCHECK(type == NotificationType::SESSION_END); | 4452 DCHECK(type == NotificationType::SESSION_END); |
4454 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit | 4453 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit |
4455 // before the task runs resulting in this object not being deleted. This | 4454 // before the task runs resulting in this object not being deleted. This |
4456 // Release balance out the Release scheduled by OnBrowserRemoved. | 4455 // Release balance out the Release scheduled by OnBrowserRemoved. |
4457 Release(); | 4456 Release(); |
4458 } | 4457 } |
4459 | 4458 |
4460 void TestingAutomationProvider::OnRemoveProvider() { | 4459 void TestingAutomationProvider::OnRemoveProvider() { |
4461 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4460 AutomationProviderList::GetInstance()->RemoveProvider(this); |
4462 } | 4461 } |
OLD | NEW |