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_UBER_UBER_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_
10 #include "base/scoped_observer.h"
11 #include "base/values.h"
12 #include "content/public/browser/web_ui_controller.h"
13 #include "extensions/browser/extension_registry_observer.h"
19 namespace extensions
{
20 class ExtensionRegistry
;
23 // The WebUI class for the uber page (chrome://chrome). It manages the UI for
24 // the uber page (navigation bar and so forth) as well as WebUI objects for
25 // pages that appear in the uber page.
26 class UberUI
: public content::WebUIController
{
28 explicit UberUI(content::WebUI
* web_ui
);
31 content::WebUI
* GetSubpage(const std::string
& page_url
);
33 // WebUIController implementation.
34 bool OverrideHandleWebUIMessage(const GURL
& source_url
,
35 const std::string
& message
,
36 const base::ListValue
& args
) override
;
38 // We forward these to |sub_uis_|.
39 void RenderViewCreated(content::RenderViewHost
* render_view_host
) override
;
40 void RenderViewReused(content::RenderViewHost
* render_view_host
) override
;
43 // A map from URL origin to WebUI instance.
44 typedef std::map
<std::string
, content::WebUI
*> SubpageMap
;
46 // Creates and stores a WebUI for the given URL.
47 void RegisterSubpage(const std::string
& page_url
,
48 const std::string
& page_host
);
50 // The WebUI*s in this map are owned.
53 DISALLOW_COPY_AND_ASSIGN(UberUI
);
56 class UberFrameUI
: public content::WebUIController
,
57 public extensions::ExtensionRegistryObserver
{
59 explicit UberFrameUI(content::WebUI
* web_ui
);
60 ~UberFrameUI() override
;
63 // extensions::ExtensionRegistryObserver implementation.
64 void OnExtensionLoaded(content::BrowserContext
* browser_context
,
65 const extensions::Extension
* extension
) override
;
66 void OnExtensionUnloaded(
67 content::BrowserContext
* browser_context
,
68 const extensions::Extension
* extension
,
69 extensions::UnloadedExtensionInfo::Reason reason
) override
;
71 ScopedObserver
<extensions::ExtensionRegistry
,
72 extensions::ExtensionRegistryObserver
>
73 extension_registry_observer_
;
75 DISALLOW_COPY_AND_ASSIGN(UberFrameUI
);
78 #endif // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_