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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Copyright (c) 2012 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_INSPECT_UI_H_
#define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_
#include <map>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
namespace base {
class Value;
class ListValue;
}
class Browser;
class DevToolsTargetsUIHandler;
class DevToolsTargetImpl;
class PortForwardingStatusSerializer;
class InspectUI : public content::WebUIController,
public content::NotificationObserver {
public:
explicit InspectUI(content::WebUI* web_ui);
virtual ~InspectUI();
void InitUI();
void Inspect(const std::string& source_id, const std::string& target_id);
void Activate(const std::string& source_id, const std::string& target_id);
void Close(const std::string& source_id, const std::string& target_id);
void Reload(const std::string& source_id, const std::string& target_id);
void Open(const std::string& source_id,
const std::string& browser_id,
const std::string& url);
void InspectBrowserWithCustomFrontend(
const std::string& source_id,
const std::string& browser_id,
const GURL& frontend_url);
static void InspectDevices(Browser* browser);
// WebUIController implementation.
virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
const std::string& message,
const base::ListValue& args) OVERRIDE;
// We forward these to |serviceworker_webui_|.
virtual void RenderViewCreated(
content::RenderViewHost* render_view_host) OVERRIDE;
virtual void RenderViewReused(
content::RenderViewHost* render_view_host) OVERRIDE;
private:
// content::NotificationObserver overrides.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
void StartListeningNotifications();
void StopListeningNotifications();
content::WebUIDataSource* CreateInspectUIHTMLSource();
void UpdateDiscoverUsbDevicesEnabled();
void UpdatePortForwardingEnabled();
void UpdatePortForwardingConfig();
void SetPortForwardingDefaults();
const base::Value* GetPrefValue(const char* name);
void AddTargetUIHandler(
scoped_ptr<DevToolsTargetsUIHandler> handler);
DevToolsTargetsUIHandler* FindTargetHandler(
const std::string& source_id);
DevToolsTargetImpl* FindTarget(const std::string& source_id,
const std::string& target_id);
void PopulateTargets(const std::string& source_id,
const base::ListValue& targets);
void PopulatePortStatus(const base::Value& status);
void ShowIncognitoWarning();
// A scoped container for notification registries.
content::NotificationRegistrar notification_registrar_;
// A scoped container for preference change registries.
PrefChangeRegistrar pref_change_registrar_;
typedef std::map<std::string, DevToolsTargetsUIHandler*> TargetHandlerMap;
TargetHandlerMap target_handlers_;
scoped_ptr<PortForwardingStatusSerializer> port_status_serializer_;
scoped_ptr<content::WebUI> serviceworker_webui_;
DISALLOW_COPY_AND_ASSIGN(InspectUI);
};
#endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_
|