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

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

Issue 99128: Allow File>Open File with no window open. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 | no next file » | 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 Profile* default_profile = [self defaultProfile]; 114 Profile* default_profile = [self defaultProfile];
115 115
116 NSInteger tag = [sender tag]; 116 NSInteger tag = [sender tag];
117 switch (tag) { 117 switch (tag) {
118 case IDC_NEW_WINDOW: 118 case IDC_NEW_WINDOW:
119 Browser::OpenEmptyWindow(default_profile); 119 Browser::OpenEmptyWindow(default_profile);
120 break; 120 break;
121 case IDC_NEW_INCOGNITO_WINDOW: 121 case IDC_NEW_INCOGNITO_WINDOW:
122 Browser::OpenURLOffTheRecord(default_profile, GURL()); 122 Browser::OpenURLOffTheRecord(default_profile, GURL());
123 break; 123 break;
124 case IDC_OPEN_FILE:
125 Browser::OpenEmptyWindow(default_profile);
pink (ping after 24hrs) 2009/04/28 16:12:12 are you sure this is synchronous?
Avi (use Gerrit) 2009/04/28 16:15:56 No. That's why I was trying it out to see if it wo
126 BrowserList::GetLastActive()->
127 ExecuteCommandWithDisposition(IDC_OPEN_FILE, CURRENT_TAB);
128 break;
124 }; 129 };
125 } 130 }
126 131
127 // NSApplication delegate method called when someone clicks on the 132 // NSApplication delegate method called when someone clicks on the
128 // dock icon and there are no open windows. To match standard mac 133 // dock icon and there are no open windows. To match standard mac
129 // behavior, we should open a new window. 134 // behavior, we should open a new window.
130 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication 135 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
131 hasVisibleWindows:(BOOL)flag { 136 hasVisibleWindows:(BOOL)flag {
132 // Don't do anything if there are visible windows. This will cause 137 // Don't do anything if there are visible windows. This will cause
133 // AppKit to unminimize the most recently minimized window. 138 // AppKit to unminimize the most recently minimized window.
134 if (flag) 139 if (flag)
135 return YES; 140 return YES;
136 141
137 // Otherwise open a new window. 142 // Otherwise open a new window.
138 Browser::OpenEmptyWindow([self defaultProfile]); 143 Browser::OpenEmptyWindow([self defaultProfile]);
139 144
140 // We've handled the reopen event, so return NO to tell AppKit not 145 // We've handled the reopen event, so return NO to tell AppKit not
141 // to do anything. 146 // to do anything.
142 return NO; 147 return NO;
143 } 148 }
144 149
145 - (void)initMenuState { 150 - (void)initMenuState {
146 menuState_ = new CommandUpdater(NULL); 151 menuState_ = new CommandUpdater(NULL);
147 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true); 152 menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true);
148 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); 153 menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true);
154 menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true);
149 // TODO(pinkerton): ...more to come... 155 // TODO(pinkerton): ...more to come...
150 } 156 }
151 157
152 - (Profile*)defaultProfile { 158 - (Profile*)defaultProfile {
153 // TODO(jrg): Find a better way to get the "default" profile. 159 // TODO(jrg): Find a better way to get the "default" profile.
154 if (g_browser_process->profile_manager()) 160 if (g_browser_process->profile_manager())
155 return* g_browser_process->profile_manager()->begin(); 161 return* g_browser_process->profile_manager()->begin();
156 162
157 return NULL; 163 return NULL;
158 } 164 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 for (NSString* filename in filenames) { 197 for (NSString* filename in filenames) {
192 NSURL* fileURL = [NSURL fileURLWithPath:filename]; 198 NSURL* fileURL = [NSURL fileURLWithPath:filename];
193 GURL gurl(base::SysNSStringToUTF8([fileURL absoluteString])); 199 GURL gurl(base::SysNSStringToUTF8([fileURL absoluteString]));
194 gurlVector.push_back(gurl); 200 gurlVector.push_back(gurl);
195 } 201 }
196 202
197 OpenURLs(gurlVector); 203 OpenURLs(gurlVector);
198 } 204 }
199 205
200 @end 206 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698