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

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

Issue 10383114: Rename BrowserInit to StartupBrowserCreator, and move into startup subdir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.cc » ('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) 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/file_path.h" 10 #include "base/file_path.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/browser/service/service_process_control.h" 31 #include "chrome/browser/service/service_process_control.h"
32 #include "chrome/browser/sessions/session_service.h" 32 #include "chrome/browser/sessions/session_service.h"
33 #include "chrome/browser/sessions/session_service_factory.h" 33 #include "chrome/browser/sessions/session_service_factory.h"
34 #include "chrome/browser/sessions/tab_restore_service.h" 34 #include "chrome/browser/sessions/tab_restore_service.h"
35 #include "chrome/browser/sessions/tab_restore_service_factory.h" 35 #include "chrome/browser/sessions/tab_restore_service_factory.h"
36 #include "chrome/browser/sync/profile_sync_service.h" 36 #include "chrome/browser/sync/profile_sync_service.h"
37 #include "chrome/browser/sync/sync_ui_util.h" 37 #include "chrome/browser/sync/sync_ui_util.h"
38 #include "chrome/browser/sync/sync_ui_util_mac.h" 38 #include "chrome/browser/sync/sync_ui_util_mac.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_init.h"
41 #include "chrome/browser/ui/browser_list.h" 40 #include "chrome/browser/ui/browser_list.h"
42 #include "chrome/browser/ui/browser_window.h" 41 #include "chrome/browser/ui/browser_window.h"
42 #include "chrome/browser/ui/startup/startup_browser_creator.h"
43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
44 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 44 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
45 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 45 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
46 #import "chrome/browser/ui/cocoa/confirm_quit.h" 46 #import "chrome/browser/ui/cocoa/confirm_quit.h"
47 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" 47 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
48 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" 48 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h"
49 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" 49 #import "chrome/browser/ui/cocoa/history_menu_bridge.h"
50 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" 50 #import "chrome/browser/ui/cocoa/profile_menu_controller.h"
51 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 51 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
52 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" 52 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 namespace { 88 namespace {
89 89
90 // Declare notification names from the 10.7 SDK. 90 // Declare notification names from the 10.7 SDK.
91 #if !defined(MAC_OS_X_VERSION_10_7) || \ 91 #if !defined(MAC_OS_X_VERSION_10_7) || \
92 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 92 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
93 NSString* NSPopoverDidShowNotification = @"NSPopoverDidShowNotification"; 93 NSString* NSPopoverDidShowNotification = @"NSPopoverDidShowNotification";
94 NSString* NSPopoverDidCloseNotification = @"NSPopoverDidCloseNotification"; 94 NSString* NSPopoverDidCloseNotification = @"NSPopoverDidCloseNotification";
95 #endif 95 #endif
96 96
97 // True while AppController is calling Browser::NewEmptyWindow(). We need a 97 // True while AppController is calling Browser::NewEmptyWindow(). We need a
98 // global flag here, analogue to BrowserInit::InProcessStartup() because 98 // global flag here, analogue to StartupBrowserCreator::InProcessStartup()
99 // otherwise the SessionService will try to restore sessions when we make a new 99 // because otherwise the SessionService will try to restore sessions when we
100 // window while there are no other active windows. 100 // make a new window while there are no other active windows.
101 bool g_is_opening_new_window = false; 101 bool g_is_opening_new_window = false;
102 102
103 // Activates a browser window having the given profile (the last one active) if 103 // Activates a browser window having the given profile (the last one active) if
104 // possible and returns a pointer to the activate |Browser| or NULL if this was 104 // possible and returns a pointer to the activate |Browser| or NULL if this was
105 // not possible. If the last active browser is minimized (in particular, if 105 // not possible. If the last active browser is minimized (in particular, if
106 // there are only minimized windows), it will unminimize it. 106 // there are only minimized windows), it will unminimize it.
107 Browser* ActivateBrowser(Profile* profile) { 107 Browser* ActivateBrowser(Profile* profile) {
108 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); 108 Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
109 if (browser) 109 if (browser)
110 browser->window()->Activate(); 110 browser->window()->Activate();
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 // Platform apps don't use browser windows so don't do anything if there are 989 // Platform apps don't use browser windows so don't do anything if there are
990 // visible windows. 990 // visible windows.
991 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 991 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
992 if (flag && command_line.HasSwitch(switches::kAppId)) 992 if (flag && command_line.HasSwitch(switches::kAppId))
993 return YES; 993 return YES;
994 994
995 // Otherwise open a new window. 995 // Otherwise open a new window.
996 { 996 {
997 AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); 997 AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true);
998 int return_code; 998 int return_code;
999 BrowserInit browser_init; 999 StartupBrowserCreator browser_creator;
1000 browser_init.LaunchBrowser(command_line, [self lastProfile], FilePath(), 1000 browser_creator.LaunchBrowser(
1001 BrowserInit::IS_NOT_PROCESS_STARTUP, 1001 command_line, [self lastProfile], FilePath(),
1002 BrowserInit::IS_NOT_FIRST_RUN, &return_code); 1002 StartupBrowserCreator::IS_NOT_PROCESS_STARTUP,
1003 StartupBrowserCreator::IS_NOT_FIRST_RUN, &return_code);
1003 } 1004 }
1004 1005
1005 // We've handled the reopen event, so return NO to tell AppKit not 1006 // We've handled the reopen event, so return NO to tell AppKit not
1006 // to do anything. 1007 // to do anything.
1007 return NO; 1008 return NO;
1008 } 1009 }
1009 1010
1010 - (void)initMenuState { 1011 - (void)initMenuState {
1011 menuState_.reset(new CommandUpdater(NULL)); 1012 menuState_.reset(new CommandUpdater(NULL));
1012 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); 1013 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 return lastProfile_; 1079 return lastProfile_;
1079 1080
1080 // On first launch, no profile will be stored, so use last from Local State. 1081 // On first launch, no profile will be stored, so use last from Local State.
1081 if (g_browser_process->profile_manager()) 1082 if (g_browser_process->profile_manager())
1082 return g_browser_process->profile_manager()->GetLastUsedProfile(); 1083 return g_browser_process->profile_manager()->GetLastUsedProfile();
1083 1084
1084 return NULL; 1085 return NULL;
1085 } 1086 }
1086 1087
1087 // Various methods to open URLs that we get in a native fashion. We use 1088 // Various methods to open URLs that we get in a native fashion. We use
1088 // BrowserInit here because on the other platforms, URLs to open come through 1089 // StartupBrowserCreator here because on the other platforms, URLs to open come
1089 // the ProcessSingleton, and it calls BrowserInit. It's best to bottleneck the 1090 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best
1090 // openings through that for uniform handling. 1091 // to bottleneck the openings through that for uniform handling.
1091 1092
1092 - (void)openUrls:(const std::vector<GURL>&)urls { 1093 - (void)openUrls:(const std::vector<GURL>&)urls {
1093 // If the browser hasn't started yet, just queue up the URLs. 1094 // If the browser hasn't started yet, just queue up the URLs.
1094 if (!startupComplete_) { 1095 if (!startupComplete_) {
1095 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); 1096 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end());
1096 return; 1097 return;
1097 } 1098 }
1098 1099
1099 Browser* browser = BrowserList::GetLastActive(); 1100 Browser* browser = BrowserList::GetLastActive();
1100 // if no browser window exists then create one with no tabs to be filled in 1101 // if no browser window exists then create one with no tabs to be filled in
1101 if (!browser) { 1102 if (!browser) {
1102 browser = Browser::Create([self lastProfile]); 1103 browser = Browser::Create([self lastProfile]);
1103 browser->window()->Show(); 1104 browser->window()->Show();
1104 } 1105 }
1105 1106
1106 CommandLine dummy(CommandLine::NO_PROGRAM); 1107 CommandLine dummy(CommandLine::NO_PROGRAM);
1107 BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1108 StartupBrowserCreator::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1108 BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; 1109 StartupBrowserCreator::IS_FIRST_RUN :
1109 BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); 1110 StartupBrowserCreator::IS_NOT_FIRST_RUN;
1111 StartupBrowserCreator::LaunchWithProfile launch(FilePath(), dummy, first_run);
1110 launch.OpenURLsInBrowser(browser, false, urls); 1112 launch.OpenURLsInBrowser(browser, false, urls);
1111 } 1113 }
1112 1114
1113 - (void)getUrl:(NSAppleEventDescriptor*)event 1115 - (void)getUrl:(NSAppleEventDescriptor*)event
1114 withReply:(NSAppleEventDescriptor*)reply { 1116 withReply:(NSAppleEventDescriptor*)reply {
1115 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] 1117 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
1116 stringValue]; 1118 stringValue];
1117 1119
1118 GURL gurl(base::SysNSStringToUTF8(urlStr)); 1120 GURL gurl(base::SysNSStringToUTF8(urlStr));
1119 std::vector<GURL> gurlVector; 1121 std::vector<GURL> gurlVector;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1316
1315 } // namespace browser 1317 } // namespace browser
1316 1318
1317 namespace app_controller_mac { 1319 namespace app_controller_mac {
1318 1320
1319 bool IsOpeningNewWindow() { 1321 bool IsOpeningNewWindow() {
1320 return g_is_opening_new_window; 1322 return g_is_opening_new_window;
1321 } 1323 }
1322 1324
1323 } // namespace app_controller_mac 1325 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698