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

Side by Side Diff: chrome/browser/ui/webui/welcome_win10_handler.h

Issue 2633743002: Add GetIsPinnedToTaskbarState() (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_
7 7
8 #include <memory>
9 #include <string> 8 #include <string>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/optional.h" 12 #include "base/optional.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "chrome/common/shell_handler_win.mojom.h"
15 #include "content/public/browser/utility_process_mojo_client.h"
16 #include "content/public/browser/web_ui_message_handler.h" 14 #include "content/public/browser/web_ui_message_handler.h"
17 15
18 namespace base { 16 namespace base {
19 class ListValue; 17 class ListValue;
20 } 18 }
21 19
22 // Handles actions on the Windows 10 specific Welcome page. 20 // Handles actions on the Windows 10 specific Welcome page.
23 class WelcomeWin10Handler : public content::WebUIMessageHandler { 21 class WelcomeWin10Handler : public content::WebUIMessageHandler {
24 public: 22 public:
25 WelcomeWin10Handler(); 23 WelcomeWin10Handler();
26 ~WelcomeWin10Handler() override; 24 ~WelcomeWin10Handler() override;
27 25
28 // content::WebUIMessageHandler: 26 // content::WebUIMessageHandler:
29 void RegisterMessages() override; 27 void RegisterMessages() override;
30 28
31 private: 29 private:
32 // Handlers for javascript calls. 30 // Handlers for javascript calls.
33 void HandleGetPinnedToTaskbarState(const base::ListValue* args); 31 void HandleGetPinnedToTaskbarState(const base::ListValue* args);
34 void HandleSetDefaultBrowser(const base::ListValue* args); 32 void HandleSetDefaultBrowser(const base::ListValue* args);
35 void HandleContinue(const base::ListValue* args); 33 void HandleContinue(const base::ListValue* args);
36 34
37 void StartIsPinnedToTaskbarCheck(); 35 void StartIsPinnedToTaskbarCheck();
38 36
39 // Callback for mojom::ShellHandler's call to IsPinnedToTaskbar(). 37 // Callback for shell_integration::win::GetIsPinnedToTaskbarState().
40 void OnIsPinnedToTaskbarResult(bool succeeded, bool is_pinned_to_taskbar); 38 void OnIsPinnedToTaskbarResult(bool succeeded, bool is_pinned_to_taskbar);
41 39
42 // Sets the internal result and optionally call 40 // Sets the internal result and optionally call
43 // SendPinnedToTaskbarStateResult() in the case that 41 // SendPinnedToTaskbarStateResult() in the case that
44 // |pinned_state_callback_id_| is not empty. 42 // |pinned_state_callback_id_| is not empty.
45 void OnIsPinnedToTaskbarDetermined(bool is_pinned_to_taskbar); 43 void OnIsPinnedToTaskbarDetermined(bool is_pinned_to_taskbar);
46 44
47 // Returns the result to the getPinnedToTaskbarState() javascript call via the 45 // Returns the result to the getPinnedToTaskbarState() javascript call via the
48 // promise. 46 // promise.
49 void SendPinnedToTaskbarStateResult(); 47 void SendPinnedToTaskbarStateResult();
50 48
51 std::unique_ptr<content::UtilityProcessMojoClient<mojom::ShellHandler>>
52 client_;
53 base::OneShotTimer timer_; 49 base::OneShotTimer timer_;
54 50
55 // Acts as a cache to hold the taskbar pinned state of Chrome. It has no value 51 // Acts as a cache to hold the taskbar pinned state of Chrome. It has no value
56 // until this state is determined. 52 // until this state is determined.
57 base::Optional<bool> pinned_state_result_; 53 base::Optional<bool> pinned_state_result_;
58 54
59 // The callback id used to return the result to the getPinnedToTaskbarState() 55 // The callback id used to return the result to the getPinnedToTaskbarState()
60 // javascript call. This id is empty until we receive the call; thus this 56 // javascript call. This id is empty until we receive the call; thus this
61 // variable is used to determine if the result should be sent to the caller 57 // variable is used to determine if the result should be sent to the caller
62 // when it is received, or wait for the call to happen. 58 // when it is received, or wait for the call to happen.
63 std::string pinned_state_callback_id_; 59 std::string pinned_state_callback_id_;
64 60
61 base::WeakPtrFactory<WelcomeWin10Handler> weak_ptr_factory_;
62
65 DISALLOW_COPY_AND_ASSIGN(WelcomeWin10Handler); 63 DISALLOW_COPY_AND_ASSIGN(WelcomeWin10Handler);
66 }; 64 };
67 65
68 #endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ 66 #endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_win.cc ('k') | chrome/browser/ui/webui/welcome_win10_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698