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_UBER_UBER_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // WebUIController implementation. | 51 // WebUIController implementation. |
52 bool OverrideHandleWebUIMessage(const GURL& source_url, | 52 bool OverrideHandleWebUIMessage(const GURL& source_url, |
53 const std::string& message, | 53 const std::string& message, |
54 const base::ListValue& args) override; | 54 const base::ListValue& args) override; |
55 | 55 |
56 // We forward these to |sub_uis_|. | 56 // We forward these to |sub_uis_|. |
57 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | 57 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
58 | 58 |
59 private: | 59 private: |
60 // A map from URL origin to WebUI instance. | |
61 typedef std::map<std::string, content::WebUI*> SubpageMap; | |
62 | |
63 // Creates and stores a WebUI for the given URL. | 60 // Creates and stores a WebUI for the given URL. |
64 void RegisterSubpage(const std::string& page_url, | 61 void RegisterSubpage(const std::string& page_url, |
65 const std::string& page_host); | 62 const std::string& page_host); |
66 | 63 |
67 SubframeLogger subframe_logger_; | 64 SubframeLogger subframe_logger_; |
68 | 65 |
69 // The WebUI*s in this map are owned. | 66 // Map from URL origin to WebUI instance. |
70 SubpageMap sub_uis_; | 67 std::map<std::string, std::unique_ptr<content::WebUI>> sub_uis_; |
71 | 68 |
72 DISALLOW_COPY_AND_ASSIGN(UberUI); | 69 DISALLOW_COPY_AND_ASSIGN(UberUI); |
73 }; | 70 }; |
74 | 71 |
75 class UberFrameUI : public content::WebUIController, | 72 class UberFrameUI : public content::WebUIController, |
76 public extensions::ExtensionRegistryObserver { | 73 public extensions::ExtensionRegistryObserver { |
77 public: | 74 public: |
78 explicit UberFrameUI(content::WebUI* web_ui); | 75 explicit UberFrameUI(content::WebUI* web_ui); |
79 ~UberFrameUI() override; | 76 ~UberFrameUI() override; |
80 | 77 |
81 private: | 78 private: |
82 // extensions::ExtensionRegistryObserver implementation. | 79 // extensions::ExtensionRegistryObserver implementation. |
83 void OnExtensionLoaded(content::BrowserContext* browser_context, | 80 void OnExtensionLoaded(content::BrowserContext* browser_context, |
84 const extensions::Extension* extension) override; | 81 const extensions::Extension* extension) override; |
85 void OnExtensionUnloaded( | 82 void OnExtensionUnloaded( |
86 content::BrowserContext* browser_context, | 83 content::BrowserContext* browser_context, |
87 const extensions::Extension* extension, | 84 const extensions::Extension* extension, |
88 extensions::UnloadedExtensionInfo::Reason reason) override; | 85 extensions::UnloadedExtensionInfo::Reason reason) override; |
89 | 86 |
90 ScopedObserver<extensions::ExtensionRegistry, | 87 ScopedObserver<extensions::ExtensionRegistry, |
91 extensions::ExtensionRegistryObserver> | 88 extensions::ExtensionRegistryObserver> |
92 extension_registry_observer_; | 89 extension_registry_observer_; |
93 | 90 |
94 DISALLOW_COPY_AND_ASSIGN(UberFrameUI); | 91 DISALLOW_COPY_AND_ASSIGN(UberFrameUI); |
95 }; | 92 }; |
96 | 93 |
97 #endif // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | 94 #endif // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ |
OLD | NEW |