OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 int app_launch_index = prefs->GetAppLaunchIndex(extension->id()); | 156 int app_launch_index = prefs->GetAppLaunchIndex(extension->id()); |
157 if (app_launch_index == -1) { | 157 if (app_launch_index == -1) { |
158 // Make sure every app has a launch index (some predate the launch index). | 158 // Make sure every app has a launch index (some predate the launch index). |
159 app_launch_index = prefs->GetNextAppLaunchIndex(0); | 159 app_launch_index = prefs->GetNextAppLaunchIndex(0); |
160 prefs->SetAppLaunchIndex(extension->id(), app_launch_index); | 160 prefs->SetAppLaunchIndex(extension->id(), app_launch_index); |
161 } | 161 } |
162 value->SetInteger("app_launch_index", app_launch_index); | 162 value->SetInteger("app_launch_index", app_launch_index); |
163 | 163 |
164 int page_index = prefs->GetPageIndex(extension->id()); | 164 int page_index = prefs->GetPageIndex(extension->id()); |
165 if (page_index >= 0) { | 165 if (page_index < 0) { |
166 // Only provide a value if one is stored | 166 // Make sure every app has a page index (some predate the page index). |
167 value->SetInteger("page_index", page_index); | 167 // The webstore app should be on the first page. |
| 168 page_index = extension->id() == extension_misc::kWebStoreAppId ? |
| 169 0 : prefs->GetNaturalAppPageIndex(); |
| 170 prefs->SetPageIndex(extension->id(), page_index); |
168 } | 171 } |
| 172 value->SetInteger("page_index", page_index); |
169 } | 173 } |
170 | 174 |
171 // TODO(estade): remove this. We record app launches via js calls rather than | 175 // TODO(estade): remove this. We record app launches via js calls rather than |
172 // pings for ntp4. | 176 // pings for ntp4. |
173 // static | 177 // static |
174 bool AppLauncherHandler::HandlePing(Profile* profile, const std::string& path) { | 178 bool AppLauncherHandler::HandlePing(Profile* profile, const std::string& path) { |
175 std::vector<std::string> params; | 179 std::vector<std::string> params; |
176 base::SplitString(path, '+', ¶ms); | 180 base::SplitString(path, '+', ¶ms); |
177 | 181 |
178 // Check if the user launched an app from the most visited or recently | 182 // Check if the user launched an app from the most visited or recently |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 921 |
918 void AppLauncherHandler::UninstallDefaultApps() { | 922 void AppLauncherHandler::UninstallDefaultApps() { |
919 AppsPromo* apps_promo = extension_service_->apps_promo(); | 923 AppsPromo* apps_promo = extension_service_->apps_promo(); |
920 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 924 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
921 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 925 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
922 iter != app_ids.end(); ++iter) { | 926 iter != app_ids.end(); ++iter) { |
923 if (extension_service_->GetExtensionById(*iter, true)) | 927 if (extension_service_->GetExtensionById(*iter, true)) |
924 extension_service_->UninstallExtension(*iter, false, NULL); | 928 extension_service_->UninstallExtension(*iter, false, NULL); |
925 } | 929 } |
926 } | 930 } |
OLD | NEW |