OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 if (!entry) | 736 if (!entry) |
737 return; // Can't star if there is no URL. | 737 return; // Can't star if there is no URL. |
738 const GURL& url = entry->display_url(); | 738 const GURL& url = entry->display_url(); |
739 if (url.is_empty() || !url.is_valid()) | 739 if (url.is_empty() || !url.is_valid()) |
740 return; | 740 return; |
741 | 741 |
742 model->SetURLStarred(url, entry->title(), true); | 742 model->SetURLStarred(url, entry->title(), true); |
743 window_->ShowBookmarkBubble(url, model->IsBookmarked(url)); | 743 window_->ShowBookmarkBubble(url, model->IsBookmarked(url)); |
744 } | 744 } |
745 | 745 |
| 746 void Browser::SavePage() { |
| 747 UserMetrics::RecordAction(L"SavePage", profile_); |
| 748 GetSelectedTabContents()->AsWebContents()->OnSavePage(); |
| 749 } |
| 750 |
746 void Browser::ViewSource() { | 751 void Browser::ViewSource() { |
747 UserMetrics::RecordAction(L"ViewSource", profile_); | 752 UserMetrics::RecordAction(L"ViewSource", profile_); |
748 | 753 |
749 TabContents* current_tab = GetSelectedTabContents(); | 754 TabContents* current_tab = GetSelectedTabContents(); |
750 NavigationEntry* entry = current_tab->controller()->GetLastCommittedEntry(); | 755 NavigationEntry* entry = current_tab->controller()->GetLastCommittedEntry(); |
751 if (entry) { | 756 if (entry) { |
752 GURL url("view-source:" + entry->url().spec()); | 757 GURL url("view-source:" + entry->url().spec()); |
753 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 758 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
754 } | 759 } |
755 } | 760 } |
756 | 761 |
757 #if defined(OS_WIN) | 762 #if defined(OS_WIN) |
758 | 763 |
759 void Browser::ClosePopups() { | 764 void Browser::ClosePopups() { |
760 UserMetrics::RecordAction(L"CloseAllSuppressedPopups", profile_); | 765 UserMetrics::RecordAction(L"CloseAllSuppressedPopups", profile_); |
761 GetSelectedTabContents()->CloseAllSuppressedPopups(); | 766 GetSelectedTabContents()->CloseAllSuppressedPopups(); |
762 } | 767 } |
763 | 768 |
764 void Browser::Print() { | 769 void Browser::Print() { |
765 UserMetrics::RecordAction(L"PrintPreview", profile_); | 770 UserMetrics::RecordAction(L"PrintPreview", profile_); |
766 GetSelectedTabContents()->AsWebContents()->PrintPreview(); | 771 GetSelectedTabContents()->AsWebContents()->PrintPreview(); |
767 } | 772 } |
768 | 773 |
769 void Browser::SavePage() { | |
770 UserMetrics::RecordAction(L"SavePage", profile_); | |
771 GetSelectedTabContents()->AsWebContents()->OnSavePage(); | |
772 } | |
773 | |
774 void Browser::ToggleEncodingAutoDetect() { | 774 void Browser::ToggleEncodingAutoDetect() { |
775 UserMetrics::RecordAction(L"AutoDetectChange", profile_); | 775 UserMetrics::RecordAction(L"AutoDetectChange", profile_); |
776 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 776 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
777 // Reload the page so we can try to auto-detect the charset. | 777 // Reload the page so we can try to auto-detect the charset. |
778 Reload(); | 778 Reload(); |
779 } | 779 } |
780 | 780 |
781 void Browser::OverrideEncoding(int encoding_id) { | 781 void Browser::OverrideEncoding(int encoding_id) { |
782 UserMetrics::RecordAction(L"OverrideEncoding", profile_); | 782 UserMetrics::RecordAction(L"OverrideEncoding", profile_); |
783 const std::wstring selected_encoding = | 783 const std::wstring selected_encoding = |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); | 1106 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); |
1107 break; | 1107 break; |
1108 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; | 1108 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; |
1109 case IDC_DUPLICATE_TAB: DuplicateTab(); break; | 1109 case IDC_DUPLICATE_TAB: DuplicateTab(); break; |
1110 case IDC_RESTORE_TAB: RestoreTab(); break; | 1110 case IDC_RESTORE_TAB: RestoreTab(); break; |
1111 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; | 1111 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; |
1112 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; | 1112 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; |
1113 case IDC_EXIT: Exit(); break; | 1113 case IDC_EXIT: Exit(); break; |
1114 | 1114 |
1115 // Page-related commands | 1115 // Page-related commands |
| 1116 case IDC_SAVE_PAGE: SavePage(); break; |
1116 case IDC_STAR: BookmarkCurrentPage(); break; | 1117 case IDC_STAR: BookmarkCurrentPage(); break; |
1117 case IDC_VIEW_SOURCE: ViewSource(); break; | 1118 case IDC_VIEW_SOURCE: ViewSource(); break; |
1118 #if defined(OS_WIN) | 1119 #if defined(OS_WIN) |
1119 case IDC_CLOSE_POPUPS: ClosePopups(); break; | 1120 case IDC_CLOSE_POPUPS: ClosePopups(); break; |
1120 case IDC_PRINT: Print(); break; | 1121 case IDC_PRINT: Print(); break; |
1121 case IDC_SAVE_PAGE: SavePage(); break; | |
1122 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 1122 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
1123 case IDC_ENCODING_UTF8: | 1123 case IDC_ENCODING_UTF8: |
1124 case IDC_ENCODING_UTF16LE: | 1124 case IDC_ENCODING_UTF16LE: |
1125 case IDC_ENCODING_ISO88591: | 1125 case IDC_ENCODING_ISO88591: |
1126 case IDC_ENCODING_WINDOWS1252: | 1126 case IDC_ENCODING_WINDOWS1252: |
1127 case IDC_ENCODING_GBK: | 1127 case IDC_ENCODING_GBK: |
1128 case IDC_ENCODING_GB18030: | 1128 case IDC_ENCODING_GB18030: |
1129 case IDC_ENCODING_BIG5HKSCS: | 1129 case IDC_ENCODING_BIG5HKSCS: |
1130 case IDC_ENCODING_BIG5: | 1130 case IDC_ENCODING_BIG5: |
1131 case IDC_ENCODING_KOREAN: | 1131 case IDC_ENCODING_KOREAN: |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 | 2418 |
2419 // We need to register the window position pref. | 2419 // We need to register the window position pref. |
2420 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2420 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
2421 window_pref.append(L"_"); | 2421 window_pref.append(L"_"); |
2422 window_pref.append(app_name); | 2422 window_pref.append(app_name); |
2423 PrefService* prefs = g_browser_process->local_state(); | 2423 PrefService* prefs = g_browser_process->local_state(); |
2424 DCHECK(prefs); | 2424 DCHECK(prefs); |
2425 | 2425 |
2426 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2426 prefs->RegisterDictionaryPref(window_pref.c_str()); |
2427 } | 2427 } |
OLD | NEW |