Home | History | Annotate | Download | only in apps
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "apps/app_launcher.h"
      6 
      7 #include "apps/field_trial_names.h"
      8 #include "apps/pref_names.h"
      9 #include "base/metrics/field_trial.h"
     10 #include "base/prefs/pref_registry_simple.h"
     11 #include "base/prefs/pref_service.h"
     12 #include "chrome/browser/browser_process.h"
     13 #include "chrome/browser/ui/host_desktop.h"
     14 
     15 namespace apps {
     16 
     17 bool IsAppLauncherEnabled() {
     18 #if !defined(ENABLE_APP_LIST)
     19   return false;
     20 
     21 #elif defined(OS_CHROMEOS)
     22   return true;
     23 
     24 #else  // defined(ENABLE_APP_LIST) && !defined(OS_CHROMEOS)
     25   if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
     26     return true;
     27 
     28   PrefService* prefs = g_browser_process->local_state();
     29   // In some tests, the prefs aren't initialised.
     30   return prefs && prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled);
     31 #endif
     32 }
     33 
     34 bool ShouldShowAppLauncherPromo() {
     35   PrefService* local_state = g_browser_process->local_state();
     36   // In some tests, the prefs aren't initialised.
     37   if (!local_state)
     38     return false;
     39   std::string app_launcher_promo_group_name =
     40       base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName);
     41   return !IsAppLauncherEnabled() &&
     42       local_state->GetBoolean(apps::prefs::kShowAppLauncherPromo) &&
     43       (app_launcher_promo_group_name == apps::kShowLauncherPromoOnceGroupName ||
     44        app_launcher_promo_group_name ==
     45           apps::kResetShowLauncherPromoPrefGroupName);
     46 }
     47 
     48 }  // namespace apps
     49