Home | History | Annotate | Download | only in win
      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 
     16 namespace base {
     17 namespace win {
     18 
     19 // Identifies the type of the metro launch.
     20 enum 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.
     32 enum 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).
     43 enum 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.
     62 struct 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.
     69 BASE_EXPORT HMODULE GetMetroModule();
     70 
     71 // Returns true if this process is running as an immersive program
     72 // in Windows Metro mode.
     73 BASE_EXPORT bool IsMetroProcess();
     74 
     75 // Returns true if the process identified by the handle passed in is an
     76 // immersive (Metro) process.
     77 BASE_EXPORT bool IsProcessImmersive(HANDLE process);
     78 
     79 // Returns true if this process is running under Text Services Framework (TSF)
     80 // and browser must be TSF-aware.
     81 BASE_EXPORT bool IsTSFAwareRequired();
     82 
     83 // Sets browser to use Text Services Framework (TSF) regardless of process
     84 // status. On Windows 8, this function also disables CUAS (Cicero Unaware
     85 // Application Support) to emulate Windows Metro mode in terms of IME
     86 // functionality. This should be beneficial in QA process because on can test
     87 // IME functionality in Windows 8 desktop mode.
     88 BASE_EXPORT void SetForceToUseTSF();
     89 
     90 // Allocates and returns the destination string via the LocalAlloc API after
     91 // copying the src to it.
     92 BASE_EXPORT wchar_t* LocalAllocAndCopyString(const string16& src);
     93 
     94 // Returns true if Windows Parental control activity logging is enabled. This
     95 // feature is available on Windows Vista and beyond.
     96 // This function should ideally be called on the UI thread.
     97 BASE_EXPORT bool IsParentalControlActivityLoggingOn();
     98 
     99 // Returns the type of launch and the activation params. For example if the
    100 // the launch is for METRO_PROTOCOL then the params is a url.
    101 BASE_EXPORT MetroLaunchType GetMetroLaunchParams(string16* params);
    102 
    103 // Handler function for the buttons on a metro dialog box
    104 typedef void (*MetroDialogButtonPressedHandler)();
    105 
    106 // Handler function invoked when a metro style notification is clicked.
    107 typedef void (*MetroNotificationClickedHandler)(const wchar_t* context);
    108 
    109 // Function to display metro style notifications.
    110 typedef void (*MetroNotification)(const char* origin_url,
    111                                   const char* icon_url,
    112                                   const wchar_t* title,
    113                                   const wchar_t* body,
    114                                   const wchar_t* display_source,
    115                                   const char* notification_id,
    116                                   MetroNotificationClickedHandler handler,
    117                                   const wchar_t* handler_context);
    118 
    119 // Function to cancel displayed notification.
    120 typedef bool (*MetroCancelNotification)(const char* notification_id);
    121 
    122 // Callback for UMA invoked by Metro Pin and UnPin functions after user gesture.
    123 typedef base::Callback<void(MetroSecondaryTilePinUmaResult)>
    124     MetroPinUmaResultCallback;
    125 
    126 // Function to pin a site-specific tile (bookmark) to the start screen.
    127 typedef void (*MetroPinToStartScreen)(
    128     const string16& tile_id,
    129     const string16& title,
    130     const string16& url,
    131     const FilePath& logo_path,
    132     const MetroPinUmaResultCallback& callback);
    133 
    134 // Function to un-pin a site-specific tile (bookmark) from the start screen.
    135 typedef void (*MetroUnPinFromStartScreen)(
    136     const string16& title_id,
    137     const MetroPinUmaResultCallback& callback);
    138 
    139 }  // namespace win
    140 }  // namespace base
    141 
    142 #endif  // BASE_WIN_METRO_H_
    143