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/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "chrome/browser/browsing_data_remover.h" | 39 #include "chrome/browser/browsing_data_remover.h" |
40 #include "chrome/browser/character_encoding.h" | 40 #include "chrome/browser/character_encoding.h" |
41 #include "chrome/browser/content_settings/host_content_settings_map.h" | 41 #include "chrome/browser/content_settings/host_content_settings_map.h" |
42 #include "chrome/browser/net/url_request_mock_util.h" | 42 #include "chrome/browser/net/url_request_mock_util.h" |
43 #include "chrome/browser/prefs/pref_service.h" | 43 #include "chrome/browser/prefs/pref_service.h" |
44 #include "chrome/browser/printing/print_job.h" | 44 #include "chrome/browser/printing/print_job.h" |
45 #include "chrome/browser/profiles/profile_manager.h" | 45 #include "chrome/browser/profiles/profile_manager.h" |
46 #include "chrome/browser/ssl/ssl_blocking_page.h" | 46 #include "chrome/browser/ssl/ssl_blocking_page.h" |
47 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 47 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
48 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 48 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 49 #include "chrome/browser/ui/browser_commands.h" |
49 #include "chrome/browser/ui/browser_finder.h" | 50 #include "chrome/browser/ui/browser_finder.h" |
50 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
51 #include "chrome/browser/ui/find_bar/find_bar.h" | 52 #include "chrome/browser/ui/find_bar/find_bar.h" |
52 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 53 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
53 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 54 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
54 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 55 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
55 #include "chrome/browser/ui/login/login_prompt.h" | 56 #include "chrome/browser/ui/login/login_prompt.h" |
56 #include "chrome/browser/ui/omnibox/location_bar.h" | 57 #include "chrome/browser/ui/omnibox/location_bar.h" |
57 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 58 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
58 #include "chrome/common/automation_constants.h" | 59 #include "chrome/common/automation_constants.h" |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 bool* success) { | 554 bool* success) { |
554 *success = false; | 555 *success = false; |
555 if (tab_tracker_->ContainsHandle(tab_handle)) { | 556 if (tab_tracker_->ContainsHandle(tab_handle)) { |
556 NavigationController* nav = tab_tracker_->GetResource(tab_handle); | 557 NavigationController* nav = tab_tracker_->GetResource(tab_handle); |
557 if (!nav) | 558 if (!nav) |
558 return; | 559 return; |
559 Browser* browser = FindAndActivateTab(nav); | 560 Browser* browser = FindAndActivateTab(nav); |
560 | 561 |
561 // If the browser has UI, simulate what a user would do. | 562 // If the browser has UI, simulate what a user would do. |
562 // Activate the tab and then click the encoding menu. | 563 // Activate the tab and then click the encoding menu. |
563 if (browser && | 564 if (browser && chrome::IsCommandEnabled(browser, IDC_ENCODING_MENU)) { |
564 browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) { | |
565 int selected_encoding_id = | 565 int selected_encoding_id = |
566 CharacterEncoding::GetCommandIdByCanonicalEncodingName(encoding_name); | 566 CharacterEncoding::GetCommandIdByCanonicalEncodingName(encoding_name); |
567 if (selected_encoding_id) { | 567 if (selected_encoding_id) { |
568 browser->OverrideEncoding(selected_encoding_id); | 568 browser->OverrideEncoding(selected_encoding_id); |
569 *success = true; | 569 *success = true; |
570 } | 570 } |
571 } else { | 571 } else { |
572 // There is no UI, Chrome probably runs as Chrome-Frame mode. | 572 // There is no UI, Chrome probably runs as Chrome-Frame mode. |
573 // Try to get WebContents and call its override_encoding method. | 573 // Try to get WebContents and call its override_encoding method. |
574 WebContents* contents = nav->GetWebContents(); | 574 WebContents* contents = nav->GetWebContents(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 749 |
750 return NULL; | 750 return NULL; |
751 } | 751 } |
752 | 752 |
753 void AutomationProvider::SaveAsAsync(int tab_handle) { | 753 void AutomationProvider::SaveAsAsync(int tab_handle) { |
754 NavigationController* tab = NULL; | 754 NavigationController* tab = NULL; |
755 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); | 755 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); |
756 if (web_contents) | 756 if (web_contents) |
757 web_contents->OnSavePage(); | 757 web_contents->OnSavePage(); |
758 } | 758 } |
OLD | NEW |