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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 5908003: Added Background Application entries to Dock menu (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed indentation Created 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/background_application_list_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 184b1969ac3a787ca2f66914b814c7218142ca65..81ea20c82121b5da901562daedd05e91a9866f36 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -15,6 +15,7 @@
#include "base/sys_string_conversions.h"
#import "base/worker_pool_mac.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/background_application_list_model.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_thread.h"
@@ -155,6 +156,7 @@ void RecordLastRunAppBundlePath() {
- (void)showPreferencesWindow:(id)sender
page:(OptionsPage)page
profile:(Profile*)profile;
+- (void)executeApplication:(id)sender;
@end
@implementation AppController
@@ -938,9 +940,28 @@ void RecordLastRunAppBundlePath() {
case IDC_OPTIONS:
[self showPreferences:sender];
break;
+ default:
+ [self executeApplication:sender];
Andrew T Wilson (Slow) 2010/12/16 02:18:25 Is there any assert we could have here to make sur
The wrong rickcam account 2010/12/16 18:50:58 Done . . . provided that you like the approach tha
}
}
+// Run a (background) application in a new tab.
+- (void)executeApplication:(id)sender {
+ NSInteger tag = [sender tag];
+ Profile* profile = [self defaultProfile];
+ DCHECK(profile);
+ BackgroundApplicationListModel applications(profile);
+ DCHECK(tag >= 0 &&
+ tag < static_cast<int>(applications.size()));
+ Browser* browser = BrowserList::GetLastActive();
+ if (!browser) {
+ Browser::OpenEmptyWindow(profile);
+ browser = BrowserList::GetLastActive();
+ }
+ const Extension* extension = applications.GetExtension(tag);
+ browser->OpenApplicationTab(profile, extension, NULL);
+}
+
// Same as |-commandDispatch:|, but executes commands using a disposition
// determined by the key flags. This will get called in the case where the
// frontmost window is not a browser window, and the user has command-clicked
@@ -1179,11 +1200,37 @@ void RecordLastRunAppBundlePath() {
- (NSMenu*)applicationDockMenu:(NSApplication*)sender {
NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease];
- NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
- scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc]
- initWithTitle:titleStr
- action:@selector(newWindowFromDock:)
- keyEquivalent:@""]);
+ NSString* titleStr = NULL;
Andrew T Wilson (Slow) 2010/12/16 02:18:25 Should we use nil instead of NULL here? Not sure a
The wrong rickcam account 2010/12/16 18:50:58 Yes. Well, as best as I can tell anyway. I didn'
+ scoped_nsobject<NSMenuItem> item(NULL);
+
Andrew T Wilson (Slow) 2010/12/16 02:18:25 I was confused by us using titleStr/item up here a
The wrong rickcam account 2010/12/16 18:50:58 Done.
+ Profile* profile = [self defaultProfile];
+ DCHECK(profile);
+ int position = 0;
+ BackgroundApplicationListModel applications(profile);
+ if (applications.begin() != applications.end()) {
Andrew T Wilson (Slow) 2010/12/16 02:18:25 I wonder if it's cleaner to move the for loop outs
The wrong rickcam account 2010/12/16 18:50:58 Done. I saw the purpose as "avoiding the whole bl
+ for (ExtensionList::const_iterator cursor = applications.begin();
The wrong rickcam account 2010/12/16 01:22:26 Need to indent the following two lines a bit more.
+ cursor != applications.end();
+ ++cursor, ++position) {
+ int sort_position = applications.GetPosition(*cursor);
+ DCHECK(sort_position == position);
Andrew T Wilson (Slow) 2010/12/16 02:18:25 I dimly recall talking about this before - why can
The wrong rickcam account 2010/12/16 18:50:58 Done. In fact, I think I missed that bit of clean
+ const std::string& name = (*cursor)->name();
+ string16 label = ASCIIToUTF16(name);
Andrew T Wilson (Slow) 2010/12/16 02:18:25 This seems weird to me. Should this be UTF8ToUTF16
The wrong rickcam account 2010/12/16 18:50:58 Done.
+ titleStr = l10n_util::FixUpWindowsStyleLabel(label);
Andrew T Wilson (Slow) 2010/12/16 02:18:25 I'm not sure that we should call this - I think th
The wrong rickcam account 2010/12/16 18:50:58 Done. Swtiched to base::SysUTF16ToNSString which
+ item.reset([[NSMenuItem alloc] initWithTitle:titleStr
+ action:@selector(newWindowFromDock:)
Andrew T Wilson (Slow) 2010/12/16 02:18:25 BTW, I'm wondering if newWindowFromDock should be
The wrong rickcam account 2010/12/16 18:50:58 Done.
+ keyEquivalent:@""]);
+ [item setTarget:self];
+ [item setTag:position];
+ [dockMenu addItem:item];
+ }
+ titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
Andrew T Wilson (Slow) 2010/12/16 02:18:25 Remove this superfluous set of titleStr.
The wrong rickcam account 2010/12/16 18:50:58 Done.
+ NSMenuItem* sepItem = [[NSMenuItem separatorItem] init];
+ [dockMenu addItem:sepItem];
+ }
+ titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
+ item.reset([[NSMenuItem alloc] initWithTitle:titleStr
+ action:@selector(newWindowFromDock:)
+ keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_WINDOW];
[dockMenu addItem:item];
« no previous file with comments | « no previous file | chrome/browser/background_application_list_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698