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 "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 11 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" |
12 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 12 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
13 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 13 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
14 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" | 14 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" |
15 #include "chrome/browser/ui/webui/options2/options_ui2.h" | 15 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_set.h" | 18 #include "chrome/common/extensions/extension_set.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 source->AddString("overridesHistory", | 116 source->AddString("overridesHistory", |
117 ASCIIToUTF16(overridesHistory ? "yes" : "no")); | 117 ASCIIToUTF16(overridesHistory ? "yes" : "no")); |
118 | 118 |
119 return source; | 119 return source; |
120 } | 120 } |
121 | 121 |
122 } // namespace | 122 } // namespace |
123 | 123 |
124 UberUI::UberUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 124 UberUI::UberUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
125 Profile* profile = Profile::FromWebUI(web_ui); | 125 Profile* profile = Profile::FromWebUI(web_ui); |
126 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource()); | 126 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
| 127 AddDataSource(CreateUberHTMLSource()); |
127 | 128 |
128 // The user may use a virtual (short) URL to get to the page. To avoid | 129 // The user may use a virtual (short) URL to get to the page. To avoid |
129 // duplicate uber tabs, clear the virtual URL so that the omnibox will show | 130 // duplicate uber tabs, clear the virtual URL so that the omnibox will show |
130 // the real URL. http://crbug.com/111878. | 131 // the real URL. http://crbug.com/111878. |
131 NavigationController* controller = &web_ui->GetWebContents()->GetController(); | 132 NavigationController* controller = &web_ui->GetWebContents()->GetController(); |
132 NavigationEntry* pending_entry = controller->GetPendingEntry(); | 133 NavigationEntry* pending_entry = controller->GetPendingEntry(); |
133 if (pending_entry && !pending_entry->IsViewSourceMode()) | 134 if (pending_entry && !pending_entry->IsViewSourceMode()) |
134 pending_entry->SetVirtualURL(GURL()); | 135 pending_entry->SetVirtualURL(GURL()); |
135 | 136 |
136 RegisterSubpage(chrome::kChromeUIExtensionsFrameURL); | 137 RegisterSubpage(chrome::kChromeUIExtensionsFrameURL); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // return subpage->second->GetController()->OverrideHandleWebUIMessage( | 190 // return subpage->second->GetController()->OverrideHandleWebUIMessage( |
190 // source_url, message, args); | 191 // source_url, message, args); |
191 subpage->second->ProcessWebUIMessage(source_url, message, args); | 192 subpage->second->ProcessWebUIMessage(source_url, message, args); |
192 return true; | 193 return true; |
193 } | 194 } |
194 | 195 |
195 // UberFrameUI | 196 // UberFrameUI |
196 | 197 |
197 UberFrameUI::UberFrameUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 198 UberFrameUI::UberFrameUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
198 Profile* profile = Profile::FromWebUI(web_ui); | 199 Profile* profile = Profile::FromWebUI(web_ui); |
199 profile->GetChromeURLDataManager()->AddDataSource( | 200 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
200 CreateUberFrameHTMLSource(profile)); | 201 AddDataSource(CreateUberFrameHTMLSource(profile)); |
201 | 202 |
202 // Register as an observer for when extensions are loaded and unloaded. | 203 // Register as an observer for when extensions are loaded and unloaded. |
203 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 204 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
204 content::Source<Profile>(profile)); | 205 content::Source<Profile>(profile)); |
205 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 206 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
206 content::Source<Profile>(profile)); | 207 content::Source<Profile>(profile)); |
207 } | 208 } |
208 | 209 |
209 UberFrameUI::~UberFrameUI() { | 210 UberFrameUI::~UberFrameUI() { |
210 } | 211 } |
(...skipping 17 matching lines...) Expand all Loading... |
228 scoped_ptr<Value> overrideValue( | 229 scoped_ptr<Value> overrideValue( |
229 Value::CreateStringValue(overridesHistory ? "yes" : "no")); | 230 Value::CreateStringValue(overridesHistory ? "yes" : "no")); |
230 web_ui()->CallJavascriptFunction( | 231 web_ui()->CallJavascriptFunction( |
231 "uber_frame.setNavigationOverride", *controlsValue, *overrideValue); | 232 "uber_frame.setNavigationOverride", *controlsValue, *overrideValue); |
232 break; | 233 break; |
233 } | 234 } |
234 default: | 235 default: |
235 NOTREACHED(); | 236 NOTREACHED(); |
236 } | 237 } |
237 } | 238 } |
OLD | NEW |