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_popup_api.h" | 5 #include "chrome/browser/extensions/extension_popup_api.h" |
6 | 6 |
7 #include "base/gfx/point.h" | 7 #include "base/gfx/point.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/common/notification_details.h" | 11 #include "chrome/common/notification_details.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
13 #include "chrome/common/notification_source.h" | 13 #include "chrome/common/notification_source.h" |
14 #include "chrome/common/notification_type.h" | 14 #include "chrome/common/notification_type.h" |
| 15 #include "chrome/common/url_constants.h" |
15 #include "chrome/browser/extensions/extension_dom_ui.h" | 16 #include "chrome/browser/extensions/extension_dom_ui.h" |
16 #include "chrome/browser/extensions/extension_host.h" | 17 #include "chrome/browser/extensions/extension_host.h" |
17 #include "chrome/browser/extensions/extension_message_service.h" | 18 #include "chrome/browser/extensions/extension_message_service.h" |
18 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
21 #if defined(TOOLKIT_VIEWS) | 22 #if defined(TOOLKIT_VIEWS) |
22 #include "chrome/browser/views/extensions/extension_popup.h" | 23 #include "chrome/browser/views/extensions/extension_popup.h" |
23 #include "views/view.h" | 24 #include "views/view.h" |
24 #endif | 25 #endif |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 GURL url = dispatcher()->url().Resolve(url_string); | 131 GURL url = dispatcher()->url().Resolve(url_string); |
131 if (!url.is_valid()) { | 132 if (!url.is_valid()) { |
132 error_ = kInvalidURLError; | 133 error_ = kInvalidURLError; |
133 return false; | 134 return false; |
134 } | 135 } |
135 | 136 |
136 // Disallow non-extension requests, or requests outside of the requesting | 137 // Disallow non-extension requests, or requests outside of the requesting |
137 // extension view's extension. | 138 // extension view's extension. |
138 const std::string& extension_id = url.host(); | 139 const std::string& extension_id = url.host(); |
139 if (extension_id != dispatcher()->GetExtension()->id() || | 140 if (extension_id != dispatcher()->GetExtension()->id() || |
140 !url.SchemeIs("chrome-extension")) { | 141 !url.SchemeIs(chrome::kExtensionScheme)) { |
141 error_ = kInvalidURLError; | 142 error_ = kInvalidURLError; |
142 return false; | 143 return false; |
143 } | 144 } |
144 | 145 |
145 #if defined(TOOLKIT_VIEWS) | 146 #if defined(TOOLKIT_VIEWS) |
146 gfx::Point origin(dom_left, dom_top); | 147 gfx::Point origin(dom_left, dom_top); |
147 if (!ConvertHostPointToScreen(&origin)) { | 148 if (!ConvertHostPointToScreen(&origin)) { |
148 error_ = kNotAnExtension; | 149 error_ = kNotAnExtension; |
149 return false; | 150 return false; |
150 } | 151 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 int routing_id) { | 235 int routing_id) { |
235 std::string full_event_name = StringPrintf( | 236 std::string full_event_name = StringPrintf( |
236 extension_popup_module_events::kOnPopupClosed, | 237 extension_popup_module_events::kOnPopupClosed, |
237 routing_id); | 238 routing_id); |
238 | 239 |
239 profile->GetExtensionMessageService()->DispatchEventToRenderers( | 240 profile->GetExtensionMessageService()->DispatchEventToRenderers( |
240 full_event_name, | 241 full_event_name, |
241 base::JSONWriter::kEmptyArray, | 242 base::JSONWriter::kEmptyArray, |
242 profile->IsOffTheRecord()); | 243 profile->IsOffTheRecord()); |
243 } | 244 } |
OLD | NEW |