Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3085)

Unified Diff: chrome/browser/ui/app_list/app_list_service.cc

Issue 1973203002: Make --show-app-list go to the chrome://apps page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/app_list_service.cc
diff --git a/chrome/browser/ui/app_list/app_list_service.cc b/chrome/browser/ui/app_list/app_list_service.cc
index e9ab06d4f3bd3e3030f10fdf1fab5f03a51c05a2..263f625bbb6379b0ba0eacf5d54d3ff74b7203de 100644
--- a/chrome/browser/ui/app_list/app_list_service.cc
+++ b/chrome/browser/ui/app_list/app_list_service.cc
@@ -7,136 +7,17 @@
#include <stdint.h>
#include "base/command_line.h"
-#include "base/metrics/histogram.h"
-#include "base/process/process_info.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
#include "components/prefs/pref_registry_simple.h"
-namespace {
-
-enum StartupType {
- COLD_START,
- WARM_START,
- WARM_START_FAST,
-};
-
-// For when an app list show request is received via CommandLine. Indicates
-// whether the Profile the app list was previously showing was the SAME, OTHER
-// or NONE with respect to the new Profile to show.
-enum ProfileLoadState {
- PROFILE_LOADED_SAME,
- PROFILE_LOADED_OTHER,
- PROFILE_LOADED_NONE,
-};
-
-base::Time GetOriginalProcessStartTime(const base::CommandLine& command_line) {
- if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) {
- std::string start_time_string =
- command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime);
- int64_t remote_start_time;
- base::StringToInt64(start_time_string, &remote_start_time);
- return base::Time::FromInternalValue(remote_start_time);
- }
-
-// base::CurrentProcessInfo::CreationTime() is only defined on some
-// platforms.
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
- return base::CurrentProcessInfo::CreationTime();
-#else
- return base::Time();
-#endif
-}
-
-StartupType GetStartupType(const base::CommandLine& command_line) {
- // The presence of kOriginalProcessStartTime implies that another process
- // has sent us its command line to handle, ie: we are already running.
- if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) {
- return command_line.HasSwitch(switches::kFastStart) ?
- WARM_START_FAST : WARM_START;
- }
- return COLD_START;
-}
-
-// The time the process that caused the app list to be shown started. This isn't
-// necessarily the currently executing process as we may be processing a command
-// line given to a short-lived Chrome instance.
-int64_t g_original_process_start_time;
-
-// The type of startup the the current app list show has gone through.
-StartupType g_app_show_startup_type;
-
-// The state of the active app list profile at the most recent launch.
-ProfileLoadState g_profile_load_state;
-
-void RecordFirstPaintTiming() {
- base::Time start_time(
- base::Time::FromInternalValue(g_original_process_start_time));
- base::TimeDelta elapsed = base::Time::Now() - start_time;
- switch (g_app_show_startup_type) {
- case COLD_START:
- DCHECK_EQ(PROFILE_LOADED_NONE, g_profile_load_state);
- UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed);
- break;
- case WARM_START:
- // For warm starts, only record showing the same profile. "NONE" should
- // only occur in the first 30 seconds after startup. "OTHER" only occurs
- // for multi-profile cases. In these cases, timings are also affected by
- // whether or not a profile has been loaded from disk, which makes the
- // profile load asynchronous and skews results unpredictably.
- if (g_profile_load_state == PROFILE_LOADED_SAME)
- UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed);
- break;
- case WARM_START_FAST:
- if (g_profile_load_state == PROFILE_LOADED_SAME) {
- UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast",
- elapsed);
- }
- break;
- }
-}
-
-void RecordStartupInfo(AppListService* service,
- const base::CommandLine& command_line,
- Profile* launch_profile) {
- base::Time start_time = GetOriginalProcessStartTime(command_line);
- if (start_time.is_null())
- return;
-
- base::TimeDelta elapsed = base::Time::Now() - start_time;
- StartupType startup_type = GetStartupType(command_line);
- switch (startup_type) {
- case COLD_START:
- UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed);
- break;
- case WARM_START:
- UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed);
- break;
- case WARM_START_FAST:
- UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed);
- break;
- }
-
- g_original_process_start_time = start_time.ToInternalValue();
- g_app_show_startup_type = startup_type;
-
- Profile* current_profile = service->GetCurrentAppListProfile();
- if (!current_profile)
- g_profile_load_state = PROFILE_LOADED_NONE;
- else if (current_profile == launch_profile)
- g_profile_load_state = PROFILE_LOADED_SAME;
- else
- g_profile_load_state = PROFILE_LOADED_OTHER;
-
- service->SetAppListNextPaintCallback(RecordFirstPaintTiming);
-}
-
-} // namespace
-
// static
void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0);
@@ -167,9 +48,11 @@ bool AppListService::HandleLaunchCommandLine(
if (!command_line.HasSwitch(switches::kShowAppList))
return false;
- AppListService* service = Get();
- DCHECK(service);
- RecordStartupInfo(service, command_line, launch_profile);
- service->ShowForProfile(launch_profile);
+ Browser* browser = chrome::FindLastActive();
+
+ chrome::NavigateParams params(browser ? browser->profile() : launch_profile,
tapted 2016/05/17 03:11:13 app_list_service.cc isn't compiled when enable_app
calamity 2016/05/18 01:11:38 Done.
+ GURL(chrome::kChromeUIAppsURL),
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ chrome::Navigate(&params);
return true;
}
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698