| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "chrome/browser/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/mac_util.h" | 9 #include "base/mac_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
| 13 #include "chrome/browser/browser.h" | 13 #include "chrome/browser/browser.h" |
| 14 #include "chrome/browser/browser_init.h" | 14 #include "chrome/browser/browser_init.h" |
| 15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_shutdown.h" | 17 #include "chrome/browser/browser_shutdown.h" |
| 18 #include "chrome/browser/browser_window.h" | 18 #include "chrome/browser/browser_window.h" |
| 19 #import "chrome/browser/chrome_application_mac.h" | 19 #import "chrome/browser/chrome_application_mac.h" |
| 20 #import "chrome/browser/cocoa/about_window_controller.h" | 20 #import "chrome/browser/cocoa/about_window_controller.h" |
| 21 #import "chrome/browser/cocoa/bookmark_menu_bridge.h" | 21 #import "chrome/browser/cocoa/bookmark_menu_bridge.h" |
| 22 #import "chrome/browser/cocoa/browser_window_cocoa.h" | 22 #import "chrome/browser/cocoa/browser_window_cocoa.h" |
| 23 #import "chrome/browser/cocoa/browser_window_controller.h" | 23 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 24 #import "chrome/browser/cocoa/bug_report_window_controller.h" |
| 24 #import "chrome/browser/cocoa/history_menu_bridge.h" | 25 #import "chrome/browser/cocoa/history_menu_bridge.h" |
| 25 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" | 26 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" |
| 26 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" | 27 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" |
| 27 #import "chrome/browser/cocoa/preferences_window_controller.h" | 28 #import "chrome/browser/cocoa/preferences_window_controller.h" |
| 28 #import "chrome/browser/cocoa/tab_strip_controller.h" | 29 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| 29 #import "chrome/browser/cocoa/tab_window_controller.h" | 30 #import "chrome/browser/cocoa/tab_window_controller.h" |
| 30 #include "chrome/browser/command_updater.h" | 31 #include "chrome/browser/command_updater.h" |
| 31 #include "chrome/browser/download/download_manager.h" | 32 #include "chrome/browser/download/download_manager.h" |
| 32 #include "chrome/browser/options_window.h" | 33 #include "chrome/browser/options_window.h" |
| 33 #include "chrome/browser/sessions/tab_restore_service.h" | 34 #include "chrome/browser/sessions/tab_restore_service.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 522 } |
| 522 case IDC_SHOW_HISTORY: | 523 case IDC_SHOW_HISTORY: |
| 523 Browser::OpenHistoryWindow(defaultProfile); | 524 Browser::OpenHistoryWindow(defaultProfile); |
| 524 break; | 525 break; |
| 525 case IDC_SHOW_DOWNLOADS: | 526 case IDC_SHOW_DOWNLOADS: |
| 526 Browser::OpenDownloadsWindow(defaultProfile); | 527 Browser::OpenDownloadsWindow(defaultProfile); |
| 527 break; | 528 break; |
| 528 case IDC_HELP_PAGE: | 529 case IDC_HELP_PAGE: |
| 529 Browser::OpenHelpWindow(defaultProfile); | 530 Browser::OpenHelpWindow(defaultProfile); |
| 530 break; | 531 break; |
| 532 case IDC_REPORT_BUG: { |
| 533 Browser* browser = BrowserList::GetLastActive(); |
| 534 TabContents* current_tab = (browser != NULL) ? |
| 535 browser->GetSelectedTabContents() : NULL; |
| 536 BugReportWindowController* controller = |
| 537 [[BugReportWindowController alloc] |
| 538 initWithTabContents:current_tab |
| 539 profile:[self defaultProfile]]; |
| 540 [controller runModalDialog]; |
| 541 break; |
| 542 } |
| 531 }; | 543 }; |
| 532 } | 544 } |
| 533 | 545 |
| 534 // NSApplication delegate method called when someone clicks on the | 546 // NSApplication delegate method called when someone clicks on the |
| 535 // dock icon and there are no open windows. To match standard mac | 547 // dock icon and there are no open windows. To match standard mac |
| 536 // behavior, we should open a new window. | 548 // behavior, we should open a new window. |
| 537 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication | 549 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication |
| 538 hasVisibleWindows:(BOOL)flag { | 550 hasVisibleWindows:(BOOL)flag { |
| 539 // Don't do anything if there are visible windows. This will cause | 551 // Don't do anything if there are visible windows. This will cause |
| 540 // AppKit to unminimize the most recently minimized window. | 552 // AppKit to unminimize the most recently minimized window. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 556 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); | 568 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); |
| 557 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true); | 569 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
| 558 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); | 570 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); |
| 559 menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true); | 571 menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true); |
| 560 menuState_->UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, true); | 572 menuState_->UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, true); |
| 561 menuState_->UpdateCommandEnabled(IDC_RESTORE_TAB, false); | 573 menuState_->UpdateCommandEnabled(IDC_RESTORE_TAB, false); |
| 562 menuState_->UpdateCommandEnabled(IDC_FOCUS_LOCATION, true); | 574 menuState_->UpdateCommandEnabled(IDC_FOCUS_LOCATION, true); |
| 563 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true); | 575 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true); |
| 564 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); | 576 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); |
| 565 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE, true); | 577 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE, true); |
| 578 menuState_->UpdateCommandEnabled(IDC_REPORT_BUG, true); |
| 566 // TODO(pinkerton): ...more to come... | 579 // TODO(pinkerton): ...more to come... |
| 567 } | 580 } |
| 568 | 581 |
| 569 - (Profile*)defaultProfile { | 582 - (Profile*)defaultProfile { |
| 570 // TODO(jrg): Find a better way to get the "default" profile. | 583 // TODO(jrg): Find a better way to get the "default" profile. |
| 571 if (g_browser_process->profile_manager()) | 584 if (g_browser_process->profile_manager()) |
| 572 return* g_browser_process->profile_manager()->begin(); | 585 return* g_browser_process->profile_manager()->begin(); |
| 573 | 586 |
| 574 return NULL; | 587 return NULL; |
| 575 } | 588 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 NOTIMPLEMENTED(); | 763 NOTIMPLEMENTED(); |
| 751 } | 764 } |
| 752 | 765 |
| 753 namespace app_controller_mac { | 766 namespace app_controller_mac { |
| 754 | 767 |
| 755 bool IsOpeningNewWindow() { | 768 bool IsOpeningNewWindow() { |
| 756 return g_is_opening_new_window; | 769 return g_is_opening_new_window; |
| 757 } | 770 } |
| 758 | 771 |
| 759 } // namespace app_controller_mac | 772 } // namespace app_controller_mac |
| OLD | NEW |