OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/guest_view/extension_options/extension_options_guest.h" | 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" | 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/common/extensions/api/extension_options_internal.h" | 17 #include "chrome/common/extensions/api/extension_options_internal.h" |
18 #include "chrome/common/extensions/manifest_url_handler.h" | 18 #include "chrome/common/extensions/manifest_url_handler.h" |
19 #include "components/crx_file/id_util.h" | 19 #include "components/crx_file/id_util.h" |
20 #include "components/renderer_context_menu/context_menu_delegate.h" | 20 #include "components/renderer_context_menu/context_menu_delegate.h" |
21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/site_instance.h" | 22 #include "content/public/browser/site_instance.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "extensions/browser/extension_function_dispatcher.h" | 24 #include "extensions/browser/extension_function_dispatcher.h" |
25 #include "extensions/browser/extension_registry.h" | 25 #include "extensions/browser/extension_registry.h" |
26 #include "extensions/browser/guest_view/guest_view_manager.h" | 26 #include "extensions/browser/guest_view/guest_view_manager.h" |
27 #include "extensions/common/constants.h" | |
27 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
28 #include "extensions/common/extension_messages.h" | 29 #include "extensions/common/extension_messages.h" |
29 #include "extensions/common/feature_switch.h" | 30 #include "extensions/common/feature_switch.h" |
30 #include "extensions/common/permissions/permissions_data.h" | 31 #include "extensions/common/permissions/permissions_data.h" |
31 #include "extensions/strings/grit/extensions_strings.h" | 32 #include "extensions/strings/grit/extensions_strings.h" |
32 #include "ipc/ipc_message_macros.h" | 33 #include "ipc/ipc_message_macros.h" |
33 | 34 |
34 using content::WebContents; | 35 using content::WebContents; |
35 using namespace extensions::api; | 36 using namespace extensions::api; |
36 | 37 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 } | 149 } |
149 | 150 |
150 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { | 151 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { |
151 return true; | 152 return true; |
152 } | 153 } |
153 | 154 |
154 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { | 155 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { |
155 return web_contents(); | 156 return web_contents(); |
156 } | 157 } |
157 | 158 |
159 content::WebContents* ExtensionOptionsGuest::OpenURLFromTab( | |
160 content::WebContents* source, | |
161 const content::OpenURLParams& params) { | |
162 Browser* browser = | |
163 chrome::FindBrowserWithWebContents(embedder_web_contents()); | |
164 | |
165 if ((!params.url.SchemeIs(extensions::kExtensionScheme) || | |
Fady Samuel
2014/09/05 21:11:57
Some comments describing what you're doing would b
ericzeng
2014/09/05 21:17:19
Done.
| |
166 params.url.host() != options_page_.host()) && | |
167 params.disposition == CURRENT_TAB) { | |
Fady Samuel
2014/09/05 21:11:57
Early exit preferred for readability.
ericzeng
2014/09/05 21:17:19
How do I early exit for this condition? Wouldn't f
Fady Samuel
2014/09/05 21:18:01
You're probably right...lgtm
| |
168 return browser->OpenURL( | |
169 content::OpenURLParams(params.url, | |
170 params.referrer, | |
171 params.frame_tree_node_id, | |
172 NEW_FOREGROUND_TAB, | |
173 params.transition, | |
174 params.is_renderer_initiated)); | |
175 } | |
176 return browser->OpenURL(params); | |
177 } | |
178 | |
158 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { | 179 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { |
159 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( | 180 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( |
160 extension_options_internal::OnClose::kEventName, | 181 extension_options_internal::OnClose::kEventName, |
161 make_scoped_ptr(new base::DictionaryValue()))); | 182 make_scoped_ptr(new base::DictionaryValue()))); |
162 } | 183 } |
163 | 184 |
164 bool ExtensionOptionsGuest::HandleContextMenu( | 185 bool ExtensionOptionsGuest::HandleContextMenu( |
165 const content::ContextMenuParams& params) { | 186 const content::ContextMenuParams& params) { |
166 ContextMenuDelegate* menu_delegate = | 187 ContextMenuDelegate* menu_delegate = |
167 ContextMenuDelegate::FromWebContents(web_contents()); | 188 ContextMenuDelegate::FromWebContents(web_contents()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, | 252 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, |
232 &min_height); | 253 &min_height); |
233 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 254 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
234 | 255 |
235 // Call SetAutoSize to apply all the appropriate validation and clipping of | 256 // Call SetAutoSize to apply all the appropriate validation and clipping of |
236 // values. | 257 // values. |
237 SetAutoSize(auto_size_enabled, | 258 SetAutoSize(auto_size_enabled, |
238 gfx::Size(min_width, min_height), | 259 gfx::Size(min_width, min_height), |
239 gfx::Size(max_width, max_height)); | 260 gfx::Size(max_width, max_height)); |
240 } | 261 } |
OLD | NEW |