Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / inspect_ui.h
blob2d3fc8dc02b81a1c7e5b19f49fed813dd40424f1
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 DevToolsTargetsUIHandler;
25 class DevToolsTargetImpl;
26 class PortForwardingStatusSerializer;
28 class InspectUI : public content::WebUIController,
29 public content::NotificationObserver {
30 public:
31 explicit InspectUI(content::WebUI* web_ui);
32 ~InspectUI() override;
34 void InitUI();
35 void Inspect(const std::string& source_id, const std::string& target_id);
36 void Activate(const std::string& source_id, const std::string& target_id);
37 void Close(const std::string& source_id, const std::string& target_id);
38 void Reload(const std::string& source_id, const std::string& target_id);
39 void Open(const std::string& source_id,
40 const std::string& browser_id,
41 const std::string& url);
42 void InspectBrowserWithCustomFrontend(
43 const std::string& source_id,
44 const std::string& browser_id,
45 const GURL& frontend_url);
47 static void InspectDevices(Browser* browser);
49 private:
50 // content::NotificationObserver overrides.
51 void Observe(int type,
52 const content::NotificationSource& source,
53 const content::NotificationDetails& details) override;
55 void StartListeningNotifications();
56 void StopListeningNotifications();
58 content::WebUIDataSource* CreateInspectUIHTMLSource();
60 void UpdateDiscoverUsbDevicesEnabled();
61 void UpdatePortForwardingEnabled();
62 void UpdatePortForwardingConfig();
64 void SetPortForwardingDefaults();
66 const base::Value* GetPrefValue(const char* name);
68 void AddTargetUIHandler(
69 scoped_ptr<DevToolsTargetsUIHandler> handler);
71 DevToolsTargetsUIHandler* FindTargetHandler(
72 const std::string& source_id);
73 DevToolsTargetImpl* FindTarget(const std::string& source_id,
74 const std::string& target_id);
76 void PopulateTargets(const std::string& source_id,
77 const base::ListValue& targets);
79 void ForceUpdateIfNeeded(const std::string& source_id,
80 const std::string& target_type);
82 void PopulatePortStatus(const base::Value& status);
84 void ShowIncognitoWarning();
86 // A scoped container for notification registries.
87 content::NotificationRegistrar notification_registrar_;
89 // A scoped container for preference change registries.
90 PrefChangeRegistrar pref_change_registrar_;
92 typedef std::map<std::string, DevToolsTargetsUIHandler*> TargetHandlerMap;
93 TargetHandlerMap target_handlers_;
95 scoped_ptr<PortForwardingStatusSerializer> port_status_serializer_;
97 DISALLOW_COPY_AND_ASSIGN(InspectUI);
100 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_