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

Unified Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

Issue 117683002: Show the Mac app launcher window with a spinner while loading Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, ensure no startup flows regress Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/app_list_service_mac.mm
diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm
index f6050dea63401e5a5ba1e85a3e4422c4378a7dcd..cf2d7e4952eaea2c41799bf5193dc018eb824697 100644
--- a/chrome/browser/ui/app_list/app_list_service_mac.mm
+++ b/chrome/browser/ui/app_list/app_list_service_mac.mm
@@ -30,6 +30,7 @@
#include "chrome/browser/ui/web_applications/web_app_ui.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_mac.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/mac/app_mode_common.h"
@@ -68,6 +69,11 @@ class ImageSkia;
targetOrigin:(NSPoint)targetOrigin
closing:(BOOL)closing;
+// Called on the UI thread once the animation has completed to reset the
+// animation state, close the window (if it is a close animation), and possibly
+// terminate Chrome.
+- (void)cleanupOnUIThread;
+
@end
namespace {
@@ -360,6 +366,15 @@ void AppListServiceMac::Init(Profile* initial_profile) {
init_called = true;
apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId,
AppListServiceMac::GetInstance());
+
+ // Handle the case where Chrome was not running and was started with the app
+ // launcher shim. The profile has not yet been loaded. To improve response
+ // times, start animating an empty window which will be populated via
+ // OnShimLaunch(). Note that if --silent-launch is not also passed, the window
+ // will instead populate via StartupBrowserCreator::Launch(). Shim-initiated
+ // lanuches will always have --silent-launch.
jackhou1 2014/01/17 06:10:53 lanuches -> launches
tapted 2014/01/17 06:21:03 Done.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList))
+ ShowWindowNearDock();
}
Profile* AppListServiceMac::GetCurrentAppListProfile() {
@@ -372,13 +387,8 @@ void AppListServiceMac::CreateForProfile(Profile* requested_profile) {
profile_ = requested_profile;
- if (window_controller_) {
- // Clear the search box.
- [[window_controller_ appListViewController] searchBoxModel]
tapted 2014/01/17 04:42:40 note: this logic is refactored into the view contr
- ->SetText(base::string16());
- } else {
+ if (!window_controller_)
window_controller_.reset([[AppListWindowController alloc] init]);
- }
scoped_ptr<app_list::AppListViewDelegate> delegate(
new AppListViewDelegate(profile_, GetControllerDelegate()));
@@ -453,10 +463,14 @@ AppListControllerDelegate* AppListServiceMac::GetControllerDelegate() {
void AppListServiceMac::OnShimLaunch(apps::AppShimHandler::Host* host,
apps::AppShimLaunchType launch_type,
const std::vector<base::FilePath>& files) {
- if (IsAppListVisible())
+ if (profile_ && IsAppListVisible()) {
DismissAppList();
- else
+ } else {
+ // Start by showing a possibly empty window to handle the case where Chrome
+ // is running, but hasn't yet loaded the app launcher profile.
+ ShowWindowNearDock();
Show();
+ }
// Always close the shim process immediately.
host->OnAppLaunchComplete(apps::APP_SHIM_LAUNCH_DUPLICATE_HOST);
@@ -477,6 +491,12 @@ void AppListServiceMac::ShowWindowNearDock() {
if (IsAppListVisible())
return;
+ if (!window_controller_) {
+ // Note that this will start showing an unpopulated window, the caller needs
+ // to ensure it will be populated later.
+ window_controller_.reset([[AppListWindowController alloc] init]);
+ }
+
NSWindow* window = GetAppListWindow();
DCHECK(window);
NSPoint target_origin;
@@ -495,6 +515,10 @@ void AppListServiceMac::ShowWindowNearDock() {
RecordAppListLaunch();
}
+void AppListServiceMac::WindowAnimationDidEnd() {
+ [animation_controller_ cleanupOnUIThread];
+}
+
// static
AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
return AppListServiceMac::GetInstance();
@@ -545,15 +569,26 @@ void AppListService::InitAll(Profile* initial_profile) {
[animation_ setAnimationCurve:NSAnimationEaseOut];
window_.reset();
}
+ [animation_ setAnimationBlockingMode:NSAnimationNonblockingThreaded];
[animation_ startAnimation];
}
-- (void)animationDidEnd:(NSAnimation*)animation {
+- (void)cleanupOnUIThread {
+ bool closing = [self isClosing];
[window_ close];
window_.reset();
animation_.reset();
- apps::AppShimHandler::MaybeTerminate();
+ if (closing)
+ apps::AppShimHandler::MaybeTerminate();
+}
+
+- (void)animationDidEnd:(NSAnimation*)animation {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&AppListServiceMac::WindowAnimationDidEnd,
+ base::Unretained(AppListServiceMac::GetInstance())));
}
@end

Powered by Google App Engine
This is Rietveld 408576698