| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "apps/metrics_names.h" | 9 #include "apps/metrics_names.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 &icon_small_exists); | 153 &icon_small_exists); |
| 154 value->SetString("icon_small", icon_small.spec()); | 154 value->SetString("icon_small", icon_small.spec()); |
| 155 value->SetBoolean("icon_small_exists", icon_small_exists); | 155 value->SetBoolean("icon_small_exists", icon_small_exists); |
| 156 value->SetInteger("launch_container", | 156 value->SetInteger("launch_container", |
| 157 extensions::AppLaunchInfo::GetLaunchContainer(extension)); | 157 extensions::AppLaunchInfo::GetLaunchContainer(extension)); |
| 158 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile()); | 158 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile()); |
| 159 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension)); | 159 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension)); |
| 160 value->SetBoolean("is_component", | 160 value->SetBoolean("is_component", |
| 161 extension->location() == extensions::Manifest::COMPONENT); | 161 extension->location() == extensions::Manifest::COMPONENT); |
| 162 value->SetBoolean("is_webstore", | 162 value->SetBoolean("is_webstore", |
| 163 extension->id() == extension_misc::kWebStoreAppId); | 163 extension->id() == extensions::kWebStoreAppId); |
| 164 | 164 |
| 165 AppSorting* sorting = prefs->app_sorting(); | 165 AppSorting* sorting = prefs->app_sorting(); |
| 166 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); | 166 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); |
| 167 if (!page_ordinal.IsValid()) { | 167 if (!page_ordinal.IsValid()) { |
| 168 // Make sure every app has a page ordinal (some predate the page ordinal). | 168 // Make sure every app has a page ordinal (some predate the page ordinal). |
| 169 // The webstore app should be on the first page. | 169 // The webstore app should be on the first page. |
| 170 page_ordinal = extension->id() == extension_misc::kWebStoreAppId ? | 170 page_ordinal = extension->id() == extensions::kWebStoreAppId ? |
| 171 sorting->CreateFirstAppPageOrdinal() : | 171 sorting->CreateFirstAppPageOrdinal() : |
| 172 sorting->GetNaturalAppPageOrdinal(); | 172 sorting->GetNaturalAppPageOrdinal(); |
| 173 sorting->SetPageOrdinal(extension->id(), page_ordinal); | 173 sorting->SetPageOrdinal(extension->id(), page_ordinal); |
| 174 } | 174 } |
| 175 value->SetInteger("page_index", | 175 value->SetInteger("page_index", |
| 176 sorting->PageStringOrdinalAsInteger(page_ordinal)); | 176 sorting->PageStringOrdinalAsInteger(page_ordinal)); |
| 177 | 177 |
| 178 syncer::StringOrdinal app_launch_ordinal = | 178 syncer::StringOrdinal app_launch_ordinal = |
| 179 sorting->GetAppLaunchOrdinal(extension->id()); | 179 sorting->GetAppLaunchOrdinal(extension->id()); |
| 180 if (!app_launch_ordinal.IsValid()) { | 180 if (!app_launch_ordinal.IsValid()) { |
| 181 // Make sure every app has a launch ordinal (some predate the launch | 181 // Make sure every app has a launch ordinal (some predate the launch |
| 182 // ordinal). The webstore's app launch ordinal is always set to the first | 182 // ordinal). The webstore's app launch ordinal is always set to the first |
| 183 // position. | 183 // position. |
| 184 app_launch_ordinal = extension->id() == extension_misc::kWebStoreAppId ? | 184 app_launch_ordinal = extension->id() == extensions::kWebStoreAppId ? |
| 185 sorting->CreateFirstAppLaunchOrdinal(page_ordinal) : | 185 sorting->CreateFirstAppLaunchOrdinal(page_ordinal) : |
| 186 sorting->CreateNextAppLaunchOrdinal(page_ordinal); | 186 sorting->CreateNextAppLaunchOrdinal(page_ordinal); |
| 187 sorting->SetAppLaunchOrdinal(extension->id(), app_launch_ordinal); | 187 sorting->SetAppLaunchOrdinal(extension->id(), app_launch_ordinal); |
| 188 } | 188 } |
| 189 value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue()); | 189 value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void AppLauncherHandler::RegisterMessages() { | 192 void AppLauncherHandler::RegisterMessages() { |
| 193 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, | 193 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, |
| 194 content::Source<WebContents>(web_ui()->GetWebContents())); | 194 content::Source<WebContents>(web_ui()->GetWebContents())); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // Prompt the user to re-enable the application if disabled. | 499 // Prompt the user to re-enable the application if disabled. |
| 500 if (!extension) { | 500 if (!extension) { |
| 501 PromptToEnableApp(extension_id); | 501 PromptToEnableApp(extension_id); |
| 502 return; | 502 return; |
| 503 } | 503 } |
| 504 | 504 |
| 505 Profile* profile = extension_service_->profile(); | 505 Profile* profile = extension_service_->profile(); |
| 506 | 506 |
| 507 WindowOpenDisposition disposition = args->GetSize() > 3 ? | 507 WindowOpenDisposition disposition = args->GetSize() > 3 ? |
| 508 webui::GetDispositionFromClick(args, 3) : CURRENT_TAB; | 508 webui::GetDispositionFromClick(args, 3) : CURRENT_TAB; |
| 509 if (extension_id != extension_misc::kWebStoreAppId) { | 509 if (extension_id != extensions::kWebStoreAppId) { |
| 510 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID); | 510 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID); |
| 511 CoreAppLauncherHandler::RecordAppLaunchType(launch_bucket, | 511 CoreAppLauncherHandler::RecordAppLaunchType(launch_bucket, |
| 512 extension->GetType()); | 512 extension->GetType()); |
| 513 } else { | 513 } else { |
| 514 CoreAppLauncherHandler::RecordWebStoreLaunch(); | 514 CoreAppLauncherHandler::RecordWebStoreLaunch(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB || | 517 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB || |
| 518 disposition == NEW_WINDOW) { | 518 disposition == NEW_WINDOW) { |
| 519 // TODO(jamescook): Proper support for background tabs. | 519 // TODO(jamescook): Proper support for background tabs. |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 Browser* browser = chrome::FindBrowserWithWebContents( | 841 Browser* browser = chrome::FindBrowserWithWebContents( |
| 842 web_ui()->GetWebContents()); | 842 web_ui()->GetWebContents()); |
| 843 extension_uninstall_dialog_.reset( | 843 extension_uninstall_dialog_.reset( |
| 844 extensions::ExtensionUninstallDialog::Create( | 844 extensions::ExtensionUninstallDialog::Create( |
| 845 extension_service_->profile(), | 845 extension_service_->profile(), |
| 846 browser->window()->GetNativeWindow(), | 846 browser->window()->GetNativeWindow(), |
| 847 this)); | 847 this)); |
| 848 } | 848 } |
| 849 return extension_uninstall_dialog_.get(); | 849 return extension_uninstall_dialog_.get(); |
| 850 } | 850 } |
| OLD | NEW |