OLD | NEW |
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 chrome::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 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 106 browser->window()->Show(false /* user_gesture */); |
106 return browser; | 107 return browser; |
107 } | 108 } |
108 | 109 |
109 } // namespace | 110 } // namespace |
110 | 111 |
111 ExtensionTabUtil::OpenTabParams::OpenTabParams() | 112 ExtensionTabUtil::OpenTabParams::OpenTabParams() |
112 : create_browser_if_needed(false) { | 113 : create_browser_if_needed(false) { |
113 } | 114 } |
114 | 115 |
115 ExtensionTabUtil::OpenTabParams::~OpenTabParams() { | 116 ExtensionTabUtil::OpenTabParams::~OpenTabParams() { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 if (url.SchemeIs(kExtensionScheme) && | 211 if (url.SchemeIs(kExtensionScheme) && |
211 !IncognitoInfo::IsSplitMode(function->extension()) && | 212 !IncognitoInfo::IsSplitMode(function->extension()) && |
212 browser->profile()->IsOffTheRecord()) { | 213 browser->profile()->IsOffTheRecord()) { |
213 Profile* profile = browser->profile()->GetOriginalProfile(); | 214 Profile* profile = browser->profile()->GetOriginalProfile(); |
214 chrome::HostDesktopType desktop_type = browser->host_desktop_type(); | 215 chrome::HostDesktopType desktop_type = browser->host_desktop_type(); |
215 | 216 |
216 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 217 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
217 if (!browser) { | 218 if (!browser) { |
218 browser = new Browser( | 219 browser = new Browser( |
219 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | 220 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); |
220 browser->window()->Show(); | 221 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 222 browser->window()->Show(false /* user_gesture */); |
221 } | 223 } |
222 } | 224 } |
223 | 225 |
224 // 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 |
225 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior. | 227 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior. |
226 int index = -1; | 228 int index = -1; |
227 if (params.index.get()) | 229 if (params.index.get()) |
228 index = *params.index; | 230 index = *params.index; |
229 | 231 |
230 TabStripModel* tab_strip = browser->tab_strip_model(); | 232 TabStripModel* tab_strip = browser->tab_strip_model(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 613 |
612 chrome::NavigateParams params( | 614 chrome::NavigateParams params( |
613 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate)); | 615 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate)); |
614 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 616 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
615 params.url = url_to_navigate; | 617 params.url = url_to_navigate; |
616 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 618 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
617 return true; | 619 return true; |
618 } | 620 } |
619 | 621 |
620 } // namespace extensions | 622 } // namespace extensions |
OLD | NEW |