| 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 <commdlg.h> | 7 #include <commdlg.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 case IDC_STAR: | 351 case IDC_STAR: |
| 352 UserMetrics::RecordAction(L"Star", profile_); | 352 UserMetrics::RecordAction(L"Star", profile_); |
| 353 StarCurrentTabContents(); | 353 StarCurrentTabContents(); |
| 354 break; | 354 break; |
| 355 | 355 |
| 356 case IDC_OPENURL: | 356 case IDC_OPENURL: |
| 357 UserMetrics::RecordAction(L"LoadURL", profile_); | 357 UserMetrics::RecordAction(L"LoadURL", profile_); |
| 358 { | 358 { |
| 359 LocationBarView* lbv = GetLocationBarView(); | 359 LocationBarView* lbv = GetLocationBarView(); |
| 360 if (lbv) { | 360 if (lbv) { |
| 361 OpenURL(GURL(lbv->location_input()), lbv->disposition(), | 361 OpenURL(GURL(lbv->location_input()), GURL(), lbv->disposition(), |
| 362 lbv->transition()); | 362 lbv->transition()); |
| 363 } else { | 363 } else { |
| 364 OpenURL(GURL(), CURRENT_TAB, PageTransition::TYPED); | 364 OpenURL(GURL(), GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 break; | 367 break; |
| 368 | 368 |
| 369 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 369 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
| 370 // enabled in the page menu regardless of whether the command will do | 370 // enabled in the page menu regardless of whether the command will do |
| 371 // anything. When someone selects the menu item, we just act as if they hit | 371 // anything. When someone selects the menu item, we just act as if they hit |
| 372 // the keyboard shortcut for the command by sending the associated key press | 372 // the keyboard shortcut for the command by sending the associated key press |
| 373 // to windows. The real fix to this bug is to disable the commands when they | 373 // to windows. The real fix to this bug is to disable the commands when they |
| 374 // won't do anything. We'll need something like an overall clipboard command | 374 // won't do anything. We'll need something like an overall clipboard command |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 break; | 440 break; |
| 441 | 441 |
| 442 case IDC_VIEWSOURCE: { | 442 case IDC_VIEWSOURCE: { |
| 443 UserMetrics::RecordAction(L"ViewSource", profile_); | 443 UserMetrics::RecordAction(L"ViewSource", profile_); |
| 444 | 444 |
| 445 TabContents* current_tab = GetSelectedTabContents(); | 445 TabContents* current_tab = GetSelectedTabContents(); |
| 446 NavigationEntry* entry = | 446 NavigationEntry* entry = |
| 447 current_tab->controller()->GetLastCommittedEntry(); | 447 current_tab->controller()->GetLastCommittedEntry(); |
| 448 if (entry) { | 448 if (entry) { |
| 449 GURL url("view-source:" + entry->url().spec()); | 449 GURL url("view-source:" + entry->url().spec()); |
| 450 AddTabWithURL(url, PageTransition::LINK, true, NULL); | 450 AddTabWithURL(url, GURL(), PageTransition::LINK, true, NULL); |
| 451 } | 451 } |
| 452 break; | 452 break; |
| 453 } | 453 } |
| 454 | 454 |
| 455 case IDC_SHOW_JS_CONSOLE: { | 455 case IDC_SHOW_JS_CONSOLE: { |
| 456 UserMetrics::RecordAction(L"ShowJSConsole", profile_); | 456 UserMetrics::RecordAction(L"ShowJSConsole", profile_); |
| 457 TabContents* current_tab = GetSelectedTabContents(); | 457 TabContents* current_tab = GetSelectedTabContents(); |
| 458 if (current_tab && current_tab->AsWebContents()) { | 458 if (current_tab && current_tab->AsWebContents()) { |
| 459 WebContents* wc = current_tab->AsWebContents(); | 459 WebContents* wc = current_tab->AsWebContents(); |
| 460 wc->render_view_host()->ShowJavaScriptConsole(); | 460 wc->render_view_host()->ShowJavaScriptConsole(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 service->RemoveHistoricalTabById(tab.id); | 707 service->RemoveHistoricalTabById(tab.id); |
| 708 break; | 708 break; |
| 709 } | 709 } |
| 710 | 710 |
| 711 case IDC_EXIT: | 711 case IDC_EXIT: |
| 712 BrowserList::CloseAllBrowsers(true); | 712 BrowserList::CloseAllBrowsers(true); |
| 713 break; | 713 break; |
| 714 | 714 |
| 715 case IDC_HELPMENU: { | 715 case IDC_HELPMENU: { |
| 716 GURL help_url(l10n_util::GetString(IDS_HELP_CONTENT_URL)); | 716 GURL help_url(l10n_util::GetString(IDS_HELP_CONTENT_URL)); |
| 717 AddTabWithURL(help_url, PageTransition::AUTO_BOOKMARK, true, NULL); | 717 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, |
| 718 NULL); |
| 718 break; | 719 break; |
| 719 } | 720 } |
| 720 | 721 |
| 721 default: | 722 default: |
| 722 LOG(WARNING) << "Received Unimplemented Command: " << id << | 723 LOG(WARNING) << "Received Unimplemented Command: " << id << |
| 723 " from window " << GetTopLevelHWND(); | 724 " from window " << GetTopLevelHWND(); |
| 724 } | 725 } |
| 725 } | 726 } |
| 726 | 727 |
| 727 //////////////////////////////////////////////////////////////////////////////// | 728 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 30 matching lines...) Expand all Loading... |
| 758 } | 759 } |
| 759 | 760 |
| 760 void Browser::Reload() { | 761 void Browser::Reload() { |
| 761 // If we are showing an interstitial, treat this as an OpenURL. | 762 // If we are showing an interstitial, treat this as an OpenURL. |
| 762 TabContents* current_tab = GetSelectedTabContents(); | 763 TabContents* current_tab = GetSelectedTabContents(); |
| 763 if (current_tab) { | 764 if (current_tab) { |
| 764 WebContents* web_contents = current_tab->AsWebContents(); | 765 WebContents* web_contents = current_tab->AsWebContents(); |
| 765 if (web_contents && web_contents->showing_interstitial_page()) { | 766 if (web_contents && web_contents->showing_interstitial_page()) { |
| 766 NavigationEntry* entry = current_tab->controller()->GetActiveEntry(); | 767 NavigationEntry* entry = current_tab->controller()->GetActiveEntry(); |
| 767 DCHECK(entry); // Should exist if interstitial is showing. | 768 DCHECK(entry); // Should exist if interstitial is showing. |
| 768 OpenURL(entry->url(), CURRENT_TAB, PageTransition::RELOAD); | 769 OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); |
| 769 return; | 770 return; |
| 770 } | 771 } |
| 771 } | 772 } |
| 772 | 773 |
| 773 if (current_tab) { | 774 if (current_tab) { |
| 774 // As this is caused by a user action, give the focus to the page. | 775 // As this is caused by a user action, give the focus to the page. |
| 775 current_tab->Focus(); | 776 current_tab->Focus(); |
| 776 current_tab->controller()->Reload(); | 777 current_tab->controller()->Reload(); |
| 777 } | 778 } |
| 778 } | 779 } |
| 779 | 780 |
| 780 void Browser::Home() { | 781 void Browser::Home() { |
| 781 GURL homepage_url = GetHomePage(); | 782 GURL homepage_url = GetHomePage(); |
| 782 GetSelectedTabContents()->controller()->LoadURL( | 783 GetSelectedTabContents()->controller()->LoadURL( |
| 783 homepage_url, PageTransition::AUTO_BOOKMARK); | 784 homepage_url, GURL(), PageTransition::AUTO_BOOKMARK); |
| 784 } | 785 } |
| 785 | 786 |
| 786 void Browser::StarCurrentTabContents() { | 787 void Browser::StarCurrentTabContents() { |
| 787 TabContents* tab = GetSelectedTabContents(); | 788 TabContents* tab = GetSelectedTabContents(); |
| 788 if (!tab || !tab->AsWebContents()) | 789 if (!tab || !tab->AsWebContents()) |
| 789 return; | 790 return; |
| 790 | 791 |
| 791 WebContents* rvh = tab->AsWebContents(); | 792 WebContents* rvh = tab->AsWebContents(); |
| 792 BookmarkModel* model = tab->profile()->GetBookmarkModel(); | 793 BookmarkModel* model = tab->profile()->GetBookmarkModel(); |
| 793 if (!model || !model->IsLoaded()) | 794 if (!model || !model->IsLoaded()) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 session_service->TabRestored(new_contents->controller()); | 1041 session_service->TabRestored(new_contents->controller()); |
| 1041 } | 1042 } |
| 1042 } | 1043 } |
| 1043 | 1044 |
| 1044 //////////////////////////////////////////////////////////////////////////////// | 1045 //////////////////////////////////////////////////////////////////////////////// |
| 1045 // Browser, SelectFileDialog::Listener implementation: | 1046 // Browser, SelectFileDialog::Listener implementation: |
| 1046 | 1047 |
| 1047 void Browser::FileSelected(const std::wstring& path, void* params) { | 1048 void Browser::FileSelected(const std::wstring& path, void* params) { |
| 1048 GURL file_url = net::FilePathToFileURL(path); | 1049 GURL file_url = net::FilePathToFileURL(path); |
| 1049 if (!file_url.is_empty()) | 1050 if (!file_url.is_empty()) |
| 1050 OpenURL(file_url, CURRENT_TAB, PageTransition::TYPED); | 1051 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 1051 } | 1052 } |
| 1052 | 1053 |
| OLD | NEW |