| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_dom_ui.h" | 5 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (browser_command_line.HasSwitch(switches::kChromeFrame)) | 139 if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
| 140 bindings_ |= BindingsPolicy::EXTERNAL_HOST; | 140 bindings_ |= BindingsPolicy::EXTERNAL_HOST; |
| 141 // For chrome:// overrides, some of the defaults are a little different. | 141 // For chrome:// overrides, some of the defaults are a little different. |
| 142 GURL effective_url = tab_contents->GetURL(); | 142 GURL effective_url = tab_contents->GetURL(); |
| 143 if (effective_url.SchemeIs(chrome::kChromeUIScheme) && | 143 if (effective_url.SchemeIs(chrome::kChromeUIScheme) && |
| 144 effective_url.host() == chrome::kChromeUINewTabHost) { | 144 effective_url.host() == chrome::kChromeUINewTabHost) { |
| 145 focus_location_bar_by_default_ = true; | 145 focus_location_bar_by_default_ = true; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 ExtensionDOMUI::~ExtensionDOMUI() {} |
| 150 |
| 149 void ExtensionDOMUI::ResetExtensionFunctionDispatcher( | 151 void ExtensionDOMUI::ResetExtensionFunctionDispatcher( |
| 150 RenderViewHost* render_view_host) { | 152 RenderViewHost* render_view_host) { |
| 151 // Use the NavigationController to get the URL rather than the TabContents | 153 // Use the NavigationController to get the URL rather than the TabContents |
| 152 // since this is the real underlying URL (see HandleChromeURLOverride). | 154 // since this is the real underlying URL (see HandleChromeURLOverride). |
| 153 NavigationController& controller = tab_contents()->controller(); | 155 NavigationController& controller = tab_contents()->controller(); |
| 154 const GURL& url = controller.GetActiveEntry()->url(); | 156 const GURL& url = controller.GetActiveEntry()->url(); |
| 155 extension_function_dispatcher_.reset( | 157 extension_function_dispatcher_.reset( |
| 156 ExtensionFunctionDispatcher::Create(render_view_host, this, url)); | 158 ExtensionFunctionDispatcher::Create(render_view_host, this, url)); |
| 157 DCHECK(extension_function_dispatcher_.get()); | 159 DCHECK(extension_function_dispatcher_.get()); |
| 158 } | 160 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 182 const ViewHostMsg_DomMessage_Params& params) { | 184 const ViewHostMsg_DomMessage_Params& params) { |
| 183 extension_function_dispatcher_->HandleRequest(params); | 185 extension_function_dispatcher_->HandleRequest(params); |
| 184 } | 186 } |
| 185 | 187 |
| 186 Browser* ExtensionDOMUI::GetBrowser() const { | 188 Browser* ExtensionDOMUI::GetBrowser() const { |
| 187 // TODO(beng): This is an improper direct dependency on Browser. Route this | 189 // TODO(beng): This is an improper direct dependency on Browser. Route this |
| 188 // through some sort of delegate. | 190 // through some sort of delegate. |
| 189 return BrowserList::FindBrowserWithProfile(DOMUI::GetProfile()); | 191 return BrowserList::FindBrowserWithProfile(DOMUI::GetProfile()); |
| 190 } | 192 } |
| 191 | 193 |
| 194 TabContents* ExtensionDOMUI::associated_tab_contents() const { |
| 195 return tab_contents(); |
| 196 } |
| 197 |
| 192 Profile* ExtensionDOMUI::GetProfile() { | 198 Profile* ExtensionDOMUI::GetProfile() { |
| 193 return DOMUI::GetProfile(); | 199 return DOMUI::GetProfile(); |
| 194 } | 200 } |
| 195 | 201 |
| 202 ExtensionBookmarkManagerEventRouter* |
| 203 ExtensionDOMUI::extension_bookmark_manager_event_router() { |
| 204 return extension_bookmark_manager_event_router_.get(); |
| 205 } |
| 206 |
| 196 gfx::NativeWindow ExtensionDOMUI::GetCustomFrameNativeWindow() { | 207 gfx::NativeWindow ExtensionDOMUI::GetCustomFrameNativeWindow() { |
| 197 if (GetBrowser()) | 208 if (GetBrowser()) |
| 198 return NULL; | 209 return NULL; |
| 199 | 210 |
| 200 // If there was no browser associated with the function dispatcher delegate, | 211 // If there was no browser associated with the function dispatcher delegate, |
| 201 // then this DOMUI may be hosted in an ExternalTabContainer, and a framing | 212 // then this DOMUI may be hosted in an ExternalTabContainer, and a framing |
| 202 // window will be accessible through the tab_contents. | 213 // window will be accessible through the tab_contents. |
| 203 TabContentsDelegate* tab_contents_delegate = tab_contents()->delegate(); | 214 TabContentsDelegate* tab_contents_delegate = tab_contents()->delegate(); |
| 204 if (tab_contents_delegate) | 215 if (tab_contents_delegate) |
| 205 return tab_contents_delegate->GetFrameNativeWindow(); | 216 return tab_contents_delegate->GetFrameNativeWindow(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 407 } |
| 397 | 408 |
| 398 // static | 409 // static |
| 399 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, | 410 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, |
| 400 FaviconService::GetFaviconRequest* request, const GURL& page_url) { | 411 FaviconService::GetFaviconRequest* request, const GURL& page_url) { |
| 401 // tracker deletes itself when done. | 412 // tracker deletes itself when done. |
| 402 ExtensionDOMUIImageLoadingTracker* tracker = | 413 ExtensionDOMUIImageLoadingTracker* tracker = |
| 403 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); | 414 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); |
| 404 tracker->Init(); | 415 tracker->Init(); |
| 405 } | 416 } |
| OLD | NEW |