Chromium Code Reviews| Index: chrome/browser/extensions/api/tabs/tabs_api.cc |
| diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc |
| index f2d0fd9daab8032058b3663bc8e7f703fe6e2c0e..47905f733a4f15e4a08ceb47efc1b81a5eae0248 100644 |
| --- a/chrome/browser/extensions/api/tabs/tabs_api.cc |
| +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc |
| @@ -459,19 +459,40 @@ bool WindowsCreateFunction::RunSync() { |
| } |
| } |
| + // Decide whether we are opening a normal window or an incognito window. |
| + bool is_error = true; |
| + bool open_incognito_window = ShouldOpenIncognitoWindow(create_data, &urls, |
| + &is_error); |
| + if (is_error) |
| + return false; // error_ member is set inside of ShouldOpenIncognitoWindow. |
|
Finnur
2016/05/17 14:49:14
nit: This comment doesn't really add anything, I w
Devlin
2016/05/17 19:29:54
I disagree a little - it explains why we don't hav
Finnur
2016/05/18 14:06:32
Oh, error_member! Sorry, I read this as:
// is_er
|
| + |
| // Look for optional tab id. |
| if (create_data && create_data->tab_id) { |
| // Find the tab. |source_tab_strip| and |tab_index| will later be used to |
| // move the tab into the created window. |
| + Browser* source_browser = nullptr; |
|
Devlin
2016/05/17 19:29:54
nit: source_browser, to me, implies that this is t
robwu
2016/05/17 21:14:24
source as in source of the tab. I'm using source_*
Devlin
2016/05/18 17:09:41
I still disagree with the naming, but fair point r
|
| if (!GetTabById(*create_data->tab_id, |
| GetProfile(), |
| include_incognito(), |
| - NULL, |
| + &source_browser, |
| &source_tab_strip, |
| - NULL, |
| + nullptr, |
| &tab_index, |
| &error_)) |
| return false; |
| + |
| + if (!source_browser->window()->IsTabStripEditable()) { |
| + error_ = keys::kTabStripNotEditableError; |
| + return false; |
| + } |
| + |
| + bool is_source_incognito = |
| + source_browser->profile()->GetProfileType() == |
| + Profile::INCOGNITO_PROFILE; |
|
Devlin
2016/05/17 19:29:54
nit: I think we typically use BrowserContext::IsOf
|
| + if (open_incognito_window != is_source_incognito) { |
| + error_ = keys::kCanOnlyMoveTabsWithinSameProfileError; |
|
Devlin
2016/05/17 19:29:54
I also wonder if there's some other tricky edge ca
robwu
2016/05/17 21:14:24
Done.
|
| + return false; |
| + } |
| } |
| if (!IsValidStateForWindowsCreateFunction(create_data)) { |
| @@ -490,15 +511,6 @@ bool WindowsCreateFunction::RunSync() { |
| bool focused = true; |
| bool saw_focus_key = false; |
| std::string extension_id; |
| - |
| - // Decide whether we are opening a normal window or an incognito window. |
| - bool is_error = true; |
| - bool open_incognito_window = ShouldOpenIncognitoWindow(create_data, &urls, |
| - &is_error); |
| - if (is_error) { |
| - // error_ member variable is set inside of ShouldOpenIncognitoWindow. |
| - return false; |
| - } |
| if (open_incognito_window) { |
| window_profile = window_profile->GetOffTheRecordProfile(); |
| } |