Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: chrome/browser/guest_view/extension_options/extension_options_guest.cc

Issue 546073003: Embedded Extension Options: Open all external links in a new tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/guest_view/extension_options/extension_options_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Don't allow external URLs with the CURRENT_TAB disposition be opened in
166 // this guest view, change the disposition to NEW_FOREGROUND_TAB.
167 if ((!params.url.SchemeIs(extensions::kExtensionScheme) ||
168 params.url.host() != options_page_.host()) &&
169 params.disposition == CURRENT_TAB) {
170 return browser->OpenURL(
171 content::OpenURLParams(params.url,
172 params.referrer,
173 params.frame_tree_node_id,
174 NEW_FOREGROUND_TAB,
175 params.transition,
176 params.is_renderer_initiated));
177 }
178 return browser->OpenURL(params);
179 }
180
158 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { 181 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) {
159 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 182 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
160 extension_options_internal::OnClose::kEventName, 183 extension_options_internal::OnClose::kEventName,
161 make_scoped_ptr(new base::DictionaryValue()))); 184 make_scoped_ptr(new base::DictionaryValue())));
162 } 185 }
163 186
164 bool ExtensionOptionsGuest::HandleContextMenu( 187 bool ExtensionOptionsGuest::HandleContextMenu(
165 const content::ContextMenuParams& params) { 188 const content::ContextMenuParams& params) {
166 ContextMenuDelegate* menu_delegate = 189 ContextMenuDelegate* menu_delegate =
167 ContextMenuDelegate::FromWebContents(web_contents()); 190 ContextMenuDelegate::FromWebContents(web_contents());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, 254 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight,
232 &min_height); 255 &min_height);
233 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); 256 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width);
234 257
235 // Call SetAutoSize to apply all the appropriate validation and clipping of 258 // Call SetAutoSize to apply all the appropriate validation and clipping of
236 // values. 259 // values.
237 SetAutoSize(auto_size_enabled, 260 SetAutoSize(auto_size_enabled,
238 gfx::Size(min_width, min_height), 261 gfx::Size(min_width, min_height),
239 gfx::Size(max_width, max_height)); 262 gfx::Size(max_width, max_height));
240 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/extension_options/extension_options_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698