1// Copyright (c) 2012 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 BASE_WIN_METRO_H_
6#define BASE_WIN_METRO_H_
7
8#include <windows.h>
9#include <wpcapi.h>
10
11#include "base/base_export.h"
12#include "base/callback.h"
13#include "base/files/file_path.h"
14#include "base/strings/string16.h"
15
16namespace base {
17namespace win {
18
19// Identifies the type of the metro launch.
20enum MetroLaunchType {
21  METRO_LAUNCH,
22  METRO_SEARCH,
23  METRO_SHARE,
24  METRO_FILE,
25  METRO_PROTOCOL,
26  METRO_LAUNCH_ERROR,
27  METRO_LASTLAUNCHTYPE,
28};
29
30// In metro mode, this enum identifies the last execution state, i.e. whether
31// we crashed, terminated, etc.
32enum MetroPreviousExecutionState {
33  NOTRUNNING,
34  RUNNING,
35  SUSPENDED,
36  TERMINATED,
37  CLOSEDBYUSER,
38  LASTEXECUTIONSTATE,
39};
40
41// Enum values for UMA histogram reporting of site-specific tile pinning.
42// TODO(tapted): Move this to win8/util when ready (http://crbug.com/160288).
43enum MetroSecondaryTilePinUmaResult {
44  METRO_PIN_STATE_NONE,
45  METRO_PIN_INITIATED,
46  METRO_PIN_LOGO_READY,
47  METRO_PIN_REQUEST_SHOW_ERROR,
48  METRO_PIN_RESULT_CANCEL,
49  METRO_PIN_RESULT_OK,
50  METRO_PIN_RESULT_OTHER,
51  METRO_PIN_RESULT_ERROR,
52  METRO_UNPIN_INITIATED,
53  METRO_UNPIN_REQUEST_SHOW_ERROR,
54  METRO_UNPIN_RESULT_CANCEL,
55  METRO_UNPIN_RESULT_OK,
56  METRO_UNPIN_RESULT_OTHER,
57  METRO_UNPIN_RESULT_ERROR,
58  METRO_PIN_STATE_LIMIT
59};
60
61// Contains information about the currently displayed tab in metro mode.
62struct CurrentTabInfo {
63  wchar_t* title;
64  wchar_t* url;
65};
66
67// Returns the handle to the metro dll loaded in the process. A NULL return
68// indicates that the metro dll was not loaded in the process.
69BASE_EXPORT HMODULE GetMetroModule();
70
71// Returns true if this process is running as an immersive program
72// in Windows Metro mode.
73BASE_EXPORT bool IsMetroProcess();
74
75// Returns true if the process identified by the handle passed in is an
76// immersive (Metro) process.
77BASE_EXPORT bool IsProcessImmersive(HANDLE process);
78
79// Allocates and returns the destination string via the LocalAlloc API after
80// copying the src to it.
81BASE_EXPORT wchar_t* LocalAllocAndCopyString(const string16& src);
82
83// Returns true if Windows Parental control activity logging is enabled. This
84// feature is available on Windows Vista and beyond.
85// This function should ideally be called on the UI thread.
86BASE_EXPORT bool IsParentalControlActivityLoggingOn();
87
88// Returns the type of launch and the activation params. For example if the
89// the launch is for METRO_PROTOCOL then the params is a url.
90BASE_EXPORT MetroLaunchType GetMetroLaunchParams(string16* params);
91
92// Handler function for the buttons on a metro dialog box
93typedef void (*MetroDialogButtonPressedHandler)();
94
95// Handler function invoked when a metro style notification is clicked.
96typedef void (*MetroNotificationClickedHandler)(const wchar_t* context);
97
98// Function to display metro style notifications.
99typedef void (*MetroNotification)(const char* origin_url,
100                                  const char* icon_url,
101                                  const wchar_t* title,
102                                  const wchar_t* body,
103                                  const wchar_t* display_source,
104                                  const char* notification_id,
105                                  MetroNotificationClickedHandler handler,
106                                  const wchar_t* handler_context);
107
108// Function to cancel displayed notification.
109typedef bool (*MetroCancelNotification)(const char* notification_id);
110
111// Callback for UMA invoked by Metro Pin and UnPin functions after user gesture.
112typedef base::Callback<void(MetroSecondaryTilePinUmaResult)>
113    MetroPinUmaResultCallback;
114
115// Function to pin a site-specific tile (bookmark) to the start screen.
116typedef void (*MetroPinToStartScreen)(
117    const string16& tile_id,
118    const string16& title,
119    const string16& url,
120    const FilePath& logo_path,
121    const MetroPinUmaResultCallback& callback);
122
123// Function to un-pin a site-specific tile (bookmark) from the start screen.
124typedef void (*MetroUnPinFromStartScreen)(
125    const string16& title_id,
126    const MetroPinUmaResultCallback& callback);
127
128}  // namespace win
129}  // namespace base
130
131#endif  // BASE_WIN_METRO_H_
132