Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/browser/ui/webui/uber/uber_ui.cc

Issue 9188056: Start splitting out WebUI into an implementation class and an interface that each page implements... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.h ('k') | chrome/browser/ui/webui/web_ui_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/webui/uber/uber_ui.h" 5 #include "chrome/browser/ui/webui/uber/uber_ui.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #if defined(OS_CHROMEOS) 43 #if defined(OS_CHROMEOS)
44 source->AddString("aboutPageHost", 44 source->AddString("aboutPageHost",
45 ASCIIToUTF16(chrome::kAboutOptionsSubPage)); 45 ASCIIToUTF16(chrome::kAboutOptionsSubPage));
46 source->AddLocalizedString("aboutPageDisplayName", IDS_ABOUT_TAB_TITLE); 46 source->AddLocalizedString("aboutPageDisplayName", IDS_ABOUT_TAB_TITLE);
47 #endif 47 #endif
48 return source; 48 return source;
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 UberUI::UberUI(WebContents* contents) : WebUI(contents) { 53 UberUI::UberUI(WebContents* contents) : WebUI(contents, this) {
54 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 54 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
55 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource()); 55 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource());
56 56
57 RegisterSubpage(chrome::kChromeUISettingsFrameURL); 57 RegisterSubpage(chrome::kChromeUISettingsFrameURL);
58 RegisterSubpage(chrome::kChromeUIExtensionsFrameURL); 58 RegisterSubpage(chrome::kChromeUIExtensionsFrameURL);
59 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
60 RegisterSubpage(chrome::kChromeUIAboutPageFrameURL); 60 RegisterSubpage(chrome::kChromeUIAboutPageFrameURL);
61 #endif 61 #endif
62 } 62 }
63 63
64 UberUI::~UberUI() { 64 UberUI::~UberUI() {
65 STLDeleteValues(&sub_uis_); 65 STLDeleteValues(&sub_uis_);
66 } 66 }
67 67
68 void UberUI::RegisterSubpage(const std::string& page_url) { 68 void UberUI::RegisterSubpage(const std::string& page_url) {
69 WebUI* web_ui = ChromeWebUIFactory::GetInstance()->CreateWebUIForURL( 69 WebUI* web_ui = ChromeWebUIFactory::GetInstance()->CreateWebUIForURL(
70 web_contents_, GURL(page_url)); 70 web_contents_, GURL(page_url));
71 71
72 web_ui->set_frame_xpath("//iframe[@src='" + page_url + "']"); 72 web_ui->set_frame_xpath("//iframe[@src='" + page_url + "']");
73 sub_uis_[page_url] = web_ui; 73 sub_uis_[page_url] = web_ui;
74 } 74 }
75 75
76 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { 76 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) {
77 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end(); 77 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end();
78 ++iter) { 78 ++iter) {
79 iter->second->RenderViewCreated(render_view_host); 79 iter->second->controller()->RenderViewCreated(render_view_host);
80 } 80 }
81
82 WebUI::RenderViewCreated(render_view_host);
83 } 81 }
84 82
85 void UberUI::RenderViewReused(RenderViewHost* render_view_host) { 83 void UberUI::RenderViewReused(RenderViewHost* render_view_host) {
86 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end(); 84 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end();
87 ++iter) { 85 ++iter) {
88 iter->second->RenderViewReused(render_view_host); 86 iter->second->controller()->RenderViewReused(render_view_host);
89 } 87 }
90
91 WebUI::RenderViewReused(render_view_host);
92 } 88 }
93 89
94 void UberUI::DidBecomeActiveForReusedRenderView() { 90 void UberUI::DidBecomeActiveForReusedRenderView() {
95 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end(); 91 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end();
96 ++iter) { 92 ++iter) {
97 iter->second->DidBecomeActiveForReusedRenderView(); 93 iter->second->controller()->DidBecomeActiveForReusedRenderView();
98 } 94 }
99
100 WebUI::DidBecomeActiveForReusedRenderView();
101 } 95 }
102 96
103 void UberUI::OnWebUISend(const GURL& source_url, 97 bool UberUI::OverrideHandleWebUIMessage(const GURL& source_url,
104 const std::string& message, 98 const std::string& message,
105 const ListValue& args) { 99 const ListValue& args) {
106 // Find the appropriate subpage and forward the message. 100 // Find the appropriate subpage and forward the message.
107 SubpageMap::iterator subpage = sub_uis_.find(source_url.GetOrigin().spec()); 101 SubpageMap::iterator subpage = sub_uis_.find(source_url.GetOrigin().spec());
108 if (subpage == sub_uis_.end()) { 102 if (subpage == sub_uis_.end()) {
109 // The message was sent from the uber page itself. 103 // The message was sent from the uber page itself.
110 DCHECK_EQ(std::string(chrome::kChromeUIUberHost), source_url.host()); 104 DCHECK_EQ(std::string(chrome::kChromeUIUberHost), source_url.host());
111 WebUI::OnWebUISend(source_url, message, args); 105 return false;
112 } else {
113 // The message was sent from a subpage.
114 subpage->second->OnWebUISend(source_url, message, args);
115 } 106 }
107
108 // The message was sent from a subpage.
109 return subpage->second->controller()->OverrideHandleWebUIMessage(
110 source_url, message, args);
116 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.h ('k') | chrome/browser/ui/webui/web_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698