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

Side by Side Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 1662783002: Remove HostDesktopType from Browser::CreateParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-12
Patch Set: remove desktop_type_ in bookmark_bubble_sign_in_delegate Created 4 years, 10 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/extension_tab_util.h" 5 #include "chrome/browser/extensions/extension_tab_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (error_message) 88 if (error_message)
89 *error_message = ErrorUtils::FormatErrorMessage( 89 *error_message = ErrorUtils::FormatErrorMessage(
90 keys::kWindowNotFoundError, base::IntToString(window_id)); 90 keys::kWindowNotFoundError, base::IntToString(window_id));
91 91
92 return NULL; 92 return NULL;
93 } 93 }
94 94
95 Browser* CreateBrowser(ChromeUIThreadExtensionFunction* function, 95 Browser* CreateBrowser(ChromeUIThreadExtensionFunction* function,
96 int window_id, 96 int window_id,
97 std::string* error) { 97 std::string* error) {
98 content::WebContents* web_contents = function->GetAssociatedWebContents(); 98 Browser::CreateParams params(Browser::TYPE_TABBED, function->GetProfile());
99 chrome::HostDesktopType desktop_type =
100 web_contents && web_contents->GetNativeView()
101 ? chrome::GetHostDesktopTypeForNativeView(
102 web_contents->GetNativeView())
103 : chrome::GetHostDesktopTypeForNativeView(NULL);
104 Browser::CreateParams params(
105 Browser::TYPE_TABBED, function->GetProfile(), desktop_type);
106 Browser* browser = new Browser(params); 99 Browser* browser = new Browser(params);
107 browser->window()->Show(); 100 browser->window()->Show();
108 return browser; 101 return browser;
109 } 102 }
110 103
111 // Use this function for reporting a tab id to an extension. It will 104 // Use this function for reporting a tab id to an extension. It will
112 // take care of setting the id to TAB_ID_NONE if necessary (for 105 // take care of setting the id to TAB_ID_NONE if necessary (for
113 // example with devtools). 106 // example with devtools).
114 int GetTabIdForExtensions(const WebContents* web_contents) { 107 int GetTabIdForExtensions(const WebContents* web_contents) {
115 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 108 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 bool pinned = false; 207 bool pinned = false;
215 if (params.pinned.get()) 208 if (params.pinned.get())
216 pinned = *params.pinned; 209 pinned = *params.pinned;
217 210
218 // We can't load extension URLs into incognito windows unless the extension 211 // We can't load extension URLs into incognito windows unless the extension
219 // uses split mode. Special case to fall back to a tabbed window. 212 // uses split mode. Special case to fall back to a tabbed window.
220 if (url.SchemeIs(kExtensionScheme) && 213 if (url.SchemeIs(kExtensionScheme) &&
221 !IncognitoInfo::IsSplitMode(function->extension()) && 214 !IncognitoInfo::IsSplitMode(function->extension()) &&
222 browser->profile()->IsOffTheRecord()) { 215 browser->profile()->IsOffTheRecord()) {
223 Profile* profile = browser->profile()->GetOriginalProfile(); 216 Profile* profile = browser->profile()->GetOriginalProfile();
224 chrome::HostDesktopType desktop_type = browser->host_desktop_type();
225 217
226 browser = chrome::FindTabbedBrowser(profile, false); 218 browser = chrome::FindTabbedBrowser(profile, false);
227 if (!browser) { 219 if (!browser) {
228 browser = new Browser( 220 browser =
229 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); 221 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile));
230 browser->window()->Show(); 222 browser->window()->Show();
231 } 223 }
232 } 224 }
233 225
234 // If index is specified, honor the value, but keep it bound to 226 // If index is specified, honor the value, but keep it bound to
235 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior. 227 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior.
236 int index = -1; 228 int index = -1;
237 if (params.index.get()) 229 if (params.index.get())
238 index = *params.index; 230 index = *params.index;
239 231
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return false; 575 return false;
584 } 576 }
585 577
586 void ExtensionTabUtil::CreateTab(WebContents* web_contents, 578 void ExtensionTabUtil::CreateTab(WebContents* web_contents,
587 const std::string& extension_id, 579 const std::string& extension_id,
588 WindowOpenDisposition disposition, 580 WindowOpenDisposition disposition,
589 const gfx::Rect& initial_rect, 581 const gfx::Rect& initial_rect,
590 bool user_gesture) { 582 bool user_gesture) {
591 Profile* profile = 583 Profile* profile =
592 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 584 Profile::FromBrowserContext(web_contents->GetBrowserContext());
593 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop();
594 Browser* browser = chrome::FindTabbedBrowser(profile, false); 585 Browser* browser = chrome::FindTabbedBrowser(profile, false);
595 const bool browser_created = !browser; 586 const bool browser_created = !browser;
596 if (!browser) 587 if (!browser)
597 browser = new Browser(Browser::CreateParams(profile, active_desktop)); 588 browser = new Browser(Browser::CreateParams(profile));
598 chrome::NavigateParams params(browser, web_contents); 589 chrome::NavigateParams params(browser, web_contents);
599 590
600 // The extension_app_id parameter ends up as app_name in the Browser 591 // The extension_app_id parameter ends up as app_name in the Browser
601 // which causes the Browser to return true for is_app(). This affects 592 // which causes the Browser to return true for is_app(). This affects
602 // among other things, whether the location bar gets displayed. 593 // among other things, whether the location bar gets displayed.
603 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted 594 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted
604 // in a tab? 595 // in a tab?
605 if (disposition == NEW_POPUP) 596 if (disposition == NEW_POPUP)
606 params.extension_app_id = extension_id; 597 params.extension_app_id = extension_id;
607 598
(...skipping 28 matching lines...) Expand all
636 bool ExtensionTabUtil::OpenOptionsPage(const Extension* extension, 627 bool ExtensionTabUtil::OpenOptionsPage(const Extension* extension,
637 Browser* browser) { 628 Browser* browser) {
638 if (!OptionsPageInfo::HasOptionsPage(extension)) 629 if (!OptionsPageInfo::HasOptionsPage(extension))
639 return false; 630 return false;
640 631
641 // Force the options page to open in non-OTR window, because it won't be 632 // Force the options page to open in non-OTR window, because it won't be
642 // able to save settings from OTR. 633 // able to save settings from OTR.
643 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; 634 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer;
644 if (browser->profile()->IsOffTheRecord()) { 635 if (browser->profile()->IsOffTheRecord()) {
645 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( 636 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer(
646 browser->profile()->GetOriginalProfile(), 637 browser->profile()->GetOriginalProfile()));
647 browser->host_desktop_type()));
648 browser = displayer->browser(); 638 browser = displayer->browser();
649 } 639 }
650 640
651 GURL url_to_navigate; 641 GURL url_to_navigate;
652 if (OptionsPageInfo::ShouldOpenInTab(extension)) { 642 if (OptionsPageInfo::ShouldOpenInTab(extension)) {
653 // Options page tab is simply e.g. chrome-extension://.../options.html. 643 // Options page tab is simply e.g. chrome-extension://.../options.html.
654 url_to_navigate = OptionsPageInfo::GetOptionsPage(extension); 644 url_to_navigate = OptionsPageInfo::GetOptionsPage(extension);
655 } else { 645 } else {
656 // Options page tab is Extension settings pointed at that Extension's ID, 646 // Options page tab is Extension settings pointed at that Extension's ID,
657 // e.g. chrome://extensions?options=... 647 // e.g. chrome://extensions?options=...
(...skipping 12 matching lines...) Expand all
670 chrome::ShowSingletonTabOverwritingNTP(browser, params); 660 chrome::ShowSingletonTabOverwritingNTP(browser, params);
671 return true; 661 return true;
672 } 662 }
673 663
674 // static 664 // static
675 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { 665 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) {
676 return browser && browser->tab_strip_model() && !browser->is_devtools(); 666 return browser && browser->tab_strip_model() && !browser->is_devtools();
677 } 667 }
678 668
679 } // namespace extensions 669 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_context_menu_model_unittest.cc ('k') | chrome/browser/lifetime/browser_close_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698