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 #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 "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Determines whether the user has an active extension of the given type. | 66 // Determines whether the user has an active extension of the given type. |
67 bool HasExtensionType(content::BrowserContext* browser_context, | 67 bool HasExtensionType(content::BrowserContext* browser_context, |
68 const std::string& extension_type) { | 68 const std::string& extension_type) { |
69 const extensions::ExtensionSet& extension_set = | 69 const extensions::ExtensionSet& extension_set = |
70 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions(); | 70 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions(); |
71 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); | 71 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); |
72 iter != extension_set.end(); ++iter) { | 72 iter != extension_set.end(); ++iter) { |
73 const extensions::URLOverrides::URLOverrideMap& map = | 73 const extensions::URLOverrides::URLOverrideMap& map = |
74 extensions::URLOverrides::GetChromeURLOverrides(iter->get()); | 74 extensions::URLOverrides::GetChromeURLOverrides(iter->get()); |
75 if (ContainsKey(map, extension_type)) | 75 if (base::ContainsKey(map, extension_type)) |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 return false; | 79 return false; |
80 } | 80 } |
81 | 81 |
82 content::WebUIDataSource* CreateUberFrameHTMLSource( | 82 content::WebUIDataSource* CreateUberFrameHTMLSource( |
83 content::BrowserContext* browser_context) { | 83 content::BrowserContext* browser_context) { |
84 content::WebUIDataSource* source = | 84 content::WebUIDataSource* source = |
85 content::WebUIDataSource::Create(chrome::kChromeUIUberFrameHost); | 85 content::WebUIDataSource::Create(chrome::kChromeUIUberFrameHost); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 chrome::kChromeUIHelpHost); | 168 chrome::kChromeUIHelpHost); |
169 RegisterSubpage(chrome::kChromeUIHistoryFrameURL, | 169 RegisterSubpage(chrome::kChromeUIHistoryFrameURL, |
170 chrome::kChromeUIHistoryHost); | 170 chrome::kChromeUIHistoryHost); |
171 RegisterSubpage(chrome::kChromeUISettingsFrameURL, | 171 RegisterSubpage(chrome::kChromeUISettingsFrameURL, |
172 chrome::kChromeUISettingsHost); | 172 chrome::kChromeUISettingsHost); |
173 RegisterSubpage(chrome::kChromeUIUberFrameURL, | 173 RegisterSubpage(chrome::kChromeUIUberFrameURL, |
174 chrome::kChromeUIUberHost); | 174 chrome::kChromeUIUberHost); |
175 } | 175 } |
176 | 176 |
177 UberUI::~UberUI() { | 177 UberUI::~UberUI() { |
178 STLDeleteValues(&sub_uis_); | 178 base::STLDeleteValues(&sub_uis_); |
179 } | 179 } |
180 | 180 |
181 void UberUI::RegisterSubpage(const std::string& page_url, | 181 void UberUI::RegisterSubpage(const std::string& page_url, |
182 const std::string& page_host) { | 182 const std::string& page_host) { |
183 sub_uis_[page_url] = web_ui()->GetWebContents()->CreateSubframeWebUI( | 183 sub_uis_[page_url] = web_ui()->GetWebContents()->CreateSubframeWebUI( |
184 GURL(page_url), page_host); | 184 GURL(page_url), page_host); |
185 } | 185 } |
186 | 186 |
187 content::WebUI* UberUI::GetSubpage(const std::string& page_url) { | 187 content::WebUI* UberUI::GetSubpage(const std::string& page_url) { |
188 if (!ContainsKey(sub_uis_, page_url)) | 188 if (!base::ContainsKey(sub_uis_, page_url)) |
189 return NULL; | 189 return NULL; |
190 return sub_uis_[page_url]; | 190 return sub_uis_[page_url]; |
191 } | 191 } |
192 | 192 |
193 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { | 193 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { |
194 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end(); | 194 for (SubpageMap::iterator iter = sub_uis_.begin(); iter != sub_uis_.end(); |
195 ++iter) { | 195 ++iter) { |
196 iter->second->GetController()->RenderViewCreated(render_view_host); | 196 iter->second->GetController()->RenderViewCreated(render_view_host); |
197 } | 197 } |
198 } | 198 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // opens the default history page if one is uninstalled or disabled. | 244 // opens the default history page if one is uninstalled or disabled. |
245 UpdateHistoryNavigation(web_ui()); | 245 UpdateHistoryNavigation(web_ui()); |
246 } | 246 } |
247 | 247 |
248 void UberFrameUI::OnExtensionUnloaded( | 248 void UberFrameUI::OnExtensionUnloaded( |
249 content::BrowserContext* browser_context, | 249 content::BrowserContext* browser_context, |
250 const extensions::Extension* extension, | 250 const extensions::Extension* extension, |
251 extensions::UnloadedExtensionInfo::Reason reason) { | 251 extensions::UnloadedExtensionInfo::Reason reason) { |
252 UpdateHistoryNavigation(web_ui()); | 252 UpdateHistoryNavigation(web_ui()); |
253 } | 253 } |
OLD | NEW |