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#ifndef CHROME_BROWSER_UI_WEBUI_NTP_CORE_APP_LAUNCHER_HANDLER_H_ 6#define CHROME_BROWSER_UI_WEBUI_NTP_CORE_APP_LAUNCHER_HANDLER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/compiler_specific.h" 12#include "base/values.h" 13#include "chrome/common/extensions/extension_constants.h" 14#include "content/public/browser/web_ui_message_handler.h" 15#include "extensions/common/extension.h" 16 17namespace extensions { 18class Extension; 19} 20 21namespace user_prefs { 22class PrefRegistrySyncable; 23} 24 25class Profile; 26 27class CoreAppLauncherHandler : public content::WebUIMessageHandler { 28 public: 29 CoreAppLauncherHandler(); 30 virtual ~CoreAppLauncherHandler(); 31 32 // Records the given type of app launch for UMA. 33 static void RecordAppLaunchType(extension_misc::AppLaunchBucket bucket, 34 extensions::Manifest::Type app_type); 35 36 // Register app launcher preferences. 37 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 38 39 // Records an app launch from the search view of the app list. 40 static void RecordAppListSearchLaunch(const extensions::Extension* extension); 41 42 // Records an app launch from the main view of the app list. 43 static void RecordAppListMainLaunch(const extensions::Extension* extension); 44 45 // Records a web store launch in the appropriate histograms. 46 static void RecordWebStoreLaunch(); 47 48 private: 49 // Callback for the "recordAppLaunchByUrl" message. Takes an escaped URL and 50 // a launch source(integer), and if the URL represents an app, records the 51 // action for UMA. 52 void HandleRecordAppLaunchByUrl(const base::ListValue* args); 53 54 // Records an app launch in the corresponding |bucket| of the app launch 55 // histogram if the |escaped_url| corresponds to an installed app. 56 void RecordAppLaunchByUrl(Profile* profile, 57 std::string escaped_url, 58 extension_misc::AppLaunchBucket bucket); 59 60 // WebUIMessageHandler implementation. 61 virtual void RegisterMessages() OVERRIDE; 62 63 DISALLOW_COPY_AND_ASSIGN(CoreAppLauncherHandler); 64}; 65 66#endif // CHROME_BROWSER_UI_WEBUI_NTP_CORE_APP_LAUNCHER_HANDLER_H_ 67