| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/app_launcher_handler.h" | 5 #include "chrome/browser/dom_ui/app_launcher_handler.h" |
| 6 | 6 |
| 7 #include "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Don't include the WebStore component app. The WebStore launcher | 174 // Don't include the WebStore component app. The WebStore launcher |
| 175 // gets special treatment in ntp/apps.js. | 175 // gets special treatment in ntp/apps.js. |
| 176 if ((*it)->is_app() && (*it)->id() != extension_misc::kWebStoreAppId) { | 176 if ((*it)->is_app() && (*it)->id() != extension_misc::kWebStoreAppId) { |
| 177 DictionaryValue* app_info = new DictionaryValue(); | 177 DictionaryValue* app_info = new DictionaryValue(); |
| 178 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); | 178 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); |
| 179 list->Append(app_info); | 179 list->Append(app_info); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 dictionary->Set("apps", list); | 182 dictionary->Set("apps", list); |
| 183 | 183 |
| 184 DefaultApps* default_apps = extensions_service_->default_apps(); | |
| 185 if (default_apps->ShouldShowPromo(extensions_service_->GetAppIds())) { | |
| 186 dictionary->SetBoolean("showPromo", true); | |
| 187 default_apps->DidShowPromo(); | |
| 188 promo_active_ = true; | |
| 189 } else { | |
| 190 dictionary->SetBoolean("showPromo", false); | |
| 191 promo_active_ = false; | |
| 192 } | |
| 193 | |
| 194 bool showLauncher = | 184 bool showLauncher = |
| 195 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher); | 185 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher); |
| 196 dictionary->SetBoolean("showLauncher", showLauncher); | 186 dictionary->SetBoolean("showLauncher", showLauncher); |
| 197 | 187 |
| 198 #if defined(OS_MACOSX) | 188 #if defined(OS_MACOSX) |
| 199 // App windows are not yet implemented on mac. | 189 // App windows are not yet implemented on mac. |
| 200 dictionary->SetBoolean("disableAppWindowLaunch", true); | 190 dictionary->SetBoolean("disableAppWindowLaunch", true); |
| 201 dictionary->SetBoolean("disableCreateAppShortcut", true); | 191 dictionary->SetBoolean("disableCreateAppShortcut", true); |
| 202 #endif | 192 #endif |
| 203 } | 193 } |
| 204 | 194 |
| 205 void AppLauncherHandler::HandleGetApps(const ListValue* args) { | 195 void AppLauncherHandler::HandleGetApps(const ListValue* args) { |
| 206 DictionaryValue dictionary; | 196 DictionaryValue dictionary; |
| 207 FillAppDictionary(&dictionary); | 197 FillAppDictionary(&dictionary); |
| 198 |
| 199 // Tell the client whether to show the promo for this view. We don't do this |
| 200 // in the case of PREF_CHANGED because: |
| 201 // |
| 202 // a) At that point in time, depending on the pref that changed, it can look |
| 203 // like the set of apps installed has changed, and we will mark the promo |
| 204 // expired. |
| 205 // b) Conceptually, it doesn't really make sense to count a |
| 206 // prefchange-triggered refresh as a promo 'view'. |
| 207 DefaultApps* default_apps = extensions_service_->default_apps(); |
| 208 if (default_apps->CheckShouldShowPromo(extensions_service_->GetAppIds())) { |
| 209 dictionary.SetBoolean("showPromo", true); |
| 210 default_apps->DidShowPromo(); |
| 211 promo_active_ = true; |
| 212 } else { |
| 213 dictionary.SetBoolean("showPromo", false); |
| 214 promo_active_ = false; |
| 215 } |
| 216 |
| 208 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); | 217 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); |
| 209 | 218 |
| 210 // First time we get here we set up the observer so that we can tell update | 219 // First time we get here we set up the observer so that we can tell update |
| 211 // the apps as they change. | 220 // the apps as they change. |
| 212 if (registrar_.IsEmpty()) { | 221 if (registrar_.IsEmpty()) { |
| 213 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 222 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
| 214 NotificationService::AllSources()); | 223 NotificationService::AllSources()); |
| 215 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 224 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 216 NotificationService::AllSources()); | 225 NotificationService::AllSources()); |
| 217 } | 226 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // We make this check for the case of minimized windows, unit tests, etc. | 405 // We make this check for the case of minimized windows, unit tests, etc. |
| 397 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && | 406 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && |
| 398 Animation::ShouldRenderRichAnimation()) { | 407 Animation::ShouldRenderRichAnimation()) { |
| 399 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
| 400 AppLaunchedAnimation::Show(extension, rect); | 409 AppLaunchedAnimation::Show(extension, rect); |
| 401 #else | 410 #else |
| 402 NOTIMPLEMENTED(); | 411 NOTIMPLEMENTED(); |
| 403 #endif | 412 #endif |
| 404 } | 413 } |
| 405 } | 414 } |
| OLD | NEW |