blob: e6debcc9031415dadb7526e0fbf4874e6b129993 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_TOOL_UI_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_POLICY_TOOL_UI_HANDLER_H_
#include "base/files/file_path.h"
#include "chrome/browser/ui/webui/policy_ui_handler.h"
class PolicyToolUIHandler : public PolicyUIHandler {
public:
PolicyToolUIHandler();
~PolicyToolUIHandler() override;
// content::WebUIMessageHandler implementation.
void RegisterMessages() override;
void OnJavascriptDisallowed() override;
private:
friend class PolicyToolUITest;
static const base::FilePath::CharType kPolicyToolSessionsDir[];
static const base::FilePath::CharType kPolicyToolDefaultSessionName[];
static const base::FilePath::CharType kPolicyToolSessionExtension[];
// Reads the current session file (based on the session_name_) and sends the
// contents to the UI.
void ImportFile();
void HandleInitializedAdmin(const base::ListValue* args);
void HandleLoadSession(const base::ListValue* args);
void HandleUpdateSession(const base::ListValue* args);
void HandleResetSession(const base::ListValue* args);
std::string ReadOrCreateFileCallback();
void OnFileRead(const std::string& contents);
bool DoUpdateSession(const std::string& contents);
void OnSessionUpdated(bool is_successful);
bool IsValidSessionName(const base::FilePath::StringType& name) const;
void ShowErrorMessageToUser(const std::string& message);
base::FilePath GetSessionPath(const base::FilePath::StringType& name) const;
// Returns the current list of all sessions sorted by last access time in
// decreasing order.
base::ListValue GetSessionsList();
void OnSessionsListReceived(base::ListValue list);
void SetDefaultSessionName();
bool is_saving_enabled_ = true;
base::FilePath sessions_dir_;
base::FilePath::StringType session_name_;
base::WeakPtrFactory<PolicyToolUIHandler> callback_weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PolicyToolUIHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_POLICY_TOOL_UI_HANDLER_H_
|