OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/extensions/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void ExtensionDOMUI::ProcessDOMUIMessage(const std::string& message, | 58 void ExtensionDOMUI::ProcessDOMUIMessage(const std::string& message, |
59 const Value* content, | 59 const Value* content, |
60 int request_id, | 60 int request_id, |
61 bool has_callback) { | 61 bool has_callback) { |
62 extension_function_dispatcher_->HandleRequest(message, content, request_id, | 62 extension_function_dispatcher_->HandleRequest(message, content, request_id, |
63 has_callback); | 63 has_callback); |
64 } | 64 } |
65 | 65 |
66 Browser* ExtensionDOMUI::GetBrowser() { | 66 Browser* ExtensionDOMUI::GetBrowser() const { |
67 return static_cast<Browser*>(tab_contents()->delegate()); | 67 TabContentsDelegate* tab_contents_delegate = tab_contents()->delegate(); |
| 68 if (tab_contents_delegate) |
| 69 return tab_contents_delegate->GetBrowser(); |
| 70 return NULL; |
| 71 } |
| 72 |
| 73 Profile* ExtensionDOMUI::GetProfile() { |
| 74 return DOMUI::GetProfile(); |
| 75 } |
| 76 |
| 77 gfx::NativeWindow ExtensionDOMUI::GetFrameNativeWindow() { |
| 78 gfx::NativeWindow native_window = |
| 79 ExtensionFunctionDispatcher::Delegate::GetFrameNativeWindow(); |
| 80 |
| 81 // If there was no window associated with the function dispatcher delegate, |
| 82 // then this DOMUI may be hosted in an ExternalTabContainer, and a framing |
| 83 // window will be accessible through the tab_contents. |
| 84 if (!native_window) { |
| 85 TabContentsDelegate* tab_contents_delegate = tab_contents()->delegate(); |
| 86 if (tab_contents_delegate) |
| 87 native_window = tab_contents_delegate->GetFrameNativeWindow(); |
| 88 } |
| 89 |
| 90 return native_window; |
68 } | 91 } |
69 | 92 |
70 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
71 // chrome:// URL overrides | 94 // chrome:// URL overrides |
72 | 95 |
73 // static | 96 // static |
74 void ExtensionDOMUI::RegisterUserPrefs(PrefService* prefs) { | 97 void ExtensionDOMUI::RegisterUserPrefs(PrefService* prefs) { |
75 prefs->RegisterDictionaryPref(kExtensionURLOverrides); | 98 prefs->RegisterDictionaryPref(kExtensionURLOverrides); |
76 } | 99 } |
77 | 100 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // If it's being unregistered, it should already be in the list. | 262 // If it's being unregistered, it should already be in the list. |
240 NOTREACHED(); | 263 NOTREACHED(); |
241 continue; | 264 continue; |
242 } else { | 265 } else { |
243 StringValue override((*iter).second.spec()); | 266 StringValue override((*iter).second.spec()); |
244 UnregisterAndReplaceOverride((*iter).first, profile, | 267 UnregisterAndReplaceOverride((*iter).first, profile, |
245 page_overrides, &override); | 268 page_overrides, &override); |
246 } | 269 } |
247 } | 270 } |
248 } | 271 } |
OLD | NEW |