diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 21:01:35 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 21:01:35 +0000 |
commit | cc829cf6a86824c7651abf68b47993b3d1629260 (patch) | |
tree | d3aada7adc47acfa17c716194833f8eb5eef81eb /chrome/browser/ui/webui | |
parent | 85d52babf996c106a02b8fea6d07870351f82908 (diff) | |
download | chromium_src-cc829cf6a86824c7651abf68b47993b3d1629260.zip chromium_src-cc829cf6a86824c7651abf68b47993b3d1629260.tar.gz chromium_src-cc829cf6a86824c7651abf68b47993b3d1629260.tar.bz2 |
ntp4: make app-install-via-drag less janky
don't reposition the tiles since we always add the app at the end anyways.
Also, respect which page it's dropped on (instead of always adding to the first page).
BUG=93159
TEST=drag a most visited tile onto an apps page.
Review URL: http://codereview.chromium.org/7677032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui')
-rw-r--r-- | chrome/browser/ui/webui/ntp/app_launcher_handler.cc | 32 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/app_launcher_handler.h | 9 |
2 files changed, 27 insertions, 14 deletions
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 8bc9b69..53c68cf 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -156,7 +156,7 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension, int app_launch_index = prefs->GetAppLaunchIndex(extension->id()); if (app_launch_index == -1) { // Make sure every app has a launch index (some predate the launch index). - app_launch_index = prefs->GetNextAppLaunchIndex(); + app_launch_index = prefs->GetNextAppLaunchIndex(0); prefs->SetAppLaunchIndex(extension->id(), app_launch_index); } value->SetInteger("app_launch_index", app_launch_index); @@ -690,32 +690,32 @@ void AppLauncherHandler::HandleSaveAppPageName(const ListValue* args) { void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { std::string url; CHECK(args->GetString(0, &url)); + GURL launch_url(url); string16 title; CHECK(args->GetString(1, &title)); - GURL launch_url(url); - - scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo); - web_app->is_bookmark_app = true; - web_app->title = title; - web_app->app_url = launch_url; + double page_index; + CHECK(args->GetDouble(2, &page_index)); Profile* profile = Profile::FromWebUI(web_ui_); FaviconService* favicon_service = profile->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service) { LOG(ERROR) << "No favicon service"; - scoped_refptr<CrxInstaller> installer( - extension_service_->MakeCrxInstaller(NULL)); - installer->InstallWebApp(*web_app); return; } + scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); + install_info->is_bookmark_app = true; + install_info->title = title; + install_info->app_url = launch_url; + install_info->page_index = static_cast<int>(page_index); + FaviconService::Handle h = favicon_service->GetFaviconForURL( launch_url, history::FAVICON, &favicon_consumer_, NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); - favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); + favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); } void AppLauncherHandler::HandleRecordAppLaunchByURL( @@ -734,8 +734,13 @@ void AppLauncherHandler::HandleRecordAppLaunchByURL( void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, history::FaviconData data) { - scoped_ptr<WebApplicationInfo> web_app( + scoped_ptr<AppInstallInfo> install_info( favicon_consumer_.GetClientDataForCurrentRequest()); + scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); + web_app->is_bookmark_app = install_info->is_bookmark_app; + web_app->title = install_info->title; + web_app->app_url = install_info->app_url; + WebApplicationInfo::IconInfo icon; web_app->icons.push_back(icon); if (data.is_valid() && gfx::PNGCodec::Decode(data.image_data->front(), @@ -750,6 +755,7 @@ void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, scoped_refptr<CrxInstaller> installer( extension_service_->MakeCrxInstaller(NULL)); + installer->set_page_index(install_info->page_index); installer->InstallWebApp(*web_app); } @@ -760,7 +766,7 @@ void AppLauncherHandler::RegisterUserPrefs(PrefService* pref_service) { PrefService::UNSYNCABLE_PREF); } -// static +// statiic void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, extension_misc::APP_LAUNCH_NTP_WEBSTORE, diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h index 0b2c395..1559d24 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h @@ -115,6 +115,13 @@ class AppLauncherHandler : public WebUIMessageHandler, static void RegisterUserPrefs(PrefService* pref_service); private: + struct AppInstallInfo { + bool is_bookmark_app; + string16 title; + GURL app_url; + int page_index; + }; + // Records a web store launch in the appropriate histograms. |promo_active| // specifies if the web store promotion was active. static void RecordWebStoreLaunch(bool promo_active); @@ -184,7 +191,7 @@ class AppLauncherHandler : public WebUIMessageHandler, bool ignore_changes_; // Hold state for favicon requests. - CancelableRequestConsumerTSimple<WebApplicationInfo*> favicon_consumer_; + CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_; DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); }; |