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

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

Issue 6854035: Move blocked content from TabContents to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/autofill/personal_data_manager.h" 29 #include "chrome/browser/autofill/personal_data_manager.h"
30 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" 30 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h"
31 #include "chrome/browser/automation/automation_browser_tracker.h" 31 #include "chrome/browser/automation/automation_browser_tracker.h"
32 #include "chrome/browser/automation/automation_provider_json.h" 32 #include "chrome/browser/automation/automation_provider_json.h"
33 #include "chrome/browser/automation/automation_provider_list.h" 33 #include "chrome/browser/automation/automation_provider_list.h"
34 #include "chrome/browser/automation/automation_provider_observers.h" 34 #include "chrome/browser/automation/automation_provider_observers.h"
35 #include "chrome/browser/automation/automation_tab_tracker.h" 35 #include "chrome/browser/automation/automation_tab_tracker.h"
36 #include "chrome/browser/automation/automation_util.h" 36 #include "chrome/browser/automation/automation_util.h"
37 #include "chrome/browser/automation/automation_window_tracker.h" 37 #include "chrome/browser/automation/automation_window_tracker.h"
38 #include "chrome/browser/automation/ui_controls.h" 38 #include "chrome/browser/automation/ui_controls.h"
39 #include "chrome/browser/blocked_content_container.h"
40 #include "chrome/browser/bookmarks/bookmark_model.h" 39 #include "chrome/browser/bookmarks/bookmark_model.h"
41 #include "chrome/browser/bookmarks/bookmark_storage.h" 40 #include "chrome/browser/bookmarks/bookmark_storage.h"
42 #include "chrome/browser/browser_process.h" 41 #include "chrome/browser/browser_process.h"
43 #include "chrome/browser/browser_shutdown.h" 42 #include "chrome/browser/browser_shutdown.h"
44 #include "chrome/browser/debugger/devtools_manager.h" 43 #include "chrome/browser/debugger/devtools_manager.h"
45 #include "chrome/browser/download/download_prefs.h" 44 #include "chrome/browser/download/download_prefs.h"
46 #include "chrome/browser/download/download_shelf.h" 45 #include "chrome/browser/download/download_shelf.h"
47 #include "chrome/browser/download/save_package.h" 46 #include "chrome/browser/download/save_package.h"
48 #include "chrome/browser/extensions/extension_host.h" 47 #include "chrome/browser/extensions/extension_host.h"
49 #include "chrome/browser/extensions/extension_service.h" 48 #include "chrome/browser/extensions/extension_service.h"
(...skipping 14 matching lines...) Expand all
64 #include "chrome/browser/search_engines/template_url_model.h" 63 #include "chrome/browser/search_engines/template_url_model.h"
65 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 64 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
66 #include "chrome/browser/tab_contents/link_infobar_delegate.h" 65 #include "chrome/browser/tab_contents/link_infobar_delegate.h"
67 #include "chrome/browser/themes/theme_service.h" 66 #include "chrome/browser/themes/theme_service.h"
68 #include "chrome/browser/themes/theme_service_factory.h" 67 #include "chrome/browser/themes/theme_service_factory.h"
69 #include "chrome/browser/translate/translate_infobar_delegate.h" 68 #include "chrome/browser/translate/translate_infobar_delegate.h"
70 #include "chrome/browser/translate/translate_tab_helper.h" 69 #include "chrome/browser/translate/translate_tab_helper.h"
71 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 70 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
72 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 71 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
73 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 72 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
73 #include "chrome/browser/ui/content_settings/content_settings_tab_helper.h"
74 #include "chrome/browser/ui/browser_window.h" 74 #include "chrome/browser/ui/browser_window.h"
75 #include "chrome/browser/ui/download/download_tab_helper.h" 75 #include "chrome/browser/ui/download/download_tab_helper.h"
76 #include "chrome/browser/ui/find_bar/find_bar.h" 76 #include "chrome/browser/ui/find_bar/find_bar.h"
77 #include "chrome/browser/ui/login/login_prompt.h" 77 #include "chrome/browser/ui/login/login_prompt.h"
78 #include "chrome/browser/ui/omnibox/location_bar.h" 78 #include "chrome/browser/ui/omnibox/location_bar.h"
79 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 79 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
80 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 80 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
81 #include "chrome/browser/ui/webui/shown_sections_handler.h" 81 #include "chrome/browser/ui/webui/shown_sections_handler.h"
82 #include "chrome/common/automation_messages.h" 82 #include "chrome/common/automation_messages.h"
83 #include "chrome/common/chrome_constants.h" 83 #include "chrome/common/chrome_constants.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 tab_tracker_->GetResource(handle)->tab_contents() : NULL; 532 tab_tracker_->GetResource(handle)->tab_contents() : NULL;
533 automation_util::DeleteCookie(url, cookie_name, contents, success); 533 automation_util::DeleteCookie(url, cookie_name, contents, success);
534 } 534 }
535 535
536 void TestingAutomationProvider::ShowCollectedCookiesDialog( 536 void TestingAutomationProvider::ShowCollectedCookiesDialog(
537 int handle, bool* success) { 537 int handle, bool* success) {
538 *success = false; 538 *success = false;
539 if (tab_tracker_->ContainsHandle(handle)) { 539 if (tab_tracker_->ContainsHandle(handle)) {
540 TabContents* tab_contents = 540 TabContents* tab_contents =
541 tab_tracker_->GetResource(handle)->tab_contents(); 541 tab_tracker_->GetResource(handle)->tab_contents();
542 tab_contents->delegate()->ShowCollectedCookiesDialog(tab_contents); 542 TabContentsWrapper* wrapper =
543 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
544 wrapper->content_settings_tab_helper()->delegate()->
545 ShowCollectedCookiesDialog(tab_contents);
543 *success = true; 546 *success = true;
544 } 547 }
545 } 548 }
546 549
547 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( 550 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete(
548 int handle, const GURL& url, int number_of_navigations, 551 int handle, const GURL& url, int number_of_navigations,
549 IPC::Message* reply_message) { 552 IPC::Message* reply_message) {
550 if (tab_tracker_->ContainsHandle(handle)) { 553 if (tab_tracker_->ContainsHandle(handle)) {
551 NavigationController* tab = tab_tracker_->GetResource(handle); 554 NavigationController* tab = tab_tracker_->GetResource(handle);
552 555
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 else 2003 else
2001 browser->window()->GetDownloadShelf()->Close(); 2004 browser->window()->GetDownloadShelf()->Close();
2002 } 2005 }
2003 } 2006 }
2004 } 2007 }
2005 2008
2006 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { 2009 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) {
2007 *count = -1; // -1 is the error code 2010 *count = -1; // -1 is the error code
2008 if (tab_tracker_->ContainsHandle(handle)) { 2011 if (tab_tracker_->ContainsHandle(handle)) {
2009 NavigationController* nav_controller = tab_tracker_->GetResource(handle); 2012 NavigationController* nav_controller = tab_tracker_->GetResource(handle);
2010 TabContents* tab_contents = nav_controller->tab_contents(); 2013 TabContentsWrapper* tab_contents =
2014 TabContentsWrapper::GetCurrentWrapperForContents(
2015 nav_controller->tab_contents());
2011 if (tab_contents) { 2016 if (tab_contents) {
2012 BlockedContentContainer* container = 2017 ContentSettingsTabHelper* content_settings =
2013 tab_contents->blocked_content_container(); 2018 tab_contents->content_settings_tab_helper();
2014 if (container) { 2019 *count = static_cast<int>(content_settings->GetBlockedContentsCount());
2015 *count = static_cast<int>(container->GetBlockedContentsCount());
2016 } else {
2017 // If we don't have a container, we don't have any blocked popups to
2018 // contain!
2019 *count = 0;
2020 }
2021 } 2020 }
2022 } 2021 }
2023 } 2022 }
2024 2023
2025 void TestingAutomationProvider::SendJSONRequest(int handle, 2024 void TestingAutomationProvider::SendJSONRequest(int handle,
2026 const std::string& json_request, 2025 const std::string& json_request,
2027 IPC::Message* reply_message) { 2026 IPC::Message* reply_message) {
2028 scoped_ptr<Value> values; 2027 scoped_ptr<Value> values;
2029 base::JSONReader reader; 2028 base::JSONReader reader;
2030 std::string error; 2029 std::string error;
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 3531
3533 remover->AddObserver( 3532 remover->AddObserver(
3534 new AutomationProviderBrowsingDataObserver(this, reply_message)); 3533 new AutomationProviderBrowsingDataObserver(this, reply_message));
3535 remover->Remove(remove_mask); 3534 remover->Remove(remove_mask);
3536 // BrowsingDataRemover deletes itself using DeleteTask. 3535 // BrowsingDataRemover deletes itself using DeleteTask.
3537 // The observer also deletes itself after sending the reply. 3536 // The observer also deletes itself after sending the reply.
3538 } 3537 }
3539 3538
3540 namespace { 3539 namespace {
3541 3540
3542 // Get the TabContents from a dictionary of arguments. 3541 // Get the TabContentsWrapper from a dictionary of arguments.
3543 TabContents* GetTabContentsFromDict(const Browser* browser, 3542 TabContentsWrapper* GetTabContentsWrapperFromDict(const Browser* browser,
3544 const DictionaryValue* args, 3543 const DictionaryValue* args,
3545 std::string* error_message) { 3544 std::string* error_message) {
3546 int tab_index; 3545 int tab_index;
3547 if (!args->GetInteger("tab_index", &tab_index)) { 3546 if (!args->GetInteger("tab_index", &tab_index)) {
3548 *error_message = "Must include tab_index."; 3547 *error_message = "Must include tab_index.";
3549 return NULL; 3548 return NULL;
3550 }
3551
3552 TabContents* tab_contents = browser->GetTabContentsAt(tab_index);
3553 if (!tab_contents) {
3554 *error_message = StringPrintf("No tab at index %d.", tab_index);
3555 return NULL;
3556 }
3557 return tab_contents;
3558 } 3549 }
3559 3550
3560 // Get the TranslateInfoBarDelegate from TabContents. 3551 TabContentsWrapper* tab_contents =
3561 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( 3552 browser->GetTabContentsWrapperAt(tab_index);
3562 TabContents* tab_contents) { 3553 if (!tab_contents) {
3563 for (size_t i = 0; i < tab_contents->infobar_count(); i++) { 3554 *error_message = StringPrintf("No tab at index %d.", tab_index);
3564 InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i);
3565 if (infobar->AsTranslateInfoBarDelegate())
3566 return infobar->AsTranslateInfoBarDelegate();
3567 }
3568 // No translate infobar.
3569 return NULL; 3555 return NULL;
3570 } 3556 }
3557 return tab_contents;
3558 }
3559
3560 // Get the TranslateInfoBarDelegate from TabContents.
3561 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate(
3562 TabContents* tab_contents) {
3563 for (size_t i = 0; i < tab_contents->infobar_count(); i++) {
3564 InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i);
3565 if (infobar->AsTranslateInfoBarDelegate())
3566 return infobar->AsTranslateInfoBarDelegate();
3567 }
3568 // No translate infobar.
3569 return NULL;
3570 }
3571
3571 } // namespace 3572 } // namespace
3572 3573
3573 void TestingAutomationProvider::FindInPage( 3574 void TestingAutomationProvider::FindInPage(
3574 Browser* browser, 3575 Browser* browser,
3575 DictionaryValue* args, 3576 DictionaryValue* args,
3576 IPC::Message* reply_message) { 3577 IPC::Message* reply_message) {
3577 std::string error_message; 3578 std::string error_message;
3578 TabContents* tab_contents = GetTabContentsFromDict(browser, args, 3579 TabContentsWrapper* tab_contents =
3579 &error_message); 3580 GetTabContentsWrapperFromDict(browser, args, &error_message);
3580 if (!tab_contents) { 3581 if (!tab_contents) {
3581 AutomationJSONReply(this, reply_message).SendError(error_message); 3582 AutomationJSONReply(this, reply_message).SendError(error_message);
3582 return; 3583 return;
3583 } 3584 }
3584 string16 search_string; 3585 string16 search_string;
3585 bool forward; 3586 bool forward;
3586 bool match_case; 3587 bool match_case;
3587 bool find_next; 3588 bool find_next;
3588 if (!args->GetString("search_string", &search_string)) { 3589 if (!args->GetString("search_string", &search_string)) {
3589 AutomationJSONReply(this, reply_message). 3590 AutomationJSONReply(this, reply_message).
3590 SendError("Must include search_string string."); 3591 SendError("Must include search_string string.");
3591 return; 3592 return;
3592 } 3593 }
3593 if (!args->GetBoolean("forward", &forward)) { 3594 if (!args->GetBoolean("forward", &forward)) {
3594 AutomationJSONReply(this, reply_message). 3595 AutomationJSONReply(this, reply_message).
3595 SendError("Must include forward boolean."); 3596 SendError("Must include forward boolean.");
3596 return; 3597 return;
3597 } 3598 }
3598 if (!args->GetBoolean("match_case", &match_case)) { 3599 if (!args->GetBoolean("match_case", &match_case)) {
3599 AutomationJSONReply(this, reply_message). 3600 AutomationJSONReply(this, reply_message).
3600 SendError("Must include match_case boolean."); 3601 SendError("Must include match_case boolean.");
3601 return; 3602 return;
3602 } 3603 }
3603 if (!args->GetBoolean("find_next", &find_next)) { 3604 if (!args->GetBoolean("find_next", &find_next)) {
3604 AutomationJSONReply(this, reply_message). 3605 AutomationJSONReply(this, reply_message).
3605 SendError("Must include find_next boolean."); 3606 SendError("Must include find_next boolean.");
3606 return; 3607 return;
3607 } 3608 }
3608 SendFindRequest(tab_contents, 3609 SendFindRequest(tab_contents->tab_contents(),
3609 true, 3610 true,
3610 search_string, 3611 search_string,
3611 forward, 3612 forward,
3612 match_case, 3613 match_case,
3613 find_next, 3614 find_next,
3614 reply_message); 3615 reply_message);
3615 } 3616 }
3616 3617
3617 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json 3618 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json
3618 // input and output. 3619 // input and output.
3619 void TestingAutomationProvider::GetTranslateInfo( 3620 void TestingAutomationProvider::GetTranslateInfo(
3620 Browser* browser, 3621 Browser* browser,
3621 DictionaryValue* args, 3622 DictionaryValue* args,
3622 IPC::Message* reply_message) { 3623 IPC::Message* reply_message) {
3623 std::string error_message; 3624 std::string error_message;
3624 TabContents* tab_contents = GetTabContentsFromDict(browser, args, 3625 TabContentsWrapper* tab_contents_wrapper =
3625 &error_message); 3626 GetTabContentsWrapperFromDict(browser, args, &error_message);
3626 if (!tab_contents) { 3627 if (!tab_contents_wrapper) {
3627 AutomationJSONReply(this, reply_message).SendError(error_message); 3628 AutomationJSONReply(this, reply_message).SendError(error_message);
3628 return; 3629 return;
3629 } 3630 }
3630 3631
3632 TabContents* tab_contents = tab_contents_wrapper->tab_contents();
3631 // Get the translate bar if there is one and pass it to the observer. 3633 // Get the translate bar if there is one and pass it to the observer.
3632 // The observer will check for null and populate the information accordingly. 3634 // The observer will check for null and populate the information accordingly.
3633 TranslateInfoBarDelegate* translate_bar = 3635 TranslateInfoBarDelegate* translate_bar =
3634 GetTranslateInfoBarDelegate(tab_contents); 3636 GetTranslateInfoBarDelegate(tab_contents);
3635 3637
3636 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( 3638 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver(
3637 this, reply_message, tab_contents, translate_bar); 3639 this, reply_message, tab_contents, translate_bar);
3638 // If the language for the page hasn't been loaded yet, then just make 3640 // If the language for the page hasn't been loaded yet, then just make
3639 // the observer, otherwise call observe directly. 3641 // the observer, otherwise call observe directly.
3640 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( 3642 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents(
3641 tab_contents)->translate_tab_helper(); 3643 tab_contents)->translate_tab_helper();
3642 std::string language = helper->language_state().original_language(); 3644 std::string language = helper->language_state().original_language();
3643 if (!language.empty()) { 3645 if (!language.empty()) {
3644 observer->Observe(NotificationType::TAB_LANGUAGE_DETERMINED, 3646 observer->Observe(NotificationType::TAB_LANGUAGE_DETERMINED,
3645 Source<TabContents>(tab_contents), 3647 Source<TabContents>(tab_contents),
3646 Details<std::string>(&language)); 3648 Details<std::string>(&language));
3647 } 3649 }
3648 } 3650 }
3649 3651
3650 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample 3652 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample
3651 // json input. 3653 // json input.
3652 // Sample json output: {} 3654 // Sample json output: {}
3653 void TestingAutomationProvider::SelectTranslateOption( 3655 void TestingAutomationProvider::SelectTranslateOption(
3654 Browser* browser, 3656 Browser* browser,
3655 DictionaryValue* args, 3657 DictionaryValue* args,
3656 IPC::Message* reply_message) { 3658 IPC::Message* reply_message) {
3657 std::string option; 3659 std::string option;
3658 std::string error_message; 3660 std::string error_message;
3659 TabContents* tab_contents = GetTabContentsFromDict(browser, args, 3661 TabContentsWrapper* tab_contents_wrapper =
3660 &error_message); 3662 GetTabContentsWrapperFromDict(browser, args, &error_message);
3661 if (!tab_contents) { 3663 if (!tab_contents_wrapper) {
3662 AutomationJSONReply(this, reply_message).SendError(error_message); 3664 AutomationJSONReply(this, reply_message).SendError(error_message);
3663 return; 3665 return;
3664 } 3666 }
3665 3667
3668 TabContents* tab_contents = tab_contents_wrapper->tab_contents();
3666 TranslateInfoBarDelegate* translate_bar = 3669 TranslateInfoBarDelegate* translate_bar =
3667 GetTranslateInfoBarDelegate(tab_contents); 3670 GetTranslateInfoBarDelegate(tab_contents);
3668 if (!translate_bar) { 3671 if (!translate_bar) {
3669 AutomationJSONReply(this, reply_message) 3672 AutomationJSONReply(this, reply_message)
3670 .SendError("There is no translate bar open."); 3673 .SendError("There is no translate bar open.");
3671 return; 3674 return;
3672 } 3675 }
3673 3676
3674 if (!args->GetString("option", &option)) { 3677 if (!args->GetString("option", &option)) {
3675 AutomationJSONReply(this, reply_message).SendError("Must include option"); 3678 AutomationJSONReply(this, reply_message).SendError("Must include option");
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 3772
3770 // Sample json input: { "command": "GetBlockedPopupsInfo", 3773 // Sample json input: { "command": "GetBlockedPopupsInfo",
3771 // "tab_index": 1 } 3774 // "tab_index": 1 }
3772 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output. 3775 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output.
3773 void TestingAutomationProvider::GetBlockedPopupsInfo( 3776 void TestingAutomationProvider::GetBlockedPopupsInfo(
3774 Browser* browser, 3777 Browser* browser,
3775 DictionaryValue* args, 3778 DictionaryValue* args,
3776 IPC::Message* reply_message) { 3779 IPC::Message* reply_message) {
3777 AutomationJSONReply reply(this, reply_message); 3780 AutomationJSONReply reply(this, reply_message);
3778 std::string error_message; 3781 std::string error_message;
3779 TabContents* tab_contents = GetTabContentsFromDict( 3782 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict(
3780 browser, args, &error_message); 3783 browser, args, &error_message);
3781 if (!tab_contents) { 3784 if (!tab_contents) {
3782 reply.SendError(error_message); 3785 reply.SendError(error_message);
3783 return; 3786 return;
3784 } 3787 }
3785 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3788 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3786 BlockedContentContainer* popup_container = 3789 ContentSettingsTabHelper* content_settings =
3787 tab_contents->blocked_content_container(); 3790 tab_contents->content_settings_tab_helper();
3788 ListValue* blocked_popups_list = new ListValue; 3791 ListValue* blocked_popups_list = new ListValue;
3789 if (popup_container) { 3792 std::vector<TabContentsWrapper*> blocked_contents;
3790 std::vector<TabContents*> blocked_contents; 3793 content_settings->GetBlockedContents(&blocked_contents);
3791 popup_container->GetBlockedContents(&blocked_contents); 3794 for (std::vector<TabContentsWrapper*>::const_iterator it =
3792 for (std::vector<TabContents*>::const_iterator it = 3795 blocked_contents.begin(); it != blocked_contents.end(); ++it) {
3793 blocked_contents.begin(); it != blocked_contents.end(); ++it) { 3796 DictionaryValue* item = new DictionaryValue;
3794 DictionaryValue* item = new DictionaryValue; 3797 item->SetString("url", (*it)->tab_contents()->GetURL().spec());
3795 item->SetString("url", (*it)->GetURL().spec()); 3798 item->SetString("title", (*it)->tab_contents()->GetTitle());
3796 item->SetString("title", (*it)->GetTitle()); 3799 blocked_popups_list->Append(item);
3797 blocked_popups_list->Append(item);
3798 }
3799 } 3800 }
3800 return_value->Set("blocked_popups", blocked_popups_list); 3801 return_value->Set("blocked_popups", blocked_popups_list);
3801 reply.SendSuccess(return_value.get()); 3802 reply.SendSuccess(return_value.get());
3802 } 3803 }
3803 3804
3804 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input. 3805 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input.
3805 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup( 3806 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup(
3806 Browser* browser, 3807 Browser* browser,
3807 DictionaryValue* args, 3808 DictionaryValue* args,
3808 IPC::Message* reply_message) { 3809 IPC::Message* reply_message) {
3809 AutomationJSONReply reply(this, reply_message); 3810 AutomationJSONReply reply(this, reply_message);
3810 std::string error_message; 3811 std::string error_message;
3811 TabContents* tab_contents = GetTabContentsFromDict( 3812 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict(
3812 browser, args, &error_message); 3813 browser, args, &error_message);
3813 if (!tab_contents) { 3814 if (!tab_contents) {
3814 reply.SendError(error_message); 3815 reply.SendError(error_message);
3815 return; 3816 return;
3816 } 3817 }
3817 int popup_index; 3818 int popup_index;
3818 if (!args->GetInteger("popup_index", &popup_index)) { 3819 if (!args->GetInteger("popup_index", &popup_index)) {
3819 reply.SendError("Need popup_index arg"); 3820 reply.SendError("Need popup_index arg");
3820 return; 3821 return;
3821 } 3822 }
3822 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3823 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3823 BlockedContentContainer* content_container = 3824 ContentSettingsTabHelper* content_settings =
3824 tab_contents->blocked_content_container(); 3825 tab_contents->content_settings_tab_helper();
3825 if (!content_container || 3826 if (popup_index >= (int)content_settings->GetBlockedContentsCount()) {
3826 popup_index >= (int)content_container->GetBlockedContentsCount()) {
3827 reply.SendError(StringPrintf("No popup at index %d", popup_index)); 3827 reply.SendError(StringPrintf("No popup at index %d", popup_index));
3828 return; 3828 return;
3829 } 3829 }
3830 std::vector<TabContents*> blocked_contents; 3830 std::vector<TabContentsWrapper*> blocked_contents;
3831 content_container->GetBlockedContents(&blocked_contents); 3831 content_settings->GetBlockedContents(&blocked_contents);
3832 content_container->LaunchForContents(blocked_contents[popup_index]); 3832 content_settings->LaunchForContents(blocked_contents[popup_index]);
3833 reply.SendSuccess(NULL); 3833 reply.SendSuccess(NULL);
3834 } 3834 }
3835 3835
3836 // Sample json input: { "command": "GetThemeInfo" } 3836 // Sample json input: { "command": "GetThemeInfo" }
3837 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. 3837 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output.
3838 void TestingAutomationProvider::GetThemeInfo( 3838 void TestingAutomationProvider::GetThemeInfo(
3839 Browser* browser, 3839 Browser* browser,
3840 DictionaryValue* args, 3840 DictionaryValue* args,
3841 IPC::Message* reply_message) { 3841 IPC::Message* reply_message) {
3842 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3842 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
5460 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 5460 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
5461 5461
5462 Send(reply_message_); 5462 Send(reply_message_);
5463 redirect_query_ = 0; 5463 redirect_query_ = 0;
5464 reply_message_ = NULL; 5464 reply_message_ = NULL;
5465 } 5465 }
5466 5466
5467 void TestingAutomationProvider::OnRemoveProvider() { 5467 void TestingAutomationProvider::OnRemoveProvider() {
5468 AutomationProviderList::GetInstance()->RemoveProvider(this); 5468 AutomationProviderList::GetInstance()->RemoveProvider(this);
5469 } 5469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698