| 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/memory/scoped_vector.h" |  10 #include "base/memory/scoped_vector.h" | 
|  11 #include "base/values.h" |  11 #include "base/values.h" | 
|  12 #include "chrome/browser/profiles/profile.h" |  12 #include "chrome/browser/profiles/profile.h" | 
|  13 #include "content/public/browser/notification_observer.h" |  13 #include "content/public/browser/notification_observer.h" | 
|  14 #include "content/public/browser/notification_registrar.h" |  14 #include "content/public/browser/notification_registrar.h" | 
|  15 #include "content/public/browser/web_ui_controller.h" |  15 #include "content/public/browser/web_ui_controller.h" | 
|  16  |  16  | 
|  17 // The WebUI class for the uber page (chrome://chrome). It manages the UI for |  17 // The WebUI class for the uber page (chrome://chrome). It manages the UI for | 
|  18 // the uber page (navigation bar and so forth) as well as WebUI objects for |  18 // the uber page (navigation bar and so forth) as well as WebUI objects for | 
|  19 // pages that appear in the uber page. |  19 // pages that appear in the uber page. | 
|  20 class UberUI : public content::WebUIController { |  20 class UberUI : public content::WebUIController { | 
|  21  public: |  21  public: | 
|  22   explicit UberUI(content::WebUI* web_ui); |  22   explicit UberUI(content::WebUI* web_ui); | 
|  23   virtual ~UberUI(); |  23   ~UberUI() override; | 
|  24  |  24  | 
|  25   content::WebUI* GetSubpage(const std::string& page_url); |  25   content::WebUI* GetSubpage(const std::string& page_url); | 
|  26  |  26  | 
|  27   // WebUIController implementation. |  27   // WebUIController implementation. | 
|  28   virtual bool OverrideHandleWebUIMessage(const GURL& source_url, |  28   bool OverrideHandleWebUIMessage(const GURL& source_url, | 
|  29                                           const std::string& message, |  29                                   const std::string& message, | 
|  30                                           const base::ListValue& args) override; |  30                                   const base::ListValue& args) override; | 
|  31  |  31  | 
|  32   // We forward these to |sub_uis_|. |  32   // We forward these to |sub_uis_|. | 
|  33   virtual void RenderViewCreated( |  33   void RenderViewCreated(content::RenderViewHost* render_view_host) override; | 
|  34       content::RenderViewHost* render_view_host) override; |  34   void RenderViewReused(content::RenderViewHost* render_view_host) override; | 
|  35   virtual void RenderViewReused( |  | 
|  36       content::RenderViewHost* render_view_host) override; |  | 
|  37  |  35  | 
|  38  private: |  36  private: | 
|  39   // A map from URL origin to WebUI instance. |  37   // A map from URL origin to WebUI instance. | 
|  40   typedef std::map<std::string, content::WebUI*> SubpageMap; |  38   typedef std::map<std::string, content::WebUI*> SubpageMap; | 
|  41  |  39  | 
|  42   // Creates and stores a WebUI for the given URL. |  40   // Creates and stores a WebUI for the given URL. | 
|  43   void RegisterSubpage(const std::string& page_url, |  41   void RegisterSubpage(const std::string& page_url, | 
|  44                        const std::string& page_host); |  42                        const std::string& page_host); | 
|  45  |  43  | 
|  46   // The WebUI*s in this map are owned. |  44   // The WebUI*s in this map are owned. | 
|  47   SubpageMap sub_uis_; |  45   SubpageMap sub_uis_; | 
|  48  |  46  | 
|  49   DISALLOW_COPY_AND_ASSIGN(UberUI); |  47   DISALLOW_COPY_AND_ASSIGN(UberUI); | 
|  50 }; |  48 }; | 
|  51  |  49  | 
|  52 class UberFrameUI : public content::NotificationObserver, |  50 class UberFrameUI : public content::NotificationObserver, | 
|  53                     public content::WebUIController { |  51                     public content::WebUIController { | 
|  54  public: |  52  public: | 
|  55   explicit UberFrameUI(content::WebUI* web_ui); |  53   explicit UberFrameUI(content::WebUI* web_ui); | 
|  56   virtual ~UberFrameUI(); |  54   ~UberFrameUI() override; | 
|  57  |  55  | 
|  58  private: |  56  private: | 
|  59   // content::NotificationObserver implementation. |  57   // content::NotificationObserver implementation. | 
|  60   virtual void Observe(int type, |  58   void Observe(int type, | 
|  61                        const content::NotificationSource& source, |  59                const content::NotificationSource& source, | 
|  62                        const content::NotificationDetails& details) override; |  60                const content::NotificationDetails& details) override; | 
|  63  |  61  | 
|  64   content::NotificationRegistrar registrar_; |  62   content::NotificationRegistrar registrar_; | 
|  65  |  63  | 
|  66   DISALLOW_COPY_AND_ASSIGN(UberFrameUI); |  64   DISALLOW_COPY_AND_ASSIGN(UberFrameUI); | 
|  67 }; |  65 }; | 
|  68  |  66  | 
|  69 #endif  // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ |  67 #endif  // CHROME_BROWSER_UI_WEBUI_UBER_UBER_UI_H_ | 
| OLD | NEW |