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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 1843943003: Extension-created windows should share the creator's BrowingInstance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up stray include and fix unrelated unit test Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/tabs/tabs_api.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/prefs/incognito_mode_prefs.h" 35 #include "chrome/browser/prefs/incognito_mode_prefs.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/sessions/session_tab_helper.h" 37 #include "chrome/browser/sessions/session_tab_helper.h"
38 #include "chrome/browser/translate/chrome_translate_client.h" 38 #include "chrome/browser/translate/chrome_translate_client.h"
39 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 39 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
40 #include "chrome/browser/ui/browser.h" 40 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_commands.h" 41 #include "chrome/browser/ui/browser_commands.h"
42 #include "chrome/browser/ui/browser_finder.h" 42 #include "chrome/browser/ui/browser_finder.h"
43 #include "chrome/browser/ui/browser_list.h" 43 #include "chrome/browser/ui/browser_list.h"
44 #include "chrome/browser/ui/browser_navigator.h" 44 #include "chrome/browser/ui/browser_navigator.h"
45 #include "chrome/browser/ui/browser_navigator_params.h"
45 #include "chrome/browser/ui/browser_tabstrip.h" 46 #include "chrome/browser/ui/browser_tabstrip.h"
46 #include "chrome/browser/ui/browser_window.h" 47 #include "chrome/browser/ui/browser_window.h"
47 #include "chrome/browser/ui/panels/panel_manager.h" 48 #include "chrome/browser/ui/panels/panel_manager.h"
48 #include "chrome/browser/ui/tabs/tab_strip_model.h" 49 #include "chrome/browser/ui/tabs/tab_strip_model.h"
49 #include "chrome/browser/ui/tabs/tab_utils.h" 50 #include "chrome/browser/ui/tabs/tab_utils.h"
50 #include "chrome/browser/ui/window_sizer/window_sizer.h" 51 #include "chrome/browser/ui/window_sizer/window_sizer.h"
51 #include "chrome/browser/web_applications/web_app.h" 52 #include "chrome/browser/web_applications/web_app.h"
52 #include "chrome/common/chrome_switches.h" 53 #include "chrome/common/chrome_switches.h"
53 #include "chrome/common/extensions/api/tabs.h" 54 #include "chrome/common/extensions/api/tabs.h"
54 #include "chrome/common/extensions/api/windows.h" 55 #include "chrome/common/extensions/api/windows.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 false /* trusted_source */, window_bounds, window_profile); 635 false /* trusted_source */, window_bounds, window_profile);
635 } 636 }
636 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; 637 create_params.initial_show_state = ui::SHOW_STATE_NORMAL;
637 if (create_data && create_data->state) { 638 if (create_data && create_data->state) {
638 create_params.initial_show_state = 639 create_params.initial_show_state =
639 ConvertToWindowShowState(create_data->state); 640 ConvertToWindowShowState(create_data->state);
640 } 641 }
641 642
642 Browser* new_window = new Browser(create_params); 643 Browser* new_window = new Browser(create_params);
643 644
644 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { 645 for (const GURL& url : urls) {
645 WebContents* tab = chrome::AddSelectedTabWithURL( 646 chrome::NavigateParams navigate_params(new_window, url,
Devlin 2016/04/01 17:20:57 Do we still need browser_tabstrip.h?
dcheng 2016/04/01 17:42:00 Done.
646 new_window, *i, ui::PAGE_TRANSITION_LINK); 647 ui::PAGE_TRANSITION_LINK);
648 navigate_params.disposition = NEW_FOREGROUND_TAB;
649 navigate_params.source_site_instance =
Devlin 2016/04/01 17:20:57 "Without plumbing through the source SiteInstance,
dcheng 2016/04/01 17:42:00 It'd cause a navigation from an extension origin t
Devlin 2016/04/01 18:56:34 Ah, got it - can you add that to the CL descriptio
dcheng 2016/04/02 00:54:25 Done.
650 render_frame_host()->GetSiteInstance();
651 chrome::Navigate(&navigate_params);
647 if (create_panel) { 652 if (create_panel) {
648 TabHelper::FromWebContents(tab)->SetExtensionAppIconById(extension_id); 653 TabHelper::FromWebContents(navigate_params.target_contents)
654 ->SetExtensionAppIconById(extension_id);
649 } 655 }
650 } 656 }
651 657
652 WebContents* contents = NULL; 658 WebContents* contents = NULL;
653 // Move the tab into the created window only if it's an empty popup or it's 659 // Move the tab into the created window only if it's an empty popup or it's
654 // a tabbed window. 660 // a tabbed window.
655 if ((window_type == Browser::TYPE_POPUP && urls.empty()) || 661 if ((window_type == Browser::TYPE_POPUP && urls.empty()) ||
656 window_type == Browser::TYPE_TABBED) { 662 window_type == Browser::TYPE_TABBED) {
657 if (source_tab_strip) 663 if (source_tab_strip)
658 contents = source_tab_strip->DetachWebContentsAt(tab_index); 664 contents = source_tab_strip->DetachWebContentsAt(tab_index);
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 2137 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
2132 zoom_settings.default_zoom_factor.reset(new double( 2138 zoom_settings.default_zoom_factor.reset(new double(
2133 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); 2139 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
2134 2140
2135 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 2141 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
2136 SendResponse(true); 2142 SendResponse(true);
2137 return true; 2143 return true;
2138 } 2144 }
2139 2145
2140 } // namespace extensions 2146 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698