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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 #include "chrome/browser/translate/translate_tab_helper.h" | 98 #include "chrome/browser/translate/translate_tab_helper.h" |
99 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 99 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
100 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 100 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
101 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 101 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
102 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 102 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
103 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 103 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
104 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 104 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
105 #include "chrome/browser/ui/browser_commands.h" | 105 #include "chrome/browser/ui/browser_commands.h" |
106 #include "chrome/browser/ui/browser_finder.h" | 106 #include "chrome/browser/ui/browser_finder.h" |
107 #include "chrome/browser/ui/browser_list.h" | 107 #include "chrome/browser/ui/browser_list.h" |
| 108 #include "chrome/browser/ui/browser_tabstrip.h" |
108 #include "chrome/browser/ui/browser_window.h" | 109 #include "chrome/browser/ui/browser_window.h" |
109 #include "chrome/browser/ui/extensions/application_launch.h" | 110 #include "chrome/browser/ui/extensions/application_launch.h" |
110 #include "chrome/browser/ui/find_bar/find_bar.h" | 111 #include "chrome/browser/ui/find_bar/find_bar.h" |
111 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 112 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
112 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" | 113 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" |
113 #include "chrome/browser/ui/login/login_prompt.h" | 114 #include "chrome/browser/ui/login/login_prompt.h" |
114 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 115 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
115 #include "chrome/browser/ui/omnibox/location_bar.h" | 116 #include "chrome/browser/ui/omnibox/location_bar.h" |
116 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 117 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
117 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 118 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 browser->window()->Close(); | 479 browser->window()->Close(); |
479 } | 480 } |
480 | 481 |
481 void TestingAutomationProvider::ActivateTab(int handle, | 482 void TestingAutomationProvider::ActivateTab(int handle, |
482 int at_index, | 483 int at_index, |
483 int* status) { | 484 int* status) { |
484 *status = -1; | 485 *status = -1; |
485 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { | 486 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { |
486 Browser* browser = browser_tracker_->GetResource(handle); | 487 Browser* browser = browser_tracker_->GetResource(handle); |
487 if (at_index >= 0 && at_index < browser->tab_count()) { | 488 if (at_index >= 0 && at_index < browser->tab_count()) { |
488 browser->ActivateTabAt(at_index, true); | 489 chrome::ActivateTabAt(browser, at_index, true); |
489 *status = 0; | 490 *status = 0; |
490 } | 491 } |
491 } | 492 } |
492 } | 493 } |
493 | 494 |
494 void TestingAutomationProvider::AppendTab(int handle, | 495 void TestingAutomationProvider::AppendTab(int handle, |
495 const GURL& url, | 496 const GURL& url, |
496 IPC::Message* reply_message) { | 497 IPC::Message* reply_message) { |
497 int append_tab_response = -1; // -1 is the error code | 498 int append_tab_response = -1; // -1 is the error code |
498 TabAppendedNotificationObserver* observer = NULL; | 499 TabAppendedNotificationObserver* observer = NULL; |
499 | 500 |
500 if (browser_tracker_->ContainsHandle(handle)) { | 501 if (browser_tracker_->ContainsHandle(handle)) { |
501 Browser* browser = browser_tracker_->GetResource(handle); | 502 Browser* browser = browser_tracker_->GetResource(handle); |
502 observer = new TabAppendedNotificationObserver(browser, this, | 503 observer = new TabAppendedNotificationObserver(browser, this, |
503 reply_message); | 504 reply_message); |
504 TabContents* contents = | 505 TabContents* contents = chrome::AddSelectedTabWithURL( |
505 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); | 506 browser, url, content::PAGE_TRANSITION_TYPED); |
506 if (contents) { | 507 if (contents) { |
507 append_tab_response = GetIndexForNavigationController( | 508 append_tab_response = GetIndexForNavigationController( |
508 &contents->web_contents()->GetController(), browser); | 509 &contents->web_contents()->GetController(), browser); |
509 } | 510 } |
510 } | 511 } |
511 | 512 |
512 if (append_tab_response < 0) { | 513 if (append_tab_response < 0) { |
513 // Appending tab failed. Clean up and send failure response. | 514 // Appending tab failed. Clean up and send failure response. |
514 | 515 |
515 if (observer) | 516 if (observer) |
(...skipping 24 matching lines...) Expand all Loading... |
540 | 541 |
541 void TestingAutomationProvider::CloseTab(int tab_handle, | 542 void TestingAutomationProvider::CloseTab(int tab_handle, |
542 bool wait_until_closed, | 543 bool wait_until_closed, |
543 IPC::Message* reply_message) { | 544 IPC::Message* reply_message) { |
544 if (tab_tracker_->ContainsHandle(tab_handle)) { | 545 if (tab_tracker_->ContainsHandle(tab_handle)) { |
545 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | 546 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
546 Browser* browser = browser::FindBrowserWithWebContents( | 547 Browser* browser = browser::FindBrowserWithWebContents( |
547 controller->GetWebContents()); | 548 controller->GetWebContents()); |
548 DCHECK(browser); | 549 DCHECK(browser); |
549 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); | 550 new TabClosedNotificationObserver(this, wait_until_closed, reply_message); |
550 browser->CloseTabContents(controller->GetWebContents()); | 551 chrome::CloseWebContents(browser, controller->GetWebContents()); |
551 return; | 552 return; |
552 } | 553 } |
553 | 554 |
554 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); | 555 AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); |
555 Send(reply_message); | 556 Send(reply_message); |
556 } | 557 } |
557 | 558 |
558 void TestingAutomationProvider::GetCookies(const GURL& url, int handle, | 559 void TestingAutomationProvider::GetCookies(const GURL& url, int handle, |
559 int* value_size, | 560 int* value_size, |
560 std::string* value) { | 561 std::string* value) { |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 } | 1052 } |
1052 } | 1053 } |
1053 | 1054 |
1054 void TestingAutomationProvider::GetTab(int win_handle, | 1055 void TestingAutomationProvider::GetTab(int win_handle, |
1055 int tab_index, | 1056 int tab_index, |
1056 int* tab_handle) { | 1057 int* tab_handle) { |
1057 *tab_handle = 0; | 1058 *tab_handle = 0; |
1058 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { | 1059 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { |
1059 Browser* browser = browser_tracker_->GetResource(win_handle); | 1060 Browser* browser = browser_tracker_->GetResource(win_handle); |
1060 if (tab_index < browser->tab_count()) { | 1061 if (tab_index < browser->tab_count()) { |
1061 WebContents* web_contents = browser->GetWebContentsAt(tab_index); | 1062 WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); |
1062 *tab_handle = tab_tracker_->Add(&web_contents->GetController()); | 1063 *tab_handle = tab_tracker_->Add(&web_contents->GetController()); |
1063 } | 1064 } |
1064 } | 1065 } |
1065 } | 1066 } |
1066 | 1067 |
1067 void TestingAutomationProvider::GetTabTitle(int handle, | 1068 void TestingAutomationProvider::GetTabTitle(int handle, |
1068 int* title_string_size, | 1069 int* title_string_size, |
1069 std::wstring* title) { | 1070 std::wstring* title) { |
1070 *title_string_size = -1; // -1 is the error code | 1071 *title_string_size = -1; // -1 is the error code |
1071 if (tab_tracker_->ContainsHandle(handle)) { | 1072 if (tab_tracker_->ContainsHandle(handle)) { |
1072 NavigationController* tab = tab_tracker_->GetResource(handle); | 1073 NavigationController* tab = tab_tracker_->GetResource(handle); |
1073 NavigationEntry* entry = tab->GetActiveEntry(); | 1074 NavigationEntry* entry = tab->GetActiveEntry(); |
1074 if (entry != NULL) { | 1075 if (entry != NULL) { |
1075 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); | 1076 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); |
1076 } else { | 1077 } else { |
1077 *title = std::wstring(); | 1078 *title = std::wstring(); |
1078 } | 1079 } |
1079 *title_string_size = static_cast<int>(title->size()); | 1080 *title_string_size = static_cast<int>(title->size()); |
1080 } | 1081 } |
1081 } | 1082 } |
1082 | 1083 |
1083 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { | 1084 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { |
1084 *tabstrip_index = -1; // -1 is the error code | 1085 *tabstrip_index = -1; // -1 is the error code |
1085 | 1086 |
1086 if (tab_tracker_->ContainsHandle(handle)) { | 1087 if (tab_tracker_->ContainsHandle(handle)) { |
1087 NavigationController* tab = tab_tracker_->GetResource(handle); | 1088 NavigationController* tab = tab_tracker_->GetResource(handle); |
1088 Browser* browser = browser::FindBrowserWithWebContents( | 1089 Browser* browser = browser::FindBrowserWithWebContents( |
1089 tab->GetWebContents()); | 1090 tab->GetWebContents()); |
1090 *tabstrip_index = browser->GetIndexOfController(tab); | 1091 *tabstrip_index = chrome::GetIndexOfTab(browser, tab->GetWebContents()); |
1091 } | 1092 } |
1092 } | 1093 } |
1093 | 1094 |
1094 void TestingAutomationProvider::GetTabURL(int handle, | 1095 void TestingAutomationProvider::GetTabURL(int handle, |
1095 bool* success, | 1096 bool* success, |
1096 GURL* url) { | 1097 GURL* url) { |
1097 *success = false; | 1098 *success = false; |
1098 if (tab_tracker_->ContainsHandle(handle)) { | 1099 if (tab_tracker_->ContainsHandle(handle)) { |
1099 NavigationController* tab = tab_tracker_->GetResource(handle); | 1100 NavigationController* tab = tab_tracker_->GetResource(handle); |
1100 // Return what the user would see in the location bar. | 1101 // Return what the user would see in the location bar. |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 int tab_index; | 2211 int tab_index; |
2211 int infobar_index_int; | 2212 int infobar_index_int; |
2212 std::string action; | 2213 std::string action; |
2213 if (!args->GetInteger("tab_index", &tab_index) || | 2214 if (!args->GetInteger("tab_index", &tab_index) || |
2214 !args->GetInteger("infobar_index", &infobar_index_int) || | 2215 !args->GetInteger("infobar_index", &infobar_index_int) || |
2215 !args->GetString("action", &action)) { | 2216 !args->GetString("action", &action)) { |
2216 reply.SendError("Invalid or missing args"); | 2217 reply.SendError("Invalid or missing args"); |
2217 return; | 2218 return; |
2218 } | 2219 } |
2219 | 2220 |
2220 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); | 2221 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
2221 if (!tab_contents) { | 2222 if (!tab_contents) { |
2222 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); | 2223 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); |
2223 return; | 2224 return; |
2224 } | 2225 } |
2225 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 2226 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
2226 | 2227 |
2227 InfoBarDelegate* infobar = NULL; | 2228 InfoBarDelegate* infobar = NULL; |
2228 size_t infobar_index = static_cast<size_t>(infobar_index_int); | 2229 size_t infobar_index = static_cast<size_t>(infobar_index_int); |
2229 if (infobar_index >= infobar_helper->infobar_count()) { | 2230 if (infobar_index >= infobar_helper->infobar_count()) { |
2230 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, | 2231 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 break; | 2407 break; |
2407 default: | 2408 default: |
2408 type = "unknown"; | 2409 type = "unknown"; |
2409 break; | 2410 break; |
2410 } | 2411 } |
2411 browser_item->SetString("type", type); | 2412 browser_item->SetString("type", type); |
2412 // For each window, add info about all tabs in a list of dictionaries, | 2413 // For each window, add info about all tabs in a list of dictionaries, |
2413 // one dictionary item per tab. | 2414 // one dictionary item per tab. |
2414 ListValue* tabs = new ListValue; | 2415 ListValue* tabs = new ListValue; |
2415 for (int i = 0; i < browser->tab_count(); ++i) { | 2416 for (int i = 0; i < browser->tab_count(); ++i) { |
2416 WebContents* wc = browser->GetWebContentsAt(i); | 2417 WebContents* wc = chrome::GetWebContentsAt(browser, i); |
2417 DictionaryValue* tab = new DictionaryValue; | 2418 DictionaryValue* tab = new DictionaryValue; |
2418 tab->SetInteger("index", i); | 2419 tab->SetInteger("index", i); |
2419 tab->SetString("url", wc->GetURL().spec()); | 2420 tab->SetString("url", wc->GetURL().spec()); |
2420 tab->SetInteger("renderer_pid", | 2421 tab->SetInteger("renderer_pid", |
2421 base::GetProcId(wc->GetRenderProcessHost()->GetHandle())); | 2422 base::GetProcId(wc->GetRenderProcessHost()->GetHandle())); |
2422 tab->Set("infobars", GetInfobarsInfo(wc)); | 2423 tab->Set("infobars", GetInfobarsInfo(wc)); |
2423 tab->SetBoolean("pinned", browser->IsTabPinned(i)); | 2424 tab->SetBoolean("pinned", browser->tab_strip_model()->IsTabPinned(i)); |
2424 tabs->Append(tab); | 2425 tabs->Append(tab); |
2425 } | 2426 } |
2426 browser_item->Set("tabs", tabs); | 2427 browser_item->Set("tabs", tabs); |
2427 | 2428 |
2428 windows->Append(browser_item); | 2429 windows->Append(browser_item); |
2429 } | 2430 } |
2430 return_value->Set("windows", windows); | 2431 return_value->Set("windows", windows); |
2431 | 2432 |
2432 #if defined(OS_LINUX) | 2433 #if defined(OS_LINUX) |
2433 int flags = ChildProcessHost::CHILD_ALLOW_SELF; | 2434 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2541 // Refer to GetNavigationInfo() in chrome/test/pyautolib/pyauto.py for | 2542 // Refer to GetNavigationInfo() in chrome/test/pyautolib/pyauto.py for |
2542 // sample json output. | 2543 // sample json output. |
2543 void TestingAutomationProvider::GetNavigationInfo( | 2544 void TestingAutomationProvider::GetNavigationInfo( |
2544 Browser* browser, | 2545 Browser* browser, |
2545 DictionaryValue* args, | 2546 DictionaryValue* args, |
2546 IPC::Message* reply_message) { | 2547 IPC::Message* reply_message) { |
2547 AutomationJSONReply reply(this, reply_message); | 2548 AutomationJSONReply reply(this, reply_message); |
2548 int tab_index; | 2549 int tab_index; |
2549 WebContents* web_contents = NULL; | 2550 WebContents* web_contents = NULL; |
2550 if (!args->GetInteger("tab_index", &tab_index) || | 2551 if (!args->GetInteger("tab_index", &tab_index) || |
2551 !(web_contents = browser->GetWebContentsAt(tab_index))) { | 2552 !(web_contents = chrome::GetWebContentsAt(browser, tab_index))) { |
2552 reply.SendError("tab_index missing or invalid."); | 2553 reply.SendError("tab_index missing or invalid."); |
2553 return; | 2554 return; |
2554 } | 2555 } |
2555 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2556 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
2556 const NavigationController& controller = web_contents->GetController(); | 2557 const NavigationController& controller = web_contents->GetController(); |
2557 NavigationEntry* nav_entry = controller.GetActiveEntry(); | 2558 NavigationEntry* nav_entry = controller.GetActiveEntry(); |
2558 DCHECK(nav_entry); | 2559 DCHECK(nav_entry); |
2559 | 2560 |
2560 // Security info. | 2561 // Security info. |
2561 DictionaryValue* ssl = new DictionaryValue; | 2562 DictionaryValue* ssl = new DictionaryValue; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 model->OnUpOrDownKeyPressed(count); | 3181 model->OnUpOrDownKeyPressed(count); |
3181 reply.SendSuccess(NULL); | 3182 reply.SendSuccess(NULL); |
3182 } | 3183 } |
3183 | 3184 |
3184 // Sample json input: { "command": "OmniboxAcceptInput" } | 3185 // Sample json input: { "command": "OmniboxAcceptInput" } |
3185 void TestingAutomationProvider::OmniboxAcceptInput( | 3186 void TestingAutomationProvider::OmniboxAcceptInput( |
3186 Browser* browser, | 3187 Browser* browser, |
3187 DictionaryValue* args, | 3188 DictionaryValue* args, |
3188 IPC::Message* reply_message) { | 3189 IPC::Message* reply_message) { |
3189 NavigationController& controller = | 3190 NavigationController& controller = |
3190 browser->GetActiveWebContents()->GetController(); | 3191 chrome::GetActiveWebContents(browser)->GetController(); |
3191 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 3192 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
3192 if (!loc_bar) { | 3193 if (!loc_bar) { |
3193 AutomationJSONReply(this, reply_message).SendError( | 3194 AutomationJSONReply(this, reply_message).SendError( |
3194 "The specified browser does not have a location bar."); | 3195 "The specified browser does not have a location bar."); |
3195 return; | 3196 return; |
3196 } | 3197 } |
3197 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); | 3198 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); |
3198 loc_bar->AcceptInput(); | 3199 loc_bar->AcceptInput(); |
3199 } | 3200 } |
3200 | 3201 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3355 FilePath::StringType filename; | 3356 FilePath::StringType filename; |
3356 FilePath::StringType parent_directory; | 3357 FilePath::StringType parent_directory; |
3357 WebContents* web_contents = NULL; | 3358 WebContents* web_contents = NULL; |
3358 | 3359 |
3359 if (!args->GetInteger("tab_index", &tab_index) || | 3360 if (!args->GetInteger("tab_index", &tab_index) || |
3360 !args->GetString("filename", &filename)) { | 3361 !args->GetString("filename", &filename)) { |
3361 AutomationJSONReply(this, reply_message) | 3362 AutomationJSONReply(this, reply_message) |
3362 .SendError("tab_index or filename param missing"); | 3363 .SendError("tab_index or filename param missing"); |
3363 return; | 3364 return; |
3364 } else { | 3365 } else { |
3365 web_contents = browser->GetWebContentsAt(tab_index); | 3366 web_contents = chrome::GetWebContentsAt(browser, tab_index); |
3366 if (!web_contents) { | 3367 if (!web_contents) { |
3367 AutomationJSONReply(this, reply_message).SendError("no tab at tab_index"); | 3368 AutomationJSONReply(this, reply_message).SendError("no tab at tab_index"); |
3368 return; | 3369 return; |
3369 } | 3370 } |
3370 } | 3371 } |
3371 // We're doing a SAVE_AS_ONLY_HTML so the the directory path isn't | 3372 // We're doing a SAVE_AS_ONLY_HTML so the the directory path isn't |
3372 // used. Nevertheless, SavePackage requires it be valid. Sigh. | 3373 // used. Nevertheless, SavePackage requires it be valid. Sigh. |
3373 parent_directory = FilePath(filename).DirName().value(); | 3374 parent_directory = FilePath(filename).DirName().value(); |
3374 if (!web_contents->SavePage( | 3375 if (!web_contents->SavePage( |
3375 FilePath(filename), | 3376 FilePath(filename), |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 // Get the TabContents from a dictionary of arguments. | 3669 // Get the TabContents from a dictionary of arguments. |
3669 TabContents* GetTabContentsFromDict(const Browser* browser, | 3670 TabContents* GetTabContentsFromDict(const Browser* browser, |
3670 const DictionaryValue* args, | 3671 const DictionaryValue* args, |
3671 std::string* error_message) { | 3672 std::string* error_message) { |
3672 int tab_index; | 3673 int tab_index; |
3673 if (!args->GetInteger("tab_index", &tab_index)) { | 3674 if (!args->GetInteger("tab_index", &tab_index)) { |
3674 *error_message = "Must include tab_index."; | 3675 *error_message = "Must include tab_index."; |
3675 return NULL; | 3676 return NULL; |
3676 } | 3677 } |
3677 | 3678 |
3678 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); | 3679 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
3679 if (!tab_contents) { | 3680 if (!tab_contents) { |
3680 *error_message = StringPrintf("No tab at index %d.", tab_index); | 3681 *error_message = StringPrintf("No tab at index %d.", tab_index); |
3681 return NULL; | 3682 return NULL; |
3682 } | 3683 } |
3683 return tab_contents; | 3684 return tab_contents; |
3684 } | 3685 } |
3685 | 3686 |
3686 // Get the TranslateInfoBarDelegate from WebContents. | 3687 // Get the TranslateInfoBarDelegate from WebContents. |
3687 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( | 3688 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( |
3688 WebContents* web_contents) { | 3689 WebContents* web_contents) { |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4509 DictionaryValue* args, | 4510 DictionaryValue* args, |
4510 IPC::Message* reply_message) { | 4511 IPC::Message* reply_message) { |
4511 AutomationJSONReply reply(this, reply_message); | 4512 AutomationJSONReply reply(this, reply_message); |
4512 // Get the AutofillProfiles currently in the database. | 4513 // Get the AutofillProfiles currently in the database. |
4513 int tab_index = 0; | 4514 int tab_index = 0; |
4514 if (!args->GetInteger("tab_index", &tab_index)) { | 4515 if (!args->GetInteger("tab_index", &tab_index)) { |
4515 reply.SendError("Invalid or missing tab_index integer value."); | 4516 reply.SendError("Invalid or missing tab_index integer value."); |
4516 return; | 4517 return; |
4517 } | 4518 } |
4518 | 4519 |
4519 TabContents* tab_contents = | 4520 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
4520 browser->GetTabContentsAt(tab_index); | |
4521 if (tab_contents) { | 4521 if (tab_contents) { |
4522 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( | 4522 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( |
4523 tab_contents->profile()->GetOriginalProfile()); | 4523 tab_contents->profile()->GetOriginalProfile()); |
4524 if (pdm) { | 4524 if (pdm) { |
4525 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); | 4525 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); |
4526 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); | 4526 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); |
4527 | 4527 |
4528 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); | 4528 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); |
4529 ListValue* cards = GetListFromCreditCards(credit_cards); | 4529 ListValue* cards = GetListFromCreditCards(credit_cards); |
4530 | 4530 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4575 } | 4575 } |
4576 | 4576 |
4577 // Save the AutofillProfiles. | 4577 // Save the AutofillProfiles. |
4578 int tab_index = 0; | 4578 int tab_index = 0; |
4579 if (!args->GetInteger("tab_index", &tab_index)) { | 4579 if (!args->GetInteger("tab_index", &tab_index)) { |
4580 AutomationJSONReply(this, reply_message).SendError( | 4580 AutomationJSONReply(this, reply_message).SendError( |
4581 "Invalid or missing tab_index integer"); | 4581 "Invalid or missing tab_index integer"); |
4582 return; | 4582 return; |
4583 } | 4583 } |
4584 | 4584 |
4585 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); | 4585 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
4586 | 4586 |
4587 if (tab_contents) { | 4587 if (tab_contents) { |
4588 PersonalDataManager* pdm = | 4588 PersonalDataManager* pdm = |
4589 PersonalDataManagerFactory::GetForProfile(tab_contents->profile()); | 4589 PersonalDataManagerFactory::GetForProfile(tab_contents->profile()); |
4590 if (pdm) { | 4590 if (pdm) { |
4591 if (profiles || cards) { | 4591 if (profiles || cards) { |
4592 // This observer will delete itself. | 4592 // This observer will delete itself. |
4593 AutofillChangedObserver* observer = new AutofillChangedObserver( | 4593 AutofillChangedObserver* observer = new AutofillChangedObserver( |
4594 this, reply_message, autofill_profiles.size(), credit_cards.size()); | 4594 this, reply_message, autofill_profiles.size(), credit_cards.size()); |
4595 observer->Init(); | 4595 observer->Init(); |
(...skipping 23 matching lines...) Expand all Loading... |
4619 IPC::Message* reply_message) { | 4619 IPC::Message* reply_message) { |
4620 if (SendErrorIfModalDialogActive(this, reply_message)) | 4620 if (SendErrorIfModalDialogActive(this, reply_message)) |
4621 return; | 4621 return; |
4622 | 4622 |
4623 int tab_index; | 4623 int tab_index; |
4624 if (!args->GetInteger("tab_index", &tab_index)) { | 4624 if (!args->GetInteger("tab_index", &tab_index)) { |
4625 AutomationJSONReply(this, reply_message) | 4625 AutomationJSONReply(this, reply_message) |
4626 .SendError("'tab_index' missing or invalid."); | 4626 .SendError("'tab_index' missing or invalid."); |
4627 return; | 4627 return; |
4628 } | 4628 } |
4629 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); | 4629 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
4630 if (!tab_contents) { | 4630 if (!tab_contents) { |
4631 AutomationJSONReply(this, reply_message).SendError( | 4631 AutomationJSONReply(this, reply_message).SendError( |
4632 StringPrintf("No such tab at index %d", tab_index)); | 4632 StringPrintf("No such tab at index %d", tab_index)); |
4633 return; | 4633 return; |
4634 } | 4634 } |
4635 | 4635 |
4636 string16 frame_xpath, javascript; | 4636 string16 frame_xpath, javascript; |
4637 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4637 if (!args->GetString("frame_xpath", &frame_xpath)) { |
4638 AutomationJSONReply(this, reply_message) | 4638 AutomationJSONReply(this, reply_message) |
4639 .SendError("'frame_xpath' missing or invalid."); | 4639 .SendError("'frame_xpath' missing or invalid."); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4674 Browser* browser, | 4674 Browser* browser, |
4675 DictionaryValue* args, | 4675 DictionaryValue* args, |
4676 IPC::Message* reply_message) { | 4676 IPC::Message* reply_message) { |
4677 int tab_index; | 4677 int tab_index; |
4678 if (!args->GetInteger("tab_index", &tab_index)) { | 4678 if (!args->GetInteger("tab_index", &tab_index)) { |
4679 AutomationJSONReply(this, reply_message).SendError( | 4679 AutomationJSONReply(this, reply_message).SendError( |
4680 "Invalid or missing args"); | 4680 "Invalid or missing args"); |
4681 return; | 4681 return; |
4682 } | 4682 } |
4683 | 4683 |
4684 WebContents* web_contents = browser->GetWebContentsAt(tab_index); | 4684 WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); |
4685 if (!web_contents) { | 4685 if (!web_contents) { |
4686 AutomationJSONReply(this, reply_message).SendError( | 4686 AutomationJSONReply(this, reply_message).SendError( |
4687 StringPrintf("No such tab at index %d", tab_index)); | 4687 StringPrintf("No such tab at index %d", tab_index)); |
4688 return; | 4688 return; |
4689 } | 4689 } |
4690 | 4690 |
4691 new AutofillDisplayedObserver( | 4691 new AutofillDisplayedObserver( |
4692 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, | 4692 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, |
4693 web_contents->GetRenderViewHost(), this, reply_message); | 4693 web_contents->GetRenderViewHost(), this, reply_message); |
4694 SendWebKeyPressEventAsync(ui::VKEY_DOWN, web_contents); | 4694 SendWebKeyPressEventAsync(ui::VKEY_DOWN, web_contents); |
4695 } | 4695 } |
4696 | 4696 |
4697 void TestingAutomationProvider::AutofillHighlightSuggestion( | 4697 void TestingAutomationProvider::AutofillHighlightSuggestion( |
4698 Browser* browser, | 4698 Browser* browser, |
4699 DictionaryValue* args, | 4699 DictionaryValue* args, |
4700 IPC::Message* reply_message) { | 4700 IPC::Message* reply_message) { |
4701 int tab_index; | 4701 int tab_index; |
4702 if (!args->GetInteger("tab_index", &tab_index)) { | 4702 if (!args->GetInteger("tab_index", &tab_index)) { |
4703 AutomationJSONReply(this, reply_message).SendError( | 4703 AutomationJSONReply(this, reply_message).SendError( |
4704 "Invalid or missing args"); | 4704 "Invalid or missing args"); |
4705 return; | 4705 return; |
4706 } | 4706 } |
4707 | 4707 |
4708 WebContents* web_contents = browser->GetWebContentsAt(tab_index); | 4708 WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); |
4709 if (!web_contents) { | 4709 if (!web_contents) { |
4710 AutomationJSONReply(this, reply_message).SendError( | 4710 AutomationJSONReply(this, reply_message).SendError( |
4711 StringPrintf("No such tab at index %d", tab_index)); | 4711 StringPrintf("No such tab at index %d", tab_index)); |
4712 return; | 4712 return; |
4713 } | 4713 } |
4714 | 4714 |
4715 std::string direction; | 4715 std::string direction; |
4716 if (!args->GetString("direction", &direction) || (direction != "up" && | 4716 if (!args->GetString("direction", &direction) || (direction != "up" && |
4717 direction != "down")) { | 4717 direction != "down")) { |
4718 AutomationJSONReply(this, reply_message).SendError( | 4718 AutomationJSONReply(this, reply_message).SendError( |
(...skipping 12 matching lines...) Expand all Loading... |
4731 Browser* browser, | 4731 Browser* browser, |
4732 DictionaryValue* args, | 4732 DictionaryValue* args, |
4733 IPC::Message* reply_message) { | 4733 IPC::Message* reply_message) { |
4734 int tab_index; | 4734 int tab_index; |
4735 if (!args->GetInteger("tab_index", &tab_index)) { | 4735 if (!args->GetInteger("tab_index", &tab_index)) { |
4736 AutomationJSONReply(this, reply_message).SendError( | 4736 AutomationJSONReply(this, reply_message).SendError( |
4737 "Invalid or missing args"); | 4737 "Invalid or missing args"); |
4738 return; | 4738 return; |
4739 } | 4739 } |
4740 | 4740 |
4741 WebContents* web_contents = browser->GetWebContentsAt(tab_index); | 4741 WebContents* web_contents = chrome::GetWebContentsAt(browser, tab_index); |
4742 if (!web_contents) { | 4742 if (!web_contents) { |
4743 AutomationJSONReply(this, reply_message).SendError( | 4743 AutomationJSONReply(this, reply_message).SendError( |
4744 StringPrintf("No such tab at index %d", tab_index)); | 4744 StringPrintf("No such tab at index %d", tab_index)); |
4745 return; | 4745 return; |
4746 } | 4746 } |
4747 | 4747 |
4748 new AutofillDisplayedObserver( | 4748 new AutofillDisplayedObserver( |
4749 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, | 4749 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, |
4750 web_contents->GetRenderViewHost(), this, reply_message); | 4750 web_contents->GetRenderViewHost(), this, reply_message); |
4751 SendWebKeyPressEventAsync(ui::VKEY_RETURN, web_contents); | 4751 SendWebKeyPressEventAsync(ui::VKEY_RETURN, web_contents); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5439 | 5439 |
5440 std::string error; | 5440 std::string error; |
5441 Browser* browser; | 5441 Browser* browser; |
5442 WebContents* web_contents; | 5442 WebContents* web_contents; |
5443 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 5443 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
5444 AutomationJSONReply(this, reply_message).SendError(error); | 5444 AutomationJSONReply(this, reply_message).SendError(error); |
5445 return; | 5445 return; |
5446 } | 5446 } |
5447 // The key events will be sent to the browser window, we need the current tab | 5447 // The key events will be sent to the browser window, we need the current tab |
5448 // containing the element we send the text in to be shown. | 5448 // containing the element we send the text in to be shown. |
5449 browser->ActivateTabAt( | 5449 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents), |
5450 browser->GetIndexOfController(&web_contents->GetController()), true); | 5450 true); |
5451 | 5451 |
5452 BrowserWindow* browser_window = browser->window(); | 5452 BrowserWindow* browser_window = browser->window(); |
5453 if (!browser_window) { | 5453 if (!browser_window) { |
5454 AutomationJSONReply(this, reply_message) | 5454 AutomationJSONReply(this, reply_message) |
5455 .SendError("Could not get the browser window"); | 5455 .SendError("Could not get the browser window"); |
5456 return; | 5456 return; |
5457 } | 5457 } |
5458 gfx::NativeWindow window = browser_window->GetNativeWindow(); | 5458 gfx::NativeWindow window = browser_window->GetNativeWindow(); |
5459 if (!window) { | 5459 if (!window) { |
5460 AutomationJSONReply(this, reply_message) | 5460 AutomationJSONReply(this, reply_message) |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5697 id.c_str())); | 5697 id.c_str())); |
5698 return; | 5698 return; |
5699 } | 5699 } |
5700 | 5700 |
5701 // Look at preferences to find the right launch container. If no preference | 5701 // Look at preferences to find the right launch container. If no preference |
5702 // is set, launch as a regular tab. | 5702 // is set, launch as a regular tab. |
5703 extension_misc::LaunchContainer launch_container = | 5703 extension_misc::LaunchContainer launch_container = |
5704 service->extension_prefs()->GetLaunchContainer( | 5704 service->extension_prefs()->GetLaunchContainer( |
5705 extension, ExtensionPrefs::LAUNCH_REGULAR); | 5705 extension, ExtensionPrefs::LAUNCH_REGULAR); |
5706 | 5706 |
5707 WebContents* old_contents = browser->GetActiveWebContents(); | 5707 WebContents* old_contents = chrome::GetActiveWebContents(browser); |
5708 if (!old_contents) { | 5708 if (!old_contents) { |
5709 AutomationJSONReply(this, reply_message).SendError( | 5709 AutomationJSONReply(this, reply_message).SendError( |
5710 "Cannot identify selected tab contents."); | 5710 "Cannot identify selected tab contents."); |
5711 return; | 5711 return; |
5712 } | 5712 } |
5713 | 5713 |
5714 // This observer will delete itself. | 5714 // This observer will delete itself. |
5715 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, | 5715 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, |
5716 launch_container); | 5716 launch_container); |
5717 application_launch::OpenApplication(profile(), extension, launch_container, | 5717 application_launch::OpenApplication(profile(), extension, launch_container, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5784 WebContents* web_contents; | 5784 WebContents* web_contents; |
5785 int tab_index; | 5785 int tab_index; |
5786 std::string error; | 5786 std::string error; |
5787 | 5787 |
5788 if (!args->GetInteger("tab_index", &tab_index)) { | 5788 if (!args->GetInteger("tab_index", &tab_index)) { |
5789 AutomationJSONReply(this, reply_message).SendError( | 5789 AutomationJSONReply(this, reply_message).SendError( |
5790 "Missing 'tab_index' argument."); | 5790 "Missing 'tab_index' argument."); |
5791 return; | 5791 return; |
5792 } | 5792 } |
5793 | 5793 |
5794 web_contents = browser->GetWebContentsAt(tab_index); | 5794 web_contents = chrome::GetWebContentsAt(browser, tab_index); |
5795 if (!web_contents) { | 5795 if (!web_contents) { |
5796 AutomationJSONReply(this, reply_message).SendError( | 5796 AutomationJSONReply(this, reply_message).SendError( |
5797 StringPrintf("Could not get WebContents at tab index %d", tab_index)); | 5797 StringPrintf("Could not get WebContents at tab index %d", tab_index)); |
5798 return; | 5798 return; |
5799 } | 5799 } |
5800 | 5800 |
5801 RenderViewHost* render_view = web_contents->GetRenderViewHost(); | 5801 RenderViewHost* render_view = web_contents->GetRenderViewHost(); |
5802 | 5802 |
5803 // This observer will delete itself. | 5803 // This observer will delete itself. |
5804 new V8HeapStatsObserver( | 5804 new V8HeapStatsObserver( |
(...skipping 13 matching lines...) Expand all Loading... |
5818 WebContents* web_contents; | 5818 WebContents* web_contents; |
5819 int tab_index; | 5819 int tab_index; |
5820 std::string error; | 5820 std::string error; |
5821 | 5821 |
5822 if (!args->GetInteger("tab_index", &tab_index)) { | 5822 if (!args->GetInteger("tab_index", &tab_index)) { |
5823 AutomationJSONReply(this, reply_message).SendError( | 5823 AutomationJSONReply(this, reply_message).SendError( |
5824 "Missing 'tab_index' argument."); | 5824 "Missing 'tab_index' argument."); |
5825 return; | 5825 return; |
5826 } | 5826 } |
5827 | 5827 |
5828 web_contents = browser->GetWebContentsAt(tab_index); | 5828 web_contents = chrome::GetWebContentsAt(browser, tab_index); |
5829 if (!web_contents) { | 5829 if (!web_contents) { |
5830 AutomationJSONReply(this, reply_message).SendError( | 5830 AutomationJSONReply(this, reply_message).SendError( |
5831 StringPrintf("Could not get WebContents at tab index %d", tab_index)); | 5831 StringPrintf("Could not get WebContents at tab index %d", tab_index)); |
5832 return; | 5832 return; |
5833 } | 5833 } |
5834 | 5834 |
5835 RenderViewHost* render_view = web_contents->GetRenderViewHost(); | 5835 RenderViewHost* render_view = web_contents->GetRenderViewHost(); |
5836 int routing_id = render_view->GetRoutingID(); | 5836 int routing_id = render_view->GetRoutingID(); |
5837 | 5837 |
5838 // This observer will delete itself. | 5838 // This observer will delete itself. |
(...skipping 18 matching lines...) Expand all Loading... |
5857 IPC::Message* reply_message) { | 5857 IPC::Message* reply_message) { |
5858 DictionaryValue dict; | 5858 DictionaryValue dict; |
5859 dict.SetBoolean("result", browser->IsFullscreenForTabOrPending()); | 5859 dict.SetBoolean("result", browser->IsFullscreenForTabOrPending()); |
5860 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5860 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
5861 } | 5861 } |
5862 | 5862 |
5863 void TestingAutomationProvider::IsMouseLocked(Browser* browser, | 5863 void TestingAutomationProvider::IsMouseLocked(Browser* browser, |
5864 base::DictionaryValue* args, | 5864 base::DictionaryValue* args, |
5865 IPC::Message* reply_message) { | 5865 IPC::Message* reply_message) { |
5866 DictionaryValue dict; | 5866 DictionaryValue dict; |
5867 dict.SetBoolean("result", browser->GetActiveWebContents()-> | 5867 dict.SetBoolean("result", chrome::GetActiveWebContents(browser)-> |
5868 GetRenderViewHost()->GetView()->IsMouseLocked()); | 5868 GetRenderViewHost()->GetView()->IsMouseLocked()); |
5869 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5869 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
5870 } | 5870 } |
5871 | 5871 |
5872 void TestingAutomationProvider::IsMouseLockPermissionRequested( | 5872 void TestingAutomationProvider::IsMouseLockPermissionRequested( |
5873 Browser* browser, | 5873 Browser* browser, |
5874 base::DictionaryValue* args, | 5874 base::DictionaryValue* args, |
5875 IPC::Message* reply_message) { | 5875 IPC::Message* reply_message) { |
5876 FullscreenExitBubbleType type = | 5876 FullscreenExitBubbleType type = |
5877 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5877 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5914 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5914 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
5915 DictionaryValue dict; | 5915 DictionaryValue dict; |
5916 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); | 5916 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); |
5917 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5917 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
5918 } | 5918 } |
5919 | 5919 |
5920 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( | 5920 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( |
5921 Browser* browser, | 5921 Browser* browser, |
5922 base::DictionaryValue* args, | 5922 base::DictionaryValue* args, |
5923 IPC::Message* reply_message) { | 5923 IPC::Message* reply_message) { |
5924 WebContents* fullscreen_tab = browser->GetActiveWebContents(); | 5924 WebContents* fullscreen_tab = chrome::GetActiveWebContents(browser); |
5925 FullscreenExitBubbleType type = | 5925 FullscreenExitBubbleType type = |
5926 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5926 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
5927 browser->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | 5927 browser->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); |
5928 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 5928 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
5929 } | 5929 } |
5930 | 5930 |
5931 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( | 5931 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( |
5932 Browser* browser, | 5932 Browser* browser, |
5933 base::DictionaryValue* args, | 5933 base::DictionaryValue* args, |
5934 IPC::Message* reply_message) { | 5934 IPC::Message* reply_message) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6057 if (has_handle) { | 6057 if (has_handle) { |
6058 TabContents* tab = TabContents::FromWebContents( | 6058 TabContents* tab = TabContents::FromWebContents( |
6059 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); | 6059 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); |
6060 id = tab->restore_tab_helper()->session_id().id(); | 6060 id = tab->restore_tab_helper()->session_id().id(); |
6061 } | 6061 } |
6062 BrowserList::const_iterator iter = BrowserList::begin(); | 6062 BrowserList::const_iterator iter = BrowserList::begin(); |
6063 int browser_index = 0; | 6063 int browser_index = 0; |
6064 for (; iter != BrowserList::end(); ++iter, ++browser_index) { | 6064 for (; iter != BrowserList::end(); ++iter, ++browser_index) { |
6065 Browser* browser = *iter; | 6065 Browser* browser = *iter; |
6066 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { | 6066 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { |
6067 TabContents* tab = browser->GetTabContentsAt(tab_index); | 6067 TabContents* tab = chrome::GetTabContentsAt(browser, tab_index); |
6068 if (tab->restore_tab_helper()->session_id().id() == id) { | 6068 if (tab->restore_tab_helper()->session_id().id() == id) { |
6069 DictionaryValue dict; | 6069 DictionaryValue dict; |
6070 dict.SetInteger("windex", browser_index); | 6070 dict.SetInteger("windex", browser_index); |
6071 dict.SetInteger("tab_index", tab_index); | 6071 dict.SetInteger("tab_index", tab_index); |
6072 reply.SendSuccess(&dict); | 6072 reply.SendSuccess(&dict); |
6073 return; | 6073 return; |
6074 } | 6074 } |
6075 } | 6075 } |
6076 } | 6076 } |
6077 reply.SendError("Could not find tab among current browser windows"); | 6077 reply.SendError("Could not find tab among current browser windows"); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6403 automation_util::SetCookieJSON(this, args, reply_message); | 6403 automation_util::SetCookieJSON(this, args, reply_message); |
6404 } | 6404 } |
6405 | 6405 |
6406 void TestingAutomationProvider::GetTabIds( | 6406 void TestingAutomationProvider::GetTabIds( |
6407 DictionaryValue* args, IPC::Message* reply_message) { | 6407 DictionaryValue* args, IPC::Message* reply_message) { |
6408 ListValue* id_list = new ListValue(); | 6408 ListValue* id_list = new ListValue(); |
6409 BrowserList::const_iterator iter = BrowserList::begin(); | 6409 BrowserList::const_iterator iter = BrowserList::begin(); |
6410 for (; iter != BrowserList::end(); ++iter) { | 6410 for (; iter != BrowserList::end(); ++iter) { |
6411 Browser* browser = *iter; | 6411 Browser* browser = *iter; |
6412 for (int i = 0; i < browser->tab_count(); ++i) { | 6412 for (int i = 0; i < browser->tab_count(); ++i) { |
6413 int id = browser->GetTabContentsAt(i)->restore_tab_helper()-> | 6413 int id = chrome::GetTabContentsAt(browser, i)->restore_tab_helper()-> |
6414 session_id().id(); | 6414 session_id().id(); |
6415 id_list->Append(Value::CreateIntegerValue(id)); | 6415 id_list->Append(Value::CreateIntegerValue(id)); |
6416 } | 6416 } |
6417 } | 6417 } |
6418 DictionaryValue dict; | 6418 DictionaryValue dict; |
6419 dict.Set("ids", id_list); | 6419 dict.Set("ids", id_list); |
6420 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6420 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
6421 } | 6421 } |
6422 | 6422 |
6423 void TestingAutomationProvider::GetViews( | 6423 void TestingAutomationProvider::GetViews( |
6424 DictionaryValue* args, IPC::Message* reply_message) { | 6424 DictionaryValue* args, IPC::Message* reply_message) { |
6425 ListValue* view_list = new ListValue(); | 6425 ListValue* view_list = new ListValue(); |
6426 printing::PrintPreviewTabController* preview_controller = | 6426 printing::PrintPreviewTabController* preview_controller = |
6427 printing::PrintPreviewTabController::GetInstance(); | 6427 printing::PrintPreviewTabController::GetInstance(); |
6428 BrowserList::const_iterator browser_iter = BrowserList::begin(); | 6428 BrowserList::const_iterator browser_iter = BrowserList::begin(); |
6429 for (; browser_iter != BrowserList::end(); ++browser_iter) { | 6429 for (; browser_iter != BrowserList::end(); ++browser_iter) { |
6430 Browser* browser = *browser_iter; | 6430 Browser* browser = *browser_iter; |
6431 for (int i = 0; i < browser->tab_count(); ++i) { | 6431 for (int i = 0; i < browser->tab_count(); ++i) { |
6432 TabContents* tab = browser->GetTabContentsAt(i); | 6432 TabContents* tab = chrome::GetTabContentsAt(browser, i); |
6433 DictionaryValue* dict = new DictionaryValue(); | 6433 DictionaryValue* dict = new DictionaryValue(); |
6434 AutomationId id = automation_util::GetIdForTab(tab); | 6434 AutomationId id = automation_util::GetIdForTab(tab); |
6435 dict->Set("auto_id", id.ToValue()); | 6435 dict->Set("auto_id", id.ToValue()); |
6436 view_list->Append(dict); | 6436 view_list->Append(dict); |
6437 if (preview_controller) { | 6437 if (preview_controller) { |
6438 TabContents* preview_tab = | 6438 TabContents* preview_tab = |
6439 preview_controller->GetPrintPreviewForTab(tab); | 6439 preview_controller->GetPrintPreviewForTab(tab); |
6440 if (preview_tab) { | 6440 if (preview_tab) { |
6441 DictionaryValue* dict = new DictionaryValue(); | 6441 DictionaryValue* dict = new DictionaryValue(); |
6442 AutomationId id = automation_util::GetIdForTab(preview_tab); | 6442 AutomationId id = automation_util::GetIdForTab(preview_tab); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6475 int id; | 6475 int id; |
6476 if (!args->GetInteger("id", &id)) { | 6476 if (!args->GetInteger("id", &id)) { |
6477 reply.SendError("'id' missing or invalid"); | 6477 reply.SendError("'id' missing or invalid"); |
6478 return; | 6478 return; |
6479 } | 6479 } |
6480 bool is_valid = false; | 6480 bool is_valid = false; |
6481 BrowserList::const_iterator iter = BrowserList::begin(); | 6481 BrowserList::const_iterator iter = BrowserList::begin(); |
6482 for (; iter != BrowserList::end(); ++iter) { | 6482 for (; iter != BrowserList::end(); ++iter) { |
6483 Browser* browser = *iter; | 6483 Browser* browser = *iter; |
6484 for (int i = 0; i < browser->tab_count(); ++i) { | 6484 for (int i = 0; i < browser->tab_count(); ++i) { |
6485 TabContents* tab = browser->GetTabContentsAt(i); | 6485 TabContents* tab = chrome::GetTabContentsAt(browser, i); |
6486 if (tab->restore_tab_helper()->session_id().id() == id) { | 6486 if (tab->restore_tab_helper()->session_id().id() == id) { |
6487 is_valid = true; | 6487 is_valid = true; |
6488 break; | 6488 break; |
6489 } | 6489 } |
6490 } | 6490 } |
6491 } | 6491 } |
6492 DictionaryValue dict; | 6492 DictionaryValue dict; |
6493 dict.SetBoolean("is_valid", is_valid); | 6493 dict.SetBoolean("is_valid", is_valid); |
6494 reply.SendSuccess(&dict); | 6494 reply.SendSuccess(&dict); |
6495 } | 6495 } |
(...skipping 15 matching lines...) Expand all Loading... |
6511 } | 6511 } |
6512 | 6512 |
6513 void TestingAutomationProvider::CloseTabJSON( | 6513 void TestingAutomationProvider::CloseTabJSON( |
6514 DictionaryValue* args, IPC::Message* reply_message) { | 6514 DictionaryValue* args, IPC::Message* reply_message) { |
6515 AutomationJSONReply reply(this, reply_message); | 6515 AutomationJSONReply reply(this, reply_message); |
6516 Browser* browser; | 6516 Browser* browser; |
6517 WebContents* tab; | 6517 WebContents* tab; |
6518 std::string error; | 6518 std::string error; |
6519 // Close tabs synchronously. | 6519 // Close tabs synchronously. |
6520 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 6520 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
6521 browser->CloseTabContents(tab); | 6521 chrome::CloseWebContents(browser, tab); |
6522 reply.SendSuccess(NULL); | 6522 reply.SendSuccess(NULL); |
6523 return; | 6523 return; |
6524 } | 6524 } |
6525 | 6525 |
6526 // Close other types of views asynchronously. | 6526 // Close other types of views asynchronously. |
6527 RenderViewHost* view; | 6527 RenderViewHost* view; |
6528 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 6528 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
6529 reply.SendError(error); | 6529 reply.SendError(error); |
6530 return; | 6530 return; |
6531 } | 6531 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6591 return; | 6591 return; |
6592 | 6592 |
6593 AutomationJSONReply reply(this, reply_message); | 6593 AutomationJSONReply reply(this, reply_message); |
6594 Browser* browser; | 6594 Browser* browser; |
6595 WebContents* web_contents; | 6595 WebContents* web_contents; |
6596 std::string error; | 6596 std::string error; |
6597 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 6597 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
6598 reply.SendError(error); | 6598 reply.SendError(error); |
6599 return; | 6599 return; |
6600 } | 6600 } |
6601 browser->ActivateTabAt( | 6601 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents), |
6602 browser->GetIndexOfController(&web_contents->GetController()), true); | 6602 true); |
6603 reply.SendSuccess(NULL); | 6603 reply.SendSuccess(NULL); |
6604 } | 6604 } |
6605 | 6605 |
6606 void TestingAutomationProvider::IsPageActionVisible( | 6606 void TestingAutomationProvider::IsPageActionVisible( |
6607 base::DictionaryValue* args, | 6607 base::DictionaryValue* args, |
6608 IPC::Message* reply_message) { | 6608 IPC::Message* reply_message) { |
6609 AutomationJSONReply reply(this, reply_message); | 6609 AutomationJSONReply reply(this, reply_message); |
6610 | 6610 |
6611 WebContents* tab; | 6611 WebContents* tab; |
6612 std::string error; | 6612 std::string error; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6730 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 6730 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
6731 } | 6731 } |
6732 | 6732 |
6733 void TestingAutomationProvider::OnRemoveProvider() { | 6733 void TestingAutomationProvider::OnRemoveProvider() { |
6734 if (g_browser_process) | 6734 if (g_browser_process) |
6735 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6735 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6736 } | 6736 } |
6737 | 6737 |
6738 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6738 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6739 WebContents* tab) { | 6739 WebContents* tab) { |
6740 if (browser->GetActiveWebContents() != tab) { | 6740 if (chrome::GetActiveWebContents(browser) != tab) |
6741 browser->ActivateTabAt(browser->GetIndexOfController( | 6741 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
6742 &tab->GetController()), true); | |
6743 } | |
6744 } | 6742 } |
OLD | NEW |