diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 18:58:35 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 18:58:35 +0000 |
commit | a585a8db990e5062d2fbcec7ae3d87727bcb2875 (patch) | |
tree | 5e32e4df27f6542c5110f7d2e02cf46fb5478dd8 /chrome | |
parent | 402bcb1174120908f3c6e89fa442eb8d3d34ddda (diff) | |
download | chromium_src-a585a8db990e5062d2fbcec7ae3d87727bcb2875.zip chromium_src-a585a8db990e5062d2fbcec7ae3d87727bcb2875.tar.gz chromium_src-a585a8db990e5062d2fbcec7ae3d87727bcb2875.tar.bz2 |
Rename -[AppController defaultProfile] to |-lastProfile|.
BUG=86179
TEST=none
Review URL: http://codereview.chromium.org/7206025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
8 files changed, 68 insertions, 69 deletions
diff --git a/chrome/browser/app_controller_mac.h b/chrome/browser/app_controller_mac.h index 5e21904..fda926e 100644 --- a/chrome/browser/app_controller_mac.h +++ b/chrome/browser/app_controller_mac.h @@ -61,9 +61,9 @@ class Profile; } @property(readonly, nonatomic) BOOL startupComplete; +@property(readonly, nonatomic) Profile* lastProfile; - (void)didEndMainMessageLoop; -- (Profile*)defaultProfile; // Try to close all browser windows, and if that succeeds then quit. - (BOOL)tryToTerminateApplication:(NSApplication*)app; diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 3e13ab36..780461c 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -277,7 +277,7 @@ void RecordLastRunAppBundlePath() { - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { // Check if the preference is turned on. - const PrefService* prefs = [self defaultProfile]->GetPrefs(); + const PrefService* prefs = [self lastProfile]->GetPrefs(); if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) { confirm_quit::RecordHistogram(confirm_quit::kNoConfirm); return NSTerminateNow; @@ -317,14 +317,14 @@ void RecordLastRunAppBundlePath() { } - (void)didEndMainMessageLoop { - DCHECK(!BrowserList::HasBrowserWithProfile([self defaultProfile])); - if (!BrowserList::HasBrowserWithProfile([self defaultProfile])) { + DCHECK(!BrowserList::HasBrowserWithProfile([self lastProfile])); + if (!BrowserList::HasBrowserWithProfile([self lastProfile])) { // As we're shutting down, we need to nuke the TabRestoreService, which // will start the shutdown of the NavigationControllers and allow for // proper shutdown. If we don't do this, Chrome won't shut down cleanly, // and may end up crashing when some thread tries to use the IO thread (or // another thread) that is no longer valid. - TabRestoreServiceFactory::ResetForProfile([self defaultProfile]); + TabRestoreServiceFactory::ResetForProfile([self lastProfile]); } } @@ -525,7 +525,7 @@ void RecordLastRunAppBundlePath() { NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; NSMenu* encodingMenu = [encodingMenuItem submenu]; - EncodingMenuControllerDelegate::BuildEncodingMenu([self defaultProfile], + EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], encodingMenu); // Since Chrome is localized to more languages than the OS, tell Cocoa which @@ -652,7 +652,7 @@ void RecordLastRunAppBundlePath() { // restore and returns YES if so. - (BOOL)canRestoreTab { TabRestoreService* service = - TabRestoreServiceFactory::GetForProfile([self defaultProfile]); + TabRestoreServiceFactory::GetForProfile([self lastProfile]); return service && !service->entries().empty(); } @@ -704,21 +704,21 @@ void RecordLastRunAppBundlePath() { enable = [self keyWindowIsNotModal] || ([NSApp modalWindow] == nil); break; case IDC_SYNC_BOOKMARKS: { - Profile* defaultProfile = [self defaultProfile]; + Profile* lastProfile = [self lastProfile]; // The profile may be NULL during shutdown -- see // http://code.google.com/p/chromium/issues/detail?id=43048 . // // TODO(akalin,viettrungluu): Figure out whether this method - // can be prevented from being called if defaultProfile is + // can be prevented from being called if lastProfile is // NULL. - if (!defaultProfile) { + if (!lastProfile) { LOG(WARNING) - << "NULL defaultProfile detected -- not doing anything"; + << "NULL lastProfile detected -- not doing anything"; break; } - enable = defaultProfile->IsSyncAccessible() && + enable = lastProfile->IsSyncAccessible() && [self keyWindowIsNotModal]; - sync_ui_util::UpdateSyncItem(item, enable, defaultProfile); + sync_ui_util::UpdateSyncItem(item, enable, lastProfile); break; } default: @@ -747,7 +747,7 @@ void RecordLastRunAppBundlePath() { // check, otherwise it should have been disabled in the UI in // |-validateUserInterfaceItem:|. - (void)commandDispatch:(id)sender { - Profile* defaultProfile = [self defaultProfile]; + Profile* lastProfile = [self lastProfile]; // Handle the case where we're dispatching a command from a sender that's in a // browser window. This means that the command came from a background window @@ -765,80 +765,79 @@ void RecordLastRunAppBundlePath() { case IDC_NEW_TAB: // Create a new tab in an existing browser window (which we activate) if // possible. - if (Browser* browser = ActivateBrowser(defaultProfile)) { + if (Browser* browser = ActivateBrowser(lastProfile)) { browser->ExecuteCommand(IDC_NEW_TAB); break; } // Else fall through to create new window. case IDC_NEW_WINDOW: - CreateBrowser(defaultProfile); + CreateBrowser(lastProfile); break; case IDC_FOCUS_LOCATION: - ActivateOrCreateBrowser(defaultProfile)-> - ExecuteCommand(IDC_FOCUS_LOCATION); + ActivateOrCreateBrowser(lastProfile)->ExecuteCommand(IDC_FOCUS_LOCATION); break; case IDC_FOCUS_SEARCH: - ActivateOrCreateBrowser(defaultProfile)->ExecuteCommand(IDC_FOCUS_SEARCH); + ActivateOrCreateBrowser(lastProfile)->ExecuteCommand(IDC_FOCUS_SEARCH); break; case IDC_NEW_INCOGNITO_WINDOW: - Browser::OpenEmptyWindow(defaultProfile->GetOffTheRecordProfile()); + Browser::OpenEmptyWindow(lastProfile->GetOffTheRecordProfile()); break; case IDC_RESTORE_TAB: - Browser::OpenWindowWithRestoredTabs(defaultProfile); + Browser::OpenWindowWithRestoredTabs(lastProfile); break; case IDC_OPEN_FILE: - CreateBrowser(defaultProfile)->ExecuteCommand(IDC_OPEN_FILE); + CreateBrowser(lastProfile)->ExecuteCommand(IDC_OPEN_FILE); break; case IDC_CLEAR_BROWSING_DATA: { // There may not be a browser open, so use the default profile. - if (Browser* browser = ActivateBrowser(defaultProfile)) { + if (Browser* browser = ActivateBrowser(lastProfile)) { browser->OpenClearBrowsingDataDialog(); } else { - Browser::OpenClearBrowingDataDialogWindow(defaultProfile); + Browser::OpenClearBrowingDataDialogWindow(lastProfile); } break; } case IDC_IMPORT_SETTINGS: { - if (Browser* browser = ActivateBrowser(defaultProfile)) { + if (Browser* browser = ActivateBrowser(lastProfile)) { browser->OpenImportSettingsDialog(); } else { - Browser::OpenImportSettingsDialogWindow(defaultProfile); + Browser::OpenImportSettingsDialogWindow(lastProfile); } break; } case IDC_SHOW_BOOKMARK_MANAGER: UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); - if (Browser* browser = ActivateBrowser(defaultProfile)) { + if (Browser* browser = ActivateBrowser(lastProfile)) { // Open a bookmark manager tab. browser->OpenBookmarkManager(); } else { // No browser window, so create one for the bookmark manager tab. - Browser::OpenBookmarkManagerWindow(defaultProfile); + Browser::OpenBookmarkManagerWindow(lastProfile); } break; case IDC_SHOW_HISTORY: - if (Browser* browser = ActivateBrowser(defaultProfile)) + if (Browser* browser = ActivateBrowser(lastProfile)) browser->ShowHistoryTab(); else - Browser::OpenHistoryWindow(defaultProfile); + Browser::OpenHistoryWindow(lastProfile); break; case IDC_SHOW_DOWNLOADS: - if (Browser* browser = ActivateBrowser(defaultProfile)) + if (Browser* browser = ActivateBrowser(lastProfile)) browser->ShowDownloadsTab(); else - Browser::OpenDownloadsWindow(defaultProfile); + Browser::OpenDownloadsWindow(lastProfile); break; case IDC_MANAGE_EXTENSIONS: - if (Browser* browser = ActivateBrowser(defaultProfile)) + if (Browser* browser = ActivateBrowser(lastProfile)) browser->ShowExtensionsTab(); else - Browser::OpenExtensionsWindow(defaultProfile); + Browser::OpenExtensionsWindow(lastProfile); break; case IDC_HELP_PAGE: - if (Browser* browser = ActivateBrowser(defaultProfile)) + if (Browser* browser = ActivateBrowser(lastProfile)) browser->OpenHelpTab(); else - Browser::OpenHelpWindow(defaultProfile); + Browser::OpenHelpWindow(lastProfile); break; case IDC_FEEDBACK: { Browser* browser = BrowserList::GetLastActive(); @@ -847,7 +846,7 @@ void RecordLastRunAppBundlePath() { BugReportWindowController* controller = [[BugReportWindowController alloc] initWithTabContents:currentTab - profile:[self defaultProfile]]; + profile:[self lastProfile]]; [controller runModalDialog]; break; } @@ -856,15 +855,15 @@ void RecordLastRunAppBundlePath() { // http://code.google.com/p/chromium/issues/detail?id=43048 . // // TODO(akalin,viettrungluu): Figure out whether this method can - // be prevented from being called if defaultProfile is NULL. - if (!defaultProfile) { - LOG(WARNING) << "NULL defaultProfile detected -- not doing anything"; + // be prevented from being called if lastProfile is NULL. + if (!lastProfile) { + LOG(WARNING) << "NULL lastProfile detected -- not doing anything"; break; } // TODO(akalin): Add a constant to denote starting sync from the // main menu and use that instead of START_FROM_WRENCH. sync_ui_util::OpenSyncMyBookmarksDialog( - defaultProfile, ActivateBrowser(defaultProfile), + lastProfile, ActivateBrowser(lastProfile), ProfileSyncService::START_FROM_WRENCH); break; case IDC_TASK_MANAGER: @@ -886,7 +885,7 @@ void RecordLastRunAppBundlePath() { // Run a (background) application in a new tab. - (void)executeApplication:(id)sender { NSInteger tag = [sender tag]; - Profile* profile = [self defaultProfile]; + Profile* profile = [self lastProfile]; DCHECK(profile); BackgroundApplicationListModel applications(profile); DCHECK(tag >= 0 && @@ -941,7 +940,7 @@ void RecordLastRunAppBundlePath() { doneOnce = YES; if (base::mac::WasLaunchedAsHiddenLoginItem()) { SessionService* sessionService = - SessionServiceFactory::GetForProfile([self defaultProfile]); + SessionServiceFactory::GetForProfile([self lastProfile]); if (sessionService && sessionService->RestoreIfNecessary(std::vector<GURL>())) return NO; @@ -951,7 +950,7 @@ void RecordLastRunAppBundlePath() { // Otherwise open a new window. { AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); - Browser::OpenEmptyWindow([self defaultProfile]); + Browser::OpenEmptyWindow([self lastProfile]); } // We've handled the reopen event, so return NO to tell AppKit not @@ -990,7 +989,7 @@ void RecordLastRunAppBundlePath() { base::SysNSStringToUTF16(acceleratorString)); [item setTitle:title]; - const PrefService* prefService = [self defaultProfile]->GetPrefs(); + const PrefService* prefService = [self lastProfile]->GetPrefs(); bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); [item setState:enabled ? NSOnState : NSOffState]; } @@ -1002,7 +1001,7 @@ void RecordLastRunAppBundlePath() { [app registerServicesMenuSendTypes:types returnTypes:types]; } -- (Profile*)defaultProfile { +- (Profile*)lastProfile { // Return the profile of the last-used BrowserWindowController, if available. if (lastProfile_) return lastProfile_; @@ -1029,7 +1028,7 @@ void RecordLastRunAppBundlePath() { Browser* browser = BrowserList::GetLastActive(); // if no browser window exists then create one with no tabs to be filled in if (!browser) { - browser = Browser::Create([self defaultProfile]); + browser = Browser::Create([self lastProfile]); browser->window()->Show(); } @@ -1068,12 +1067,12 @@ void RecordLastRunAppBundlePath() { // Show the preferences window, or bring it to the front if it's already // visible. - (IBAction)showPreferences:(id)sender { - if (Browser* browser = ActivateBrowser([self defaultProfile])) { + if (Browser* browser = ActivateBrowser([self lastProfile])) { // Show options tab in the active browser window. browser->OpenOptionsDialog(); } else { // No browser window, so create one for the options tab. - Browser::OpenOptionsWindow([self defaultProfile]); + Browser::OpenOptionsWindow([self lastProfile]); } } @@ -1094,7 +1093,7 @@ void RecordLastRunAppBundlePath() { - (IBAction)orderFrontStandardAboutPanel:(id)sender { if (!aboutController_) { aboutController_ = - [[AboutWindowController alloc] initWithProfile:[self defaultProfile]]; + [[AboutWindowController alloc] initWithProfile:[self lastProfile]]; // Watch for a notification of when it goes away so that we can destroy // the controller. @@ -1109,7 +1108,7 @@ void RecordLastRunAppBundlePath() { } - (IBAction)toggleConfirmToQuit:(id)sender { - PrefService* prefService = [self defaultProfile]->GetPrefs(); + PrefService* prefService = [self lastProfile]->GetPrefs(); bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); } @@ -1122,7 +1121,7 @@ void RecordLastRunAppBundlePath() { - (NSMenu*)applicationDockMenu:(NSApplication*)sender { NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; - Profile* profile = [self defaultProfile]; + Profile* profile = [self lastProfile]; NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC); scoped_nsobject<NSMenuItem> item( diff --git a/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.h b/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.h index e55f933..7ca98cf 100644 --- a/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.h +++ b/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.h @@ -25,7 +25,7 @@ class BookmarkModel; } @property(nonatomic) BrowserTestHelper* helper; // Return the |TestingProfile*| which is used for testing. -- (Profile*)defaultProfile; +- (Profile*)lastProfile; @end diff --git a/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.mm b/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.mm index 353e592..666b195 100644 --- a/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.mm +++ b/chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.mm @@ -10,7 +10,7 @@ @synthesize helper = helper_; -- (Profile*)defaultProfile { +- (Profile*)lastProfile { if (!helper_) return NULL; return helper_->profile(); diff --git a/chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.mm b/chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.mm index 24b5857..e238c4e 100644 --- a/chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.mm @@ -112,13 +112,13 @@ - (BookmarkModel*)bookmarkModel { AppController* appDelegate = [NSApp delegate]; - Profile* defaultProfile = [appDelegate defaultProfile]; - if (!defaultProfile) { + Profile* lastProfile = [appDelegate lastProfile]; + if (!lastProfile) { AppleScript::SetError(AppleScript::errGetProfile); return NULL; } - BookmarkModel* model = defaultProfile->GetBookmarkModel(); + BookmarkModel* model = lastProfile->GetBookmarkModel(); if (!model->IsLoaded()) { AppleScript::SetError(AppleScript::errBookmarkModelLoad); return NULL; diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm index 9cd3517..1f280ac 100644 --- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm @@ -69,13 +69,13 @@ - (BookmarkFolderAppleScript*)otherBookmarks { AppController* appDelegate = [NSApp delegate]; - Profile* defaultProfile = [appDelegate defaultProfile]; - if (!defaultProfile) { + Profile* lastProfile = [appDelegate lastProfile]; + if (!lastProfile) { AppleScript::SetError(AppleScript::errGetProfile); return nil; } - BookmarkModel* model = defaultProfile->GetBookmarkModel(); + BookmarkModel* model = lastProfile->GetBookmarkModel(); if (!model->IsLoaded()) { AppleScript::SetError(AppleScript::errBookmarkModelLoad); return nil; @@ -92,13 +92,13 @@ - (BookmarkFolderAppleScript*)bookmarksBar { AppController* appDelegate = [NSApp delegate]; - Profile* defaultProfile = [appDelegate defaultProfile]; - if (!defaultProfile) { + Profile* lastProfile = [appDelegate lastProfile]; + if (!lastProfile) { AppleScript::SetError(AppleScript::errGetProfile); return nil; } - BookmarkModel* model = defaultProfile->GetBookmarkModel(); + BookmarkModel* model = lastProfile->GetBookmarkModel(); if (!model->IsLoaded()) { AppleScript::SetError(AppleScript::errBookmarkModelLoad); return NULL; diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript.mm b/chrome/browser/ui/cocoa/applescript/window_applescript.mm index 491cc8d..1333d57 100644 --- a/chrome/browser/ui/cocoa/applescript/window_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/window_applescript.mm @@ -37,19 +37,19 @@ objectForKey:@"KeyDictionary"] objectForKey:@"mode"]; AppController* appDelegate = [NSApp delegate]; - Profile* defaultProfile = [appDelegate defaultProfile]; + Profile* lastProfile = [appDelegate lastProfile]; - if (!defaultProfile) { + if (!lastProfile) { AppleScript::SetError(AppleScript::errGetProfile); return nil; } Profile* profile; if ([mode isEqualToString:AppleScript::kIncognitoWindowMode]) { - profile = defaultProfile->GetOffTheRecordProfile(); + profile = lastProfile->GetOffTheRecordProfile(); } else if ([mode isEqualToString:AppleScript::kNormalWindowMode] || !mode) { - profile = defaultProfile; + profile = lastProfile; } else { // Mode cannot be anything else AppleScript::SetError(AppleScript::errInvalidMode); diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript_test.mm b/chrome/browser/ui/cocoa/applescript/window_applescript_test.mm index b1bee22..f54bcb8 100644 --- a/chrome/browser/ui/cocoa/applescript/window_applescript_test.mm +++ b/chrome/browser/ui/cocoa/applescript/window_applescript_test.mm @@ -39,9 +39,9 @@ IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithNoProfile) { // Create a window with a particular profile. IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithProfile) { - Profile* defaultProfile = [[NSApp delegate] defaultProfile]; + Profile* lastProfile = [[NSApp delegate] lastProfile]; scoped_nsobject<WindowAppleScript> aWindow( - [[WindowAppleScript alloc] initWithProfile:defaultProfile]); + [[WindowAppleScript alloc] initWithProfile:lastProfile]); EXPECT_TRUE(aWindow.get()); EXPECT_TRUE([aWindow.get() uniqueID]); } |