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

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

Issue 14923004: [Mac] AppController needs to update its "last profile" pointer when the active profile is deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months 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
OLDNEW
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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // Build up the encoding menu, the order of the items differs based on the 578 // Build up the encoding menu, the order of the items differs based on the
579 // current locale (see http://crbug.com/7647 for details). 579 // current locale (see http://crbug.com/7647 for details).
580 // We need a valid g_browser_process to get the profile which is why we can't 580 // We need a valid g_browser_process to get the profile which is why we can't
581 // call this from awakeFromNib. 581 // call this from awakeFromNib.
582 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; 582 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu];
583 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; 583 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU];
584 NSMenu* encodingMenu = [encodingMenuItem submenu]; 584 NSMenu* encodingMenu = [encodingMenuItem submenu];
585 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], 585 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
586 encodingMenu); 586 encodingMenu);
587 587
588 // Instantiate the ProfileInfoCache observer so that we can get
589 // notified when a profile is deleted.
590 profileInfoCacheObserver_ = new AppControllerProfileObserver(
591 g_browser_process->profile_manager(), self);
592
588 // Since Chrome is localized to more languages than the OS, tell Cocoa which 593 // Since Chrome is localized to more languages than the OS, tell Cocoa which
589 // menu is the Help so it can add the search item to it. 594 // menu is the Help so it can add the search item to it.
590 [NSApp setHelpMenu:helpMenu_]; 595 [NSApp setHelpMenu:helpMenu_];
591 596
592 // Record the path to the (browser) app bundle; this is used by the app mode 597 // Record the path to the (browser) app bundle; this is used by the app mode
593 // shim. 598 // shim.
594 RecordLastRunAppBundlePath(); 599 RecordLastRunAppBundlePath();
595 600
596 // Makes "Services" menu items available. 601 // Makes "Services" menu items available.
597 [self registerServicesMenuTypesTo:[notify object]]; 602 [self registerServicesMenuTypesTo:[notify object]];
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 712
708 // Called to determine if we should enable the "restore tab" menu item. 713 // Called to determine if we should enable the "restore tab" menu item.
709 // Checks with the TabRestoreService to see if there's anything there to 714 // Checks with the TabRestoreService to see if there's anything there to
710 // restore and returns YES if so. 715 // restore and returns YES if so.
711 - (BOOL)canRestoreTab { 716 - (BOOL)canRestoreTab {
712 TabRestoreService* service = 717 TabRestoreService* service =
713 TabRestoreServiceFactory::GetForProfile([self lastProfile]); 718 TabRestoreServiceFactory::GetForProfile([self lastProfile]);
714 return service && !service->entries().empty(); 719 return service && !service->entries().empty();
715 } 720 }
716 721
722 - (void)profileWasRemoved:(const string16&)profileName {
723 Profile* lastProfile = [self lastProfile];
724 string16 lastProfileName = UTF8ToUTF16(lastProfile->GetPrefs()->GetString(
725 prefs::kProfileName));
726
727 // If the last profile has been deleted, we must NULL out our pointer
728 // otherwise we will try to start up a browser window with a pointer
729 // to the old profile.
730 if (profileName == lastProfileName) {
731 lastProfile_ = NULL;
732 }
733 }
734
717 // Returns true if there is a modal window (either window- or application- 735 // Returns true if there is a modal window (either window- or application-
718 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth 736 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
719 // sheets) will not count as blocking the browser. But things like open/save 737 // sheets) will not count as blocking the browser. But things like open/save
720 // dialogs that are window modal will block the browser. 738 // dialogs that are window modal will block the browser.
721 - (BOOL)keyWindowIsModal { 739 - (BOOL)keyWindowIsModal {
722 if ([NSApp modalWindow]) 740 if ([NSApp modalWindow])
723 return YES; 741 return YES;
724 742
725 Browser* browser = chrome::GetLastActiveBrowser(); 743 Browser* browser = chrome::GetLastActiveBrowser();
726 return browser && 744 return browser &&
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 1334
1317 //--------------------------------------------------------------------------- 1335 //---------------------------------------------------------------------------
1318 1336
1319 namespace app_controller_mac { 1337 namespace app_controller_mac {
1320 1338
1321 bool IsOpeningNewWindow() { 1339 bool IsOpeningNewWindow() {
1322 return g_is_opening_new_window; 1340 return g_is_opening_new_window;
1323 } 1341 }
1324 1342
1325 } // namespace app_controller_mac 1343 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698