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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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 <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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 TabStripModel* tab_strip = browser->tab_strip_model(); 235 TabStripModel* tab_strip = browser->tab_strip_model();
236 236
237 index = std::min(std::max(index, -1), tab_strip->count()); 237 index = std::min(std::max(index, -1), tab_strip->count());
238 238
239 int add_types = active ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; 239 int add_types = active ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE;
240 add_types |= TabStripModel::ADD_FORCE_INDEX; 240 add_types |= TabStripModel::ADD_FORCE_INDEX;
241 if (pinned) 241 if (pinned)
242 add_types |= TabStripModel::ADD_PINNED; 242 add_types |= TabStripModel::ADD_PINNED;
243 chrome::NavigateParams navigate_params( 243 chrome::NavigateParams navigate_params(
244 browser, url, ui::PAGE_TRANSITION_LINK); 244 browser, url, ui::PAGE_TRANSITION_LINK);
245 navigate_params.disposition = 245 navigate_params.disposition = active
246 active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; 246 ? WindowOpenDisposition::NEW_FOREGROUND_TAB
247 : WindowOpenDisposition::NEW_BACKGROUND_TAB;
247 navigate_params.tabstrip_index = index; 248 navigate_params.tabstrip_index = index;
248 navigate_params.tabstrip_add_types = add_types; 249 navigate_params.tabstrip_add_types = add_types;
249 chrome::Navigate(&navigate_params); 250 chrome::Navigate(&navigate_params);
250 251
251 // The tab may have been created in a different window, so make sure we look 252 // The tab may have been created in a different window, so make sure we look
252 // at the right tab strip. 253 // at the right tab strip.
253 tab_strip = navigate_params.browser->tab_strip_model(); 254 tab_strip = navigate_params.browser->tab_strip_model();
254 int new_index = 255 int new_index =
255 tab_strip->GetIndexOfWebContents(navigate_params.target_contents); 256 tab_strip->GetIndexOfWebContents(navigate_params.target_contents);
256 if (opener) 257 if (opener)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 const bool browser_created = !browser; 589 const bool browser_created = !browser;
589 if (!browser) 590 if (!browser)
590 browser = new Browser(Browser::CreateParams(profile)); 591 browser = new Browser(Browser::CreateParams(profile));
591 chrome::NavigateParams params(browser, web_contents); 592 chrome::NavigateParams params(browser, web_contents);
592 593
593 // The extension_app_id parameter ends up as app_name in the Browser 594 // The extension_app_id parameter ends up as app_name in the Browser
594 // which causes the Browser to return true for is_app(). This affects 595 // which causes the Browser to return true for is_app(). This affects
595 // among other things, whether the location bar gets displayed. 596 // among other things, whether the location bar gets displayed.
596 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted 597 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted
597 // in a tab? 598 // in a tab?
598 if (disposition == NEW_POPUP) 599 if (disposition == WindowOpenDisposition::NEW_POPUP)
599 params.extension_app_id = extension_id; 600 params.extension_app_id = extension_id;
600 601
601 params.disposition = disposition; 602 params.disposition = disposition;
602 params.window_bounds = initial_rect; 603 params.window_bounds = initial_rect;
603 params.window_action = chrome::NavigateParams::SHOW_WINDOW; 604 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
604 params.user_gesture = user_gesture; 605 params.user_gesture = user_gesture;
605 chrome::Navigate(&params); 606 chrome::Navigate(&params);
606 607
607 // Close the browser if chrome::Navigate created a new one. 608 // Close the browser if chrome::Navigate created a new one.
608 if (browser_created && (browser != params.browser)) 609 if (browser_created && (browser != params.browser))
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 chrome::ShowSingletonTabOverwritingNTP(browser, params); 671 chrome::ShowSingletonTabOverwritingNTP(browser, params);
671 return true; 672 return true;
672 } 673 }
673 674
674 // static 675 // static
675 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { 676 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) {
676 return browser && browser->tab_strip_model() && !browser->is_devtools(); 677 return browser && browser->tab_strip_model() && !browser->is_devtools();
677 } 678 }
678 679
679 } // namespace extensions 680 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698