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

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | « chrome/browser/ui/browser_mac.cc ('k') | chrome/browser/ui/browser_navigator_browsertest.cc » ('j') | 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/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // those types of Browser. 51 // those types of Browser.
52 bool WindowCanOpenTabs(Browser* browser) { 52 bool WindowCanOpenTabs(Browser* browser) {
53 return browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP) || 53 return browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP) ||
54 browser->tab_strip_model()->empty(); 54 browser->tab_strip_model()->empty();
55 } 55 }
56 56
57 // Finds an existing Browser compatible with |profile|, making a new one if no 57 // Finds an existing Browser compatible with |profile|, making a new one if no
58 // such Browser is located. 58 // such Browser is located.
59 Browser* GetOrCreateBrowser(Profile* profile) { 59 Browser* GetOrCreateBrowser(Profile* profile) {
60 Browser* browser = browser::FindTabbedBrowser(profile, false); 60 Browser* browser = browser::FindTabbedBrowser(profile, false);
61 return browser ? browser : Browser::Create(profile); 61 return browser ? browser : new Browser(Browser::CreateParams(profile));
62 } 62 }
63 63
64 // Change some of the navigation parameters based on the particular URL. 64 // Change some of the navigation parameters based on the particular URL.
65 // Currently this applies to some chrome:// pages which we always want to open 65 // Currently this applies to some chrome:// pages which we always want to open
66 // in a non-incognito window. Note that even though a ChromeOS guest session is 66 // in a non-incognito window. Note that even though a ChromeOS guest session is
67 // technically an incognito window, these URLs are allowed. 67 // technically an incognito window, these URLs are allowed.
68 // Returns true on success. Otherwise, if changing params leads the browser into 68 // Returns true on success. Otherwise, if changing params leads the browser into
69 // an erroneous state, returns false. 69 // an erroneous state, returns false.
70 bool AdjustNavigateParamsForURL(chrome::NavigateParams* params) { 70 bool AdjustNavigateParamsForURL(chrome::NavigateParams* params) {
71 if (params->target_contents != NULL || 71 if (params->target_contents != NULL ||
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 app_name = params->browser->app_name(); 130 app_name = params->browser->app_name();
131 } else if (params->source_contents && 131 } else if (params->source_contents &&
132 params->source_contents->extension_tab_helper()->is_app()) { 132 params->source_contents->extension_tab_helper()->is_app()) {
133 app_name = web_app::GenerateApplicationNameFromExtensionId( 133 app_name = web_app::GenerateApplicationNameFromExtensionId(
134 params->source_contents->extension_tab_helper()-> 134 params->source_contents->extension_tab_helper()->
135 extension_app()->id()); 135 extension_app()->id());
136 } 136 }
137 if (app_name.empty()) { 137 if (app_name.empty()) {
138 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile); 138 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile);
139 browser_params.initial_bounds = params->window_bounds; 139 browser_params.initial_bounds = params->window_bounds;
140 return Browser::CreateWithParams(browser_params); 140 return new Browser(browser_params);
141 } 141 }
142 142
143 return Browser::CreateWithParams( 143 return new Browser(Browser::CreateParams::CreateForApp(
144 Browser::CreateParams::CreateForApp( 144 Browser::TYPE_POPUP, app_name, params->window_bounds, profile));
145 Browser::TYPE_POPUP, app_name, params->window_bounds,
146 profile));
147 } 145 }
148 case NEW_WINDOW: { 146 case NEW_WINDOW: {
149 // Make a new normal browser window. 147 // Make a new normal browser window.
150 Browser* browser = new Browser(Browser::TYPE_TABBED, profile); 148 return new Browser(Browser::CreateParams(profile));
151 browser->InitBrowserWindow();
152 return browser;
153 } 149 }
154 case OFF_THE_RECORD: 150 case OFF_THE_RECORD:
155 // Make or find an incognito window. 151 // Make or find an incognito window.
156 return GetOrCreateBrowser(profile->GetOffTheRecordProfile()); 152 return GetOrCreateBrowser(profile->GetOffTheRecordProfile());
157 // The following types all result in no navigation. 153 // The following types all result in no navigation.
158 case SUPPRESS_OPEN: 154 case SUPPRESS_OPEN:
159 case SAVE_TO_DISK: 155 case SAVE_TO_DISK:
160 case IGNORE_ACTION: 156 case IGNORE_ACTION:
161 return NULL; 157 return NULL;
162 default: 158 default:
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 return !(url.scheme() == chrome::kChromeUIScheme && 584 return !(url.scheme() == chrome::kChromeUIScheme &&
589 (url.host() == chrome::kChromeUISettingsHost || 585 (url.host() == chrome::kChromeUISettingsHost ||
590 url.host() == chrome::kChromeUISettingsFrameHost || 586 url.host() == chrome::kChromeUISettingsFrameHost ||
591 url.host() == chrome::kChromeUIExtensionsHost || 587 url.host() == chrome::kChromeUIExtensionsHost ||
592 url.host() == chrome::kChromeUIBookmarksHost || 588 url.host() == chrome::kChromeUIBookmarksHost ||
593 url.host() == chrome::kChromeUISyncPromoHost || 589 url.host() == chrome::kChromeUISyncPromoHost ||
594 url.host() == chrome::kChromeUIUberHost)); 590 url.host() == chrome::kChromeUIUberHost));
595 } 591 }
596 592
597 } // namespace chrome 593 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_mac.cc ('k') | chrome/browser/ui/browser_navigator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698