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

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

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 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
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 "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 *error_message = ErrorUtils::FormatErrorMessage( 87 *error_message = ErrorUtils::FormatErrorMessage(
88 keys::kWindowNotFoundError, base::IntToString(window_id)); 88 keys::kWindowNotFoundError, base::IntToString(window_id));
89 89
90 return NULL; 90 return NULL;
91 } 91 }
92 92
93 Browser* CreateBrowser(ChromeUIThreadExtensionFunction* function, 93 Browser* CreateBrowser(ChromeUIThreadExtensionFunction* function,
94 int window_id, 94 int window_id,
95 std::string* error) { 95 std::string* error) {
96 content::WebContents* web_contents = function->GetAssociatedWebContents(); 96 content::WebContents* web_contents = function->GetAssociatedWebContents();
97 chrome::HostDesktopType desktop_type = 97 ui::HostDesktopType desktop_type =
98 web_contents && web_contents->GetNativeView() 98 web_contents && web_contents->GetNativeView()
99 ? chrome::GetHostDesktopTypeForNativeView( 99 ? chrome::GetHostDesktopTypeForNativeView(
100 web_contents->GetNativeView()) 100 web_contents->GetNativeView())
101 : chrome::GetHostDesktopTypeForNativeView(NULL); 101 : chrome::GetHostDesktopTypeForNativeView(NULL);
102 Browser::CreateParams params( 102 Browser::CreateParams params(
103 Browser::TYPE_TABBED, function->GetProfile(), desktop_type); 103 Browser::TYPE_TABBED, function->GetProfile(), desktop_type);
104 Browser* browser = new Browser(params); 104 Browser* browser = new Browser(params);
105 browser->window()->Show(); 105 browser->window()->Show();
106 return browser; 106 return browser;
107 } 107 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 bool pinned = false; 214 bool pinned = false;
215 if (params.pinned.get()) 215 if (params.pinned.get())
216 pinned = *params.pinned; 216 pinned = *params.pinned;
217 217
218 // We can't load extension URLs into incognito windows unless the extension 218 // 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. 219 // uses split mode. Special case to fall back to a tabbed window.
220 if (url.SchemeIs(kExtensionScheme) && 220 if (url.SchemeIs(kExtensionScheme) &&
221 !IncognitoInfo::IsSplitMode(function->extension()) && 221 !IncognitoInfo::IsSplitMode(function->extension()) &&
222 browser->profile()->IsOffTheRecord()) { 222 browser->profile()->IsOffTheRecord()) {
223 Profile* profile = browser->profile()->GetOriginalProfile(); 223 Profile* profile = browser->profile()->GetOriginalProfile();
224 chrome::HostDesktopType desktop_type = browser->host_desktop_type(); 224 ui::HostDesktopType desktop_type = browser->host_desktop_type();
225 225
226 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); 226 browser = chrome::FindTabbedBrowser(profile, false, desktop_type);
227 if (!browser) { 227 if (!browser) {
228 browser = new Browser( 228 browser = new Browser(
229 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); 229 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type));
230 browser->window()->Show(); 230 browser->window()->Show();
231 } 231 }
232 } 232 }
233 233
234 // If index is specified, honor the value, but keep it bound to 234 // If index is specified, honor the value, but keep it bound to
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 return false; 584 return false;
585 } 585 }
586 586
587 void ExtensionTabUtil::CreateTab(WebContents* web_contents, 587 void ExtensionTabUtil::CreateTab(WebContents* web_contents,
588 const std::string& extension_id, 588 const std::string& extension_id,
589 WindowOpenDisposition disposition, 589 WindowOpenDisposition disposition,
590 const gfx::Rect& initial_rect, 590 const gfx::Rect& initial_rect,
591 bool user_gesture) { 591 bool user_gesture) {
592 Profile* profile = 592 Profile* profile =
593 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 593 Profile::FromBrowserContext(web_contents->GetBrowserContext());
594 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); 594 ui::HostDesktopType active_desktop = chrome::GetActiveDesktop();
595 Browser* browser = chrome::FindTabbedBrowser(profile, false, active_desktop); 595 Browser* browser = chrome::FindTabbedBrowser(profile, false, active_desktop);
596 const bool browser_created = !browser; 596 const bool browser_created = !browser;
597 if (!browser) 597 if (!browser)
598 browser = new Browser(Browser::CreateParams(profile, active_desktop)); 598 browser = new Browser(Browser::CreateParams(profile, active_desktop));
599 chrome::NavigateParams params(browser, web_contents); 599 chrome::NavigateParams params(browser, web_contents);
600 600
601 // The extension_app_id parameter ends up as app_name in the Browser 601 // The extension_app_id parameter ends up as app_name in the Browser
602 // which causes the Browser to return true for is_app(). This affects 602 // which causes the Browser to return true for is_app(). This affects
603 // among other things, whether the location bar gets displayed. 603 // among other things, whether the location bar gets displayed.
604 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted 604 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 chrome::ShowSingletonTabOverwritingNTP(browser, params); 671 chrome::ShowSingletonTabOverwritingNTP(browser, params);
672 return true; 672 return true;
673 } 673 }
674 674
675 // static 675 // static
676 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { 676 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) {
677 return browser && browser->tab_strip_model() && !browser->is_devtools(); 677 return browser && browser->tab_strip_model() && !browser->is_devtools();
678 } 678 }
679 679
680 } // namespace extensions 680 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698