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

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

Issue 471053003: Allow links inside <extensionoptions> to be opened in new tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run formatter and make the WebUI test also use LoadExtension Created 6 years, 4 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
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/guest_view/extension_options/extension_options_constant s.h" 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/common/extensions/api/extension_options_internal.h" 16 #include "chrome/common/extensions/api/extension_options_internal.h"
12 #include "chrome/common/extensions/manifest_url_handler.h" 17 #include "chrome/common/extensions/manifest_url_handler.h"
13 #include "components/crx_file/id_util.h" 18 #include "components/crx_file/id_util.h"
14 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/site_instance.h" 20 #include "content/public/browser/site_instance.h"
16 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
17 #include "extensions/browser/extension_function_dispatcher.h" 22 #include "extensions/browser/extension_function_dispatcher.h"
18 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
24 #include "extensions/browser/guest_view/guest_view_manager.h"
19 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_messages.h" 26 #include "extensions/common/extension_messages.h"
21 #include "extensions/common/feature_switch.h" 27 #include "extensions/common/feature_switch.h"
22 #include "extensions/common/permissions/permissions_data.h" 28 #include "extensions/common/permissions/permissions_data.h"
23 #include "ipc/ipc_message_macros.h" 29 #include "ipc/ipc_message_macros.h"
24 30
25 using content::WebContents; 31 using content::WebContents;
26 using namespace extensions::api; 32 using namespace extensions::api;
27 33
28 // static 34 // static
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 int min_width = 0; 177 int min_width = 0;
172 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, 178 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight,
173 &min_height); 179 &min_height);
174 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); 180 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width);
175 181
176 // Call SetAutoSize to apply all the appropriate validation and clipping of 182 // Call SetAutoSize to apply all the appropriate validation and clipping of
177 // values. 183 // values.
178 SetAutoSize( 184 SetAutoSize(
179 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));
180 } 186 }
187
188 bool ExtensionOptionsGuest::ShouldCreateWebContents(
189 content::WebContents* web_contents,
190 int route_id,
191 WindowContainerType window_container_type,
192 const base::string16& frame_name,
193 const GURL& target_url,
194 const std::string& partition_id,
195 content::SessionStorageNamespace* session_storage_namespace) {
196 // This method handles opening links from within the guest. Since this guest
197 // 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.
199 // Therefore we just open the URL in a new tab, and since we aren't handling
200 // the new web contents, we return false.
201 Browser* browser =
202 chrome::FindBrowserWithWebContents(embedder_web_contents());
203 content::OpenURLParams params(target_url,
204 content::Referrer(),
205 NEW_FOREGROUND_TAB,
206 content::PAGE_TRANSITION_LINK,
207 false);
208 browser->OpenURL(params);
209 // TODO(ericzeng): Open the tab in the background if the click was a
210 // ctrl-click or middle mouse button click
211 return false;
212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698