Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / inspect_ui.h
blob1f73cf94efc562f3c5b4b064818f7f11d0dcae29
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_
8 #include <map>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/prefs/pref_change_registrar.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_ui_controller.h"
16 #include "content/public/browser/web_ui_data_source.h"
18 namespace base {
19 class Value;
20 class ListValue;
23 class Browser;
24 class DevToolsRemoteTargetsUIHandler;
25 class DevToolsTargetsUIHandler;
27 class InspectUI : public content::WebUIController,
28 public content::NotificationObserver {
29 public:
30 explicit InspectUI(content::WebUI* web_ui);
31 virtual ~InspectUI();
33 void InitUI();
34 void Inspect(const std::string& source_id, const std::string& target_id);
35 void Activate(const std::string& source_id, const std::string& target_id);
36 void Close(const std::string& source_id, const std::string& target_id);
37 void Reload(const std::string& source_id, const std::string& target_id);
38 void Open(const std::string& source_id,
39 const std::string& browser_id,
40 const std::string& url);
42 static void InspectDevices(Browser* browser);
44 private:
45 // content::NotificationObserver overrides.
46 virtual void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE;
50 void StartListeningNotifications();
51 void StopListeningNotifications();
53 content::WebUIDataSource* CreateInspectUIHTMLSource();
55 void UpdateDiscoverUsbDevicesEnabled();
56 void UpdatePortForwardingEnabled();
57 void UpdatePortForwardingConfig();
59 void SetPortForwardingDefaults();
61 const base::Value* GetPrefValue(const char* name);
63 void AddTargetUIHandler(
64 scoped_ptr<DevToolsTargetsUIHandler> handler);
65 void AddRemoteTargetUIHandler(
66 scoped_ptr<DevToolsRemoteTargetsUIHandler> handler);
68 DevToolsTargetsUIHandler* FindTargetHandler(const std::string& source_id);
69 DevToolsRemoteTargetsUIHandler* FindRemoteTargetHandler(
70 const std::string& source_id);
72 void PopulateTargets(const std::string& source_id,
73 scoped_ptr<base::ListValue> targets);
75 // A scoped container for notification registries.
76 content::NotificationRegistrar notification_registrar_;
78 // A scoped container for preference change registries.
79 PrefChangeRegistrar pref_change_registrar_;
81 typedef std::map<std::string, DevToolsTargetsUIHandler*> TargetHandlerMap;
82 TargetHandlerMap target_handlers_;
84 typedef std::map<std::string, DevToolsRemoteTargetsUIHandler*>
85 RemoteTargetHandlerMap;
86 RemoteTargetHandlerMap remote_target_handlers_;
88 DISALLOW_COPY_AND_ASSIGN(InspectUI);
91 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_