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" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, | 178 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, |
179 &min_height); | 179 &min_height); |
180 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 180 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
181 | 181 |
182 // Call SetAutoSize to apply all the appropriate validation and clipping of | 182 // Call SetAutoSize to apply all the appropriate validation and clipping of |
183 // values. | 183 // values. |
184 SetAutoSize( | 184 SetAutoSize( |
185 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); | 185 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); |
186 } | 186 } |
187 | 187 |
| 188 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { |
| 189 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( |
| 190 extension_options_internal::OnClose::kEventName, |
| 191 make_scoped_ptr(new base::DictionaryValue()))); |
| 192 } |
| 193 |
188 bool ExtensionOptionsGuest::ShouldCreateWebContents( | 194 bool ExtensionOptionsGuest::ShouldCreateWebContents( |
189 content::WebContents* web_contents, | 195 content::WebContents* web_contents, |
190 int route_id, | 196 int route_id, |
191 WindowContainerType window_container_type, | 197 WindowContainerType window_container_type, |
192 const base::string16& frame_name, | 198 const base::string16& frame_name, |
193 const GURL& target_url, | 199 const GURL& target_url, |
194 const std::string& partition_id, | 200 const std::string& partition_id, |
195 content::SessionStorageNamespace* session_storage_namespace) { | 201 content::SessionStorageNamespace* session_storage_namespace) { |
196 // This method handles opening links from within the guest. Since this guest | 202 // This method handles opening links from within the guest. Since this guest |
197 // view is used for displaying embedded extension options, we want any | 203 // view is used for displaying embedded extension options, we want any |
198 // external links to be opened in a new tab, not in a new guest view. | 204 // external links to be opened in a new tab, not in a new guest view. |
199 // Therefore we just open the URL in a new tab, and since we aren't handling | 205 // Therefore we just open the URL in a new tab, and since we aren't handling |
200 // the new web contents, we return false. | 206 // the new web contents, we return false. |
201 Browser* browser = | 207 Browser* browser = |
202 chrome::FindBrowserWithWebContents(embedder_web_contents()); | 208 chrome::FindBrowserWithWebContents(embedder_web_contents()); |
203 content::OpenURLParams params(target_url, | 209 content::OpenURLParams params(target_url, |
204 content::Referrer(), | 210 content::Referrer(), |
205 NEW_FOREGROUND_TAB, | 211 NEW_FOREGROUND_TAB, |
206 content::PAGE_TRANSITION_LINK, | 212 content::PAGE_TRANSITION_LINK, |
207 false); | 213 false); |
208 browser->OpenURL(params); | 214 browser->OpenURL(params); |
209 // TODO(ericzeng): Open the tab in the background if the click was a | 215 // TODO(ericzeng): Open the tab in the background if the click was a |
210 // ctrl-click or middle mouse button click | 216 // ctrl-click or middle mouse button click |
211 return false; | 217 return false; |
212 } | 218 } |
OLD | NEW |