blob: 1a13a9d4d0551478045d5f9c06b5f5de8ead14f8 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/app_shim/app_shim_delegate.h"
#include "base/mac/foundation_util.h"
#include "chrome/app_shim/app_shim_controller.h"
@implementation AppShimDelegate
- (id)initWithController:(AppShimController*)controller {
if (self = [super init])
appShimController_ = controller;
return self;
}
- (void)applicationDidFinishLaunching:(NSNotification*)notification {
appShimController_->OnAppFinishedLaunching();
}
- (BOOL)application:(NSApplication*)app openFile:(NSString*)filename {
std::vector<base::FilePath> filePaths = {
base::mac::NSStringToFilePath(filename)};
appShimController_->OpenFiles(filePaths);
return YES;
}
- (void)application:(NSApplication*)app openFiles:(NSArray*)filenames {
std::vector<base::FilePath> filePaths;
for (NSString* filename in filenames)
filePaths.push_back(base::mac::NSStringToFilePath(filename));
appShimController_->OpenFiles(filePaths);
[app replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
}
- (void)applicationWillBecomeActive:(NSNotification*)notification {
// TODO(https://crbug.com/829689): There should be no arguments to this mojo
// method.
return appShimController_->host()->FocusApp(
chrome::mojom::AppShimFocusType::kNormal, std::vector<base::FilePath>());
}
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
return NO;
}
@end