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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl.cc

Issue 11137031: If chrome in desktop mode on Windows 8 defers to Windows 8 metro chrome, then we only want to creat… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/startup/startup_browser_creator_impl.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 #if defined(OS_MACOSX) 104 #if defined(OS_MACOSX)
105 #include "base/mac/mac_util.h" 105 #include "base/mac/mac_util.h"
106 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" 106 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h"
107 #endif 107 #endif
108 108
109 #if defined(TOOLKIT_GTK) 109 #if defined(TOOLKIT_GTK)
110 #include "chrome/browser/ui/gtk/gtk_util.h" 110 #include "chrome/browser/ui/gtk/gtk_util.h"
111 #endif 111 #endif
112 112
113 #if defined(OS_WIN) 113 #if defined(OS_WIN)
114 #include "base/win/metro.h"
114 #include "base/win/windows_version.h" 115 #include "base/win/windows_version.h"
115 #endif 116 #endif
116 117
117 using content::ChildProcessSecurityPolicy; 118 using content::ChildProcessSecurityPolicy;
118 using content::WebContents; 119 using content::WebContents;
119 using extensions::Extension; 120 using extensions::Extension;
120 using protector::ProtectedPrefsWatcher; 121 using protector::ProtectedPrefsWatcher;
121 using protector::ProtectorService; 122 using protector::ProtectorService;
122 using protector::ProtectorServiceFactory; 123 using protector::ProtectorServiceFactory;
123 124
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_DESTROYED); 292 DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_DESTROYED);
292 contents_ = NULL; 293 contents_ = NULL;
293 } 294 }
294 295
295 content::WebContents* contents_; 296 content::WebContents* contents_;
296 content::NotificationRegistrar registrar_; 297 content::NotificationRegistrar registrar_;
297 298
298 DISALLOW_COPY_AND_ASSIGN(WebContentsCloseObserver); 299 DISALLOW_COPY_AND_ASSIGN(WebContentsCloseObserver);
299 }; 300 };
300 301
302 // Platform specific helper to activate an existing Browser instance for the
303 // profile passed in. Defaults to returning false. For Windows 8 in metro mode
304 // we activate an existing browser if the startup urls contains only the new
305 // tab page.
306 #if defined(OS_WIN) && !defined(USE_AURA)
307 bool PlatformActivateBrowserForProfile(
308 Profile* profile, const std::vector<GURL>& startup_urls) {
309 if (!base::win::IsMetroProcess())
310 return false;
311
312 // We activate an existing browser window if we are opening just the new tab
313 // page in metro mode.
314 if (startup_urls.size() > 1)
315 return false;
316
317 if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL))
318 return false;
319
320 Browser* browser = browser::FindBrowserWithProfile(
321 profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
322
323 if (!browser)
324 return false;
325
326 browser->window()->Show();
327 }
328 #else
329 bool PlatformActivateBrowserForProfile(
330 Profile* profile, const std::vector<GURL>& startup_urls) {
331 return false;
332 }
333 #endif
334
301 } // namespace 335 } // namespace
302 336
303 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( 337 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl(
304 const FilePath& cur_dir, 338 const FilePath& cur_dir,
305 const CommandLine& command_line, 339 const CommandLine& command_line,
306 chrome::startup::IsFirstRun is_first_run) 340 chrome::startup::IsFirstRun is_first_run)
307 : cur_dir_(cur_dir), 341 : cur_dir_(cur_dir),
308 command_line_(command_line), 342 command_line_(command_line),
309 profile_(NULL), 343 profile_(NULL),
310 browser_creator_(NULL), 344 browser_creator_(NULL),
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 return; 644 return;
611 } 645 }
612 } 646 }
613 } 647 }
614 648
615 // Session startup didn't occur, open the urls. 649 // Session startup didn't occur, open the urls.
616 Browser* browser = NULL; 650 Browser* browser = NULL;
617 std::vector<GURL> adjust_urls = urls_to_open; 651 std::vector<GURL> adjust_urls = urls_to_open;
618 if (adjust_urls.empty()) { 652 if (adjust_urls.empty()) {
619 AddStartupURLs(&adjust_urls); 653 AddStartupURLs(&adjust_urls);
654 if (PlatformActivateBrowserForProfile(profile_, adjust_urls))
sky 2012/10/16 15:46:30 Name this OpenStartupURLsInExistingBrowser and mov
ananta 2012/10/16 18:44:49 The function does not open the startup urls. It ac
sky 2012/10/16 21:11:08 Logically this method is called during startup to
ananta 2012/10/16 21:17:44 Fair enough. Done.
655 return;
620 } else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) { 656 } else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) {
621 // Always open a list of urls in a window on the native desktop. 657 // Always open a list of urls in a window on the native desktop.
622 browser = browser::FindBrowserWithProfile(profile_, 658 browser = browser::FindBrowserWithProfile(profile_,
623 chrome::HOST_DESKTOP_TYPE_NATIVE); 659 chrome::HOST_DESKTOP_TYPE_NATIVE);
624 } 660 }
625
626 // This will launch a browser; prevent session restore. 661 // This will launch a browser; prevent session restore.
627 in_synchronous_profile_launch = true; 662 in_synchronous_profile_launch = true;
628 browser = OpenURLsInBrowser(browser, process_startup, adjust_urls); 663 browser = OpenURLsInBrowser(browser, process_startup, adjust_urls);
629 in_synchronous_profile_launch = false; 664 in_synchronous_profile_launch = false;
630 AddInfoBarsIfNecessary(browser, is_process_startup); 665 AddInfoBarsIfNecessary(browser, is_process_startup);
631 } 666 }
632 667
633 bool StartupBrowserCreatorImpl::ProcessStartupURLs( 668 bool StartupBrowserCreatorImpl::ProcessStartupURLs(
634 const std::vector<GURL>& urls_to_open) { 669 const std::vector<GURL>& urls_to_open) {
635 VLOG(1) << "StartupBrowserCreatorImpl::ProcessStartupURLs"; 670 VLOG(1) << "StartupBrowserCreatorImpl::ProcessStartupURLs";
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // New: 1061 // New:
1027 prefs->GetString(prefs::kHomePage), 1062 prefs->GetString(prefs::kHomePage),
1028 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), 1063 prefs->GetBoolean(prefs::kHomePageIsNewTabPage),
1029 prefs->GetBoolean(prefs::kShowHomeButton), 1064 prefs->GetBoolean(prefs::kShowHomeButton),
1030 // Backup: 1065 // Backup:
1031 backup_homepage, 1066 backup_homepage,
1032 backup_homepage_is_ntp, 1067 backup_homepage_is_ntp,
1033 backup_show_home_button)); 1068 backup_show_home_button));
1034 } 1069 }
1035 } 1070 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698