OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/values.h" | |
12 #include "content/public/browser/web_contents_observer.h" | |
13 #include "content/public/browser/web_ui_controller.h" | |
14 | |
15 // Logs visits to subframe URLs (e.g. chrome://settings-frame). | |
16 class SubframeLogger : public content::WebContentsObserver { | |
17 public: | |
18 explicit SubframeLogger(content::WebContents* contents); | |
19 ~SubframeLogger() override; | |
20 | |
21 // content::WebContentsObserver implementation. | |
22 void DidFinishNavigation( | |
23 content::NavigationHandle* navigation_handle) override; | |
24 | |
25 private: | |
26 DISALLOW_COPY_AND_ASSIGN(SubframeLogger); | |
27 }; | |
28 | |
29 // The WebUI class for the uber page (chrome://chrome). It manages the UI for | |
30 // the uber page (navigation bar and so forth) as well as WebUI objects for | |
31 // pages that appear in the uber page. | |
32 class UberUI : public content::WebUIController { | |
33 public: | |
34 explicit UberUI(content::WebUI* web_ui); | |
35 ~UberUI() override; | |
36 | |
37 content::WebUI* GetSubpage(const std::string& page_url); | |
38 | |
39 // WebUIController implementation. | |
40 bool OverrideHandleWebUIMessage(const GURL& source_url, | |
41 const std::string& message, | |
42 const base::ListValue& args) override; | |
43 | |
44 // We forward these to |sub_uis_|. | |
45 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | |
46 | |
47 private: | |
48 // Creates and stores a WebUI for the given URL. | |
49 void RegisterSubpage(const std::string& page_url, | |
50 const std::string& page_host); | |
51 | |
52 std::unique_ptr<SubframeLogger> subframe_logger_; | |
53 | |
54 // Map from URL origin to WebUI instance. | |
55 std::map<std::string, std::unique_ptr<content::WebUI>> sub_uis_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(UberUI); | |
58 }; | |
59 | |
60 class UberFrameUI : public content::WebUIController { | |
61 public: | |
62 explicit UberFrameUI(content::WebUI* web_ui); | |
63 ~UberFrameUI() override; | |
64 }; | |
65 | |
66 #endif // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | |
OLD | NEW |