blob: f3e168a25580af68779e457d216603cd6ce946e8 [file] [log] [blame]
pmonette32a5cfb42016-04-11 22:04:441// Copyright 2016 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_SHELL_INTEGRATION_WIN_H_
6#define CHROME_BROWSER_SHELL_INTEGRATION_WIN_H_
7
Jay Civellid4b89052017-10-31 17:48:258#include <memory>
pmonette32a5cfb42016-04-11 22:04:449#include <string>
10
11#include "base/callback_forward.h"
pmonette9e4c1a82016-04-14 18:15:3012#include "base/files/file_path.h"
13#include "base/strings/string16.h"
pmonette32a5cfb42016-04-11 22:04:4414
Jay Civellid4b89052017-10-31 17:48:2515namespace service_manager {
16class Connector;
17}
18
pmonette32a5cfb42016-04-11 22:04:4419namespace shell_integration {
20namespace win {
21
22// Initiates an OS shell flow which (if followed by the user) should set
23// Chrome as the default browser. Returns false if the flow cannot be
24// initialized, if it is not supported (introduced for Windows 8) or if the
25// user cancels the operation. This is a blocking call and requires a FILE
26// thread. If Chrome is already default browser, no interactive dialog will be
27// shown and this method returns true.
28bool SetAsDefaultBrowserUsingIntentPicker();
29
30// Initiates the interaction with the system settings for the default browser.
31// The function takes care of making sure |on_finished_callback| will get called
32// exactly once when the interaction is finished.
33void SetAsDefaultBrowserUsingSystemSettings(
34 const base::Closure& on_finished_callback);
35
36// Initiates an OS shell flow which (if followed by the user) should set
37// Chrome as the default handler for |protocol|. Returns false if the flow
38// cannot be initialized, if it is not supported (introduced for Windows 8)
39// or if the user cancels the operation. This is a blocking call and requires
40// a FILE thread. If Chrome is already default for |protocol|, no interactive
41// dialog will be shown and this method returns true.
42bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol);
43
pmonette0c40087a2016-04-21 00:05:1644// Initiates the interaction with the system settings for the default handler of
45// |protocol|. The function takes care of making sure |on_finished_callback|
46// will get called exactly once when the interaction is finished.
47void SetAsDefaultProtocolClientUsingSystemSettings(
48 const std::string& protocol,
49 const base::Closure& on_finished_callback);
50
pmonette9e4c1a82016-04-14 18:15:3051// Generates an application user model ID (AppUserModelId) for a given app
52// name and profile path. The returned app id is in the format of
53// "|app_name|[.<profile_id>]". "profile_id" is appended when user override
54// the default value.
55// Note: If the app has an installation specific suffix (e.g. on user-level
56// Chrome installs), |app_name| should already be suffixed, this method will
57// then further suffix it with the profile id as described above.
58base::string16 GetAppModelIdForProfile(const base::string16& app_name,
59 const base::FilePath& profile_path);
60
61// Generates an application user model ID (AppUserModelId) for Chromium by
62// calling GetAppModelIdForProfile() with ShellUtil::GetAppId() as app_name.
63base::string16 GetChromiumModelIdForProfile(const base::FilePath& profile_path);
64
pmonettea98315242016-11-23 21:39:1865// Returns the taskbar pin state of Chrome via the IsPinnedToTaskbarCallback.
66// The first bool is true if the state could be calculated, and the second bool
67// is true if Chrome is pinned to the taskbar.
68// The ConnectionErrorCallback is called instead if something wrong happened
69// with the connection to the remote process.
Jay Civellid4b89052017-10-31 17:48:2570// |connector| should be a fresh connector unbound to any thread.
pmonettea98315242016-11-23 21:39:1871using ConnectionErrorCallback = base::Closure;
72using IsPinnedToTaskbarCallback = base::Callback<void(bool, bool)>;
73void GetIsPinnedToTaskbarState(
Jay Civellid4b89052017-10-31 17:48:2574 std::unique_ptr<service_manager::Connector> connector,
pmonettea98315242016-11-23 21:39:1875 const ConnectionErrorCallback& on_error_callback,
76 const IsPinnedToTaskbarCallback& result_callback);
pmonette5057ca3b2016-07-04 16:48:4077
pmonette9e4c1a82016-04-14 18:15:3078// Migrates existing chrome taskbar pins by tagging them with correct app id.
79// see http://crbug.com/28104
80void MigrateTaskbarPins();
81
82// Migrates all shortcuts in |path| which point to |chrome_exe| such that they
83// have the appropriate AppUserModelId. Also clears the legacy dual_mode
84// property from shortcuts with the default chrome app id.
85// Returns the number of shortcuts migrated.
86// This method should not be called prior to Windows 7.
87// This method is only public for the sake of tests and shouldn't be called
88// externally otherwise.
89int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
90 const base::FilePath& path);
91
pmonette32a5cfb42016-04-11 22:04:4492} // namespace win
93} // namespace shell_integration
94
95#endif // CHROME_BROWSER_SHELL_INTEGRATION_WIN_H_