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

Side by Side Diff: chrome/browser/ui/extensions/application_launch.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/ui/extensions/application_launch.h" 5 #include "chrome/browser/ui/extensions/application_launch.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "apps/launcher.h" 9 #include "apps/launcher.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Profile* const profile = launch_params.profile; 224 Profile* const profile = launch_params.profile;
225 WindowOpenDisposition disposition = launch_params.disposition; 225 WindowOpenDisposition disposition = launch_params.disposition;
226 226
227 Browser* browser = chrome::FindTabbedBrowser(profile, false); 227 Browser* browser = chrome::FindTabbedBrowser(profile, false);
228 WebContents* contents = NULL; 228 WebContents* contents = NULL;
229 if (!browser) { 229 if (!browser) {
230 // No browser for this profile, need to open a new one. 230 // No browser for this profile, need to open a new one.
231 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); 231 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile));
232 browser->window()->Show(); 232 browser->window()->Show();
233 // There's no current tab in this browser window, so add a new one. 233 // There's no current tab in this browser window, so add a new one.
234 disposition = NEW_FOREGROUND_TAB; 234 disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
235 } else { 235 } else {
236 // For existing browser, ensure its window is shown and activated. 236 // For existing browser, ensure its window is shown and activated.
237 browser->window()->Show(); 237 browser->window()->Show();
238 browser->window()->Activate(); 238 browser->window()->Activate();
239 } 239 }
240 240
241 extensions::LaunchType launch_type = 241 extensions::LaunchType launch_type =
242 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); 242 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension);
243 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); 243 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100);
244 244
245 int add_type = TabStripModel::ADD_ACTIVE; 245 int add_type = TabStripModel::ADD_ACTIVE;
246 if (launch_type == extensions::LAUNCH_TYPE_PINNED) 246 if (launch_type == extensions::LAUNCH_TYPE_PINNED)
247 add_type |= TabStripModel::ADD_PINNED; 247 add_type |= TabStripModel::ADD_PINNED;
248 248
249 ui::PageTransition transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK; 249 ui::PageTransition transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK;
250 chrome::NavigateParams params(browser, url, transition); 250 chrome::NavigateParams params(browser, url, transition);
251 params.tabstrip_add_types = add_type; 251 params.tabstrip_add_types = add_type;
252 params.disposition = disposition; 252 params.disposition = disposition;
253 253
254 if (disposition == CURRENT_TAB) { 254 if (disposition == WindowOpenDisposition::CURRENT_TAB) {
255 WebContents* existing_tab = 255 WebContents* existing_tab =
256 browser->tab_strip_model()->GetActiveWebContents(); 256 browser->tab_strip_model()->GetActiveWebContents();
257 TabStripModel* model = browser->tab_strip_model(); 257 TabStripModel* model = browser->tab_strip_model();
258 int tab_index = model->GetIndexOfWebContents(existing_tab); 258 int tab_index = model->GetIndexOfWebContents(existing_tab);
259 259
260 existing_tab->OpenURL(content::OpenURLParams( 260 existing_tab->OpenURL(content::OpenURLParams(
261 url, content::Referrer::SanitizeForRequest( 261 url, content::Referrer::SanitizeForRequest(
262 url, content::Referrer(existing_tab->GetURL(), 262 url, content::Referrer(existing_tab->GetURL(),
263 blink::WebReferrerPolicyDefault)), 263 blink::WebReferrerPolicyDefault)),
264 disposition, transition, false)); 264 disposition, transition, false));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return; 378 return;
379 } 379 }
380 380
381 OpenEnabledApplication(params); 381 OpenEnabledApplication(params);
382 } 382 }
383 383
384 WebContents* OpenAppShortcutWindow(Profile* profile, 384 WebContents* OpenAppShortcutWindow(Profile* profile,
385 const GURL& url) { 385 const GURL& url) {
386 AppLaunchParams launch_params(profile, 386 AppLaunchParams launch_params(profile,
387 NULL, // this is a URL app. No extension. 387 NULL, // this is a URL app. No extension.
388 extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW, 388 extensions::LAUNCH_CONTAINER_WINDOW,
389 WindowOpenDisposition::NEW_WINDOW,
389 extensions::SOURCE_COMMAND_LINE); 390 extensions::SOURCE_COMMAND_LINE);
390 launch_params.override_url = url; 391 launch_params.override_url = url;
391 392
392 WebContents* tab = OpenApplicationWindow(launch_params, url); 393 WebContents* tab = OpenApplicationWindow(launch_params, url);
393 394
394 if (!tab) 395 if (!tab)
395 return NULL; 396 return NULL;
396 397
397 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); 398 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete();
398 399
399 return tab; 400 return tab;
400 } 401 }
401 402
402 bool CanLaunchViaEvent(const extensions::Extension* extension) { 403 bool CanLaunchViaEvent(const extensions::Extension* extension) {
403 const extensions::Feature* feature = 404 const extensions::Feature* feature =
404 extensions::FeatureProvider::GetAPIFeature("app.runtime"); 405 extensions::FeatureProvider::GetAPIFeature("app.runtime");
405 return feature && feature->IsAvailableToExtension(extension).is_available(); 406 return feature && feature->IsAvailableToExtension(extension).is_available();
406 } 407 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/app_launch_params.cc ('k') | chrome/browser/ui/extensions/extension_installed_notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698