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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 329004: Mac: enable History, Downloads, and Open Location... with no windows open. (Closed)
Patch Set: Merged ToT. Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // through to the browser object to execute the command. This assumes that the 488 // through to the browser object to execute the command. This assumes that the
489 // command is supported and doesn't check, otherwise it would have been disabled 489 // command is supported and doesn't check, otherwise it would have been disabled
490 // in the UI in validateUserInterfaceItem:. 490 // in the UI in validateUserInterfaceItem:.
491 - (void)commandDispatch:(id)sender { 491 - (void)commandDispatch:(id)sender {
492 Profile* defaultProfile = [self defaultProfile]; 492 Profile* defaultProfile = [self defaultProfile];
493 493
494 NSInteger tag = [sender tag]; 494 NSInteger tag = [sender tag];
495 switch (tag) { 495 switch (tag) {
496 case IDC_NEW_TAB: 496 case IDC_NEW_TAB:
497 case IDC_NEW_WINDOW: 497 case IDC_NEW_WINDOW:
498 case IDC_FOCUS_LOCATION:
498 g_is_opening_new_window = true; 499 g_is_opening_new_window = true;
499 Browser::OpenEmptyWindow(defaultProfile); 500 Browser::OpenEmptyWindow(defaultProfile);
500 g_is_opening_new_window = false; 501 g_is_opening_new_window = false;
501 break; 502 break;
502 case IDC_NEW_INCOGNITO_WINDOW: 503 case IDC_NEW_INCOGNITO_WINDOW:
503 Browser::OpenEmptyWindow(defaultProfile->GetOffTheRecordProfile()); 504 Browser::OpenEmptyWindow(defaultProfile->GetOffTheRecordProfile());
504 break; 505 break;
505 case IDC_RESTORE_TAB: 506 case IDC_RESTORE_TAB:
506 Browser::OpenWindowWithRestoredTabs(defaultProfile); 507 Browser::OpenWindowWithRestoredTabs(defaultProfile);
507 break; 508 break;
508 case IDC_OPEN_FILE: 509 case IDC_OPEN_FILE:
509 Browser::OpenEmptyWindow(defaultProfile); 510 Browser::OpenEmptyWindow(defaultProfile);
510 BrowserList::GetLastActive()-> 511 BrowserList::GetLastActive()->
511 ExecuteCommandWithDisposition(IDC_OPEN_FILE, CURRENT_TAB); 512 ExecuteCommandWithDisposition(IDC_OPEN_FILE, CURRENT_TAB);
512 break; 513 break;
513 case IDC_CLEAR_BROWSING_DATA: { 514 case IDC_CLEAR_BROWSING_DATA: {
514 // There may not be a browser open, so use the default profile. 515 // There may not be a browser open, so use the default profile.
515 scoped_nsobject<ClearBrowsingDataController> controller( 516 scoped_nsobject<ClearBrowsingDataController> controller(
516 [[ClearBrowsingDataController alloc] 517 [[ClearBrowsingDataController alloc]
517 initWithProfile:defaultProfile]); 518 initWithProfile:defaultProfile]);
518 [controller runModalDialog]; 519 [controller runModalDialog];
519 break; 520 break;
520 } 521 }
522 case IDC_SHOW_HISTORY:
523 Browser::OpenHistoryWindow(defaultProfile);
524 break;
525 case IDC_SHOW_DOWNLOADS:
526 Browser::OpenDownloadsWindow(defaultProfile);
527 break;
521 case IDC_HELP_PAGE: 528 case IDC_HELP_PAGE:
522 Browser::OpenHelpWindow(defaultProfile); 529 Browser::OpenHelpWindow(defaultProfile);
523 break; 530 break;
524 }; 531 };
525 } 532 }
526 533
527 // NSApplication delegate method called when someone clicks on the 534 // NSApplication delegate method called when someone clicks on the
528 // dock icon and there are no open windows. To match standard mac 535 // dock icon and there are no open windows. To match standard mac
529 // behavior, we should open a new window. 536 // behavior, we should open a new window.
530 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication 537 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
(...skipping 14 matching lines...) Expand all
545 } 552 }
546 553
547 - (void)initMenuState { 554 - (void)initMenuState {
548 menuState_.reset(new CommandUpdater(NULL)); 555 menuState_.reset(new CommandUpdater(NULL));
549 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); 556 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true);
550 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true); 557 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true);
551 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); 558 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true);
552 menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true); 559 menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true);
553 menuState_->UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, true); 560 menuState_->UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, true);
554 menuState_->UpdateCommandEnabled(IDC_RESTORE_TAB, false); 561 menuState_->UpdateCommandEnabled(IDC_RESTORE_TAB, false);
562 menuState_->UpdateCommandEnabled(IDC_FOCUS_LOCATION, true);
563 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
564 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
555 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE, true); 565 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE, true);
556 // TODO(pinkerton): ...more to come... 566 // TODO(pinkerton): ...more to come...
557 } 567 }
558 568
559 - (Profile*)defaultProfile { 569 - (Profile*)defaultProfile {
560 // TODO(jrg): Find a better way to get the "default" profile. 570 // TODO(jrg): Find a better way to get the "default" profile.
561 if (g_browser_process->profile_manager()) 571 if (g_browser_process->profile_manager())
562 return* g_browser_process->profile_manager()->begin(); 572 return* g_browser_process->profile_manager()->begin();
563 573
564 return NULL; 574 return NULL;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 NOTIMPLEMENTED(); 750 NOTIMPLEMENTED();
741 } 751 }
742 752
743 namespace app_controller_mac { 753 namespace app_controller_mac {
744 754
745 bool IsOpeningNewWindow() { 755 bool IsOpeningNewWindow() {
746 return g_is_opening_new_window; 756 return g_is_opening_new_window;
747 } 757 }
748 758
749 } // namespace app_controller_mac 759 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698