| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_INSPECT_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| 7 | 7 |
| 8 #include <map> |
| 9 |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/devtools/devtools_adb_bridge.h" |
| 9 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 11 #include "content/public/browser/web_ui_controller.h" | 15 #include "content/public/browser/web_ui_controller.h" |
| 16 #include "content/public/browser/web_ui_data_source.h" |
| 12 | 17 |
| 13 class InspectUI : public content::WebUIController, | 18 class InspectUI : public content::WebUIController, |
| 14 public content::NotificationObserver { | 19 public content::NotificationObserver { |
| 15 public: | 20 public: |
| 16 explicit InspectUI(content::WebUI* web_ui); | 21 explicit InspectUI(content::WebUI* web_ui); |
| 17 virtual ~InspectUI(); | 22 virtual ~InspectUI(); |
| 18 | 23 |
| 19 void RefreshUI(); | 24 void RefreshUI(); |
| 20 | 25 |
| 21 private: | 26 private: |
| 22 class WorkerCreationDestructionListener; | 27 class WorkerCreationDestructionListener; |
| 23 | 28 |
| 29 static bool WeakHandleRequestCallback( |
| 30 const base::WeakPtr<InspectUI>& inspect_ui, |
| 31 const std::string& path, |
| 32 const content::WebUIDataSource::GotDataCallback& callback); |
| 33 |
| 24 // content::NotificationObserver overrides. | 34 // content::NotificationObserver overrides. |
| 25 virtual void Observe(int type, | 35 virtual void Observe(int type, |
| 26 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
| 27 const content::NotificationDetails& details) OVERRIDE; | 37 const content::NotificationDetails& details) OVERRIDE; |
| 28 | 38 |
| 29 void StopListeningNotifications(); | 39 void StopListeningNotifications(); |
| 30 | 40 |
| 41 content::WebUIDataSource* CreateInspectUIHTMLSource(); |
| 42 |
| 43 bool HandleRequestCallback( |
| 44 const std::string& path, |
| 45 const content::WebUIDataSource::GotDataCallback& callback); |
| 46 |
| 47 bool HandleAdbQueryCallback( |
| 48 const std::string& path, |
| 49 const content::WebUIDataSource::GotDataCallback& callback); |
| 50 |
| 51 bool HandleLocalXhrCallback( |
| 52 const std::string& path, |
| 53 const content::WebUIDataSource::GotDataCallback& callback); |
| 54 |
| 55 void RespondOnUIThread( |
| 56 const content::WebUIDataSource::GotDataCallback& callback, |
| 57 const std::string& error, |
| 58 const std::string& data); |
| 59 |
| 60 |
| 31 scoped_refptr<WorkerCreationDestructionListener> observer_; | 61 scoped_refptr<WorkerCreationDestructionListener> observer_; |
| 32 | 62 |
| 33 // A scoped container for notification registries. | 63 // A scoped container for notification registries. |
| 34 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
| 35 | 65 |
| 66 scoped_refptr<DevToolsAdbBridge> adb_bridge_; |
| 67 base::WeakPtrFactory<InspectUI> weak_factory_; |
| 68 |
| 36 DISALLOW_COPY_AND_ASSIGN(InspectUI); | 69 DISALLOW_COPY_AND_ASSIGN(InspectUI); |
| 37 }; | 70 }; |
| 38 | 71 |
| 39 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ | 72 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| OLD | NEW |