OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } // namespace | 245 } // namespace |
246 | 246 |
247 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
248 // Browser, CreateParams: | 248 // Browser, CreateParams: |
249 | 249 |
250 Browser::CreateParams::CreateParams(Profile* profile, | 250 Browser::CreateParams::CreateParams(Profile* profile, |
251 chrome::HostDesktopType host_desktop_type) | 251 chrome::HostDesktopType host_desktop_type) |
252 : type(TYPE_TABBED), | 252 : type(TYPE_TABBED), |
253 profile(profile), | 253 profile(profile), |
254 host_desktop_type(host_desktop_type), | 254 host_desktop_type(host_desktop_type), |
255 app_type(APP_TYPE_HOST), | |
256 initial_show_state(ui::SHOW_STATE_DEFAULT), | 255 initial_show_state(ui::SHOW_STATE_DEFAULT), |
257 is_session_restore(false), | 256 is_session_restore(false), |
258 window(NULL) { | 257 window(NULL) { |
259 } | 258 } |
260 | 259 |
261 Browser::CreateParams::CreateParams(Type type, | 260 Browser::CreateParams::CreateParams(Type type, |
262 Profile* profile, | 261 Profile* profile, |
263 chrome::HostDesktopType host_desktop_type) | 262 chrome::HostDesktopType host_desktop_type) |
264 : type(type), | 263 : type(type), |
265 profile(profile), | 264 profile(profile), |
266 host_desktop_type(host_desktop_type), | 265 host_desktop_type(host_desktop_type), |
267 app_type(APP_TYPE_HOST), | |
268 initial_show_state(ui::SHOW_STATE_DEFAULT), | 266 initial_show_state(ui::SHOW_STATE_DEFAULT), |
269 is_session_restore(false), | 267 is_session_restore(false), |
270 window(NULL) { | 268 window(NULL) { |
271 } | 269 } |
272 | 270 |
273 // static | 271 // static |
274 Browser::CreateParams Browser::CreateParams::CreateForApp( | 272 Browser::CreateParams Browser::CreateParams::CreateForApp( |
275 Type type, | 273 Type type, |
276 const std::string& app_name, | 274 const std::string& app_name, |
277 const gfx::Rect& window_bounds, | 275 const gfx::Rect& window_bounds, |
278 Profile* profile, | 276 Profile* profile, |
279 chrome::HostDesktopType host_desktop_type) { | 277 chrome::HostDesktopType host_desktop_type) { |
280 DCHECK(type != TYPE_TABBED); | 278 DCHECK(type != TYPE_TABBED); |
281 DCHECK(!app_name.empty()); | 279 DCHECK(!app_name.empty()); |
282 | 280 |
283 CreateParams params(type, profile, host_desktop_type); | 281 CreateParams params(type, profile, host_desktop_type); |
284 params.app_name = app_name; | 282 params.app_name = app_name; |
285 params.app_type = APP_TYPE_CHILD; | |
286 params.initial_bounds = window_bounds; | 283 params.initial_bounds = window_bounds; |
287 | 284 |
288 return params; | 285 return params; |
289 } | 286 } |
290 | 287 |
291 // static | 288 // static |
292 Browser::CreateParams Browser::CreateParams::CreateForDevTools( | 289 Browser::CreateParams Browser::CreateParams::CreateForDevTools( |
293 Profile* profile, | 290 Profile* profile, |
294 chrome::HostDesktopType host_desktop_type) { | 291 chrome::HostDesktopType host_desktop_type) { |
295 CreateParams params(TYPE_POPUP, profile, host_desktop_type); | 292 CreateParams params(TYPE_POPUP, profile, host_desktop_type); |
(...skipping 30 matching lines...) Expand all Loading... |
326 /////////////////////////////////////////////////////////////////////////////// | 323 /////////////////////////////////////////////////////////////////////////////// |
327 // Browser, Constructors, Creation, Showing: | 324 // Browser, Constructors, Creation, Showing: |
328 | 325 |
329 Browser::Browser(const CreateParams& params) | 326 Browser::Browser(const CreateParams& params) |
330 : type_(params.type), | 327 : type_(params.type), |
331 profile_(params.profile), | 328 profile_(params.profile), |
332 window_(NULL), | 329 window_(NULL), |
333 tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)), | 330 tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)), |
334 tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(), | 331 tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(), |
335 params.profile)), | 332 params.profile)), |
336 app_name_(params.app_name), | |
337 app_type_(params.app_type), | |
338 cancel_download_confirmation_state_(NOT_PROMPTED), | 333 cancel_download_confirmation_state_(NOT_PROMPTED), |
339 override_bounds_(params.initial_bounds), | 334 override_bounds_(params.initial_bounds), |
340 initial_show_state_(params.initial_show_state), | 335 initial_show_state_(params.initial_show_state), |
341 is_session_restore_(params.is_session_restore), | 336 is_session_restore_(params.is_session_restore), |
342 host_desktop_type_(BrowserWindow::AdjustHostDesktopType( | 337 host_desktop_type_(BrowserWindow::AdjustHostDesktopType( |
343 params.host_desktop_type)), | 338 params.host_desktop_type)), |
344 content_setting_bubble_model_delegate_( | 339 content_setting_bubble_model_delegate_( |
345 new BrowserContentSettingBubbleModelDelegate(this)), | 340 new BrowserContentSettingBubbleModelDelegate(this)), |
346 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), | 341 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), |
347 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)), | 342 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)), |
348 synced_window_delegate_(new BrowserSyncedWindowDelegate(this)), | 343 synced_window_delegate_(new BrowserSyncedWindowDelegate(this)), |
349 bookmark_bar_state_(BookmarkBar::HIDDEN), | 344 bookmark_bar_state_(BookmarkBar::HIDDEN), |
350 command_controller_(new chrome::BrowserCommandController( | 345 command_controller_(new chrome::BrowserCommandController( |
351 this, g_browser_process->profile_manager())), | 346 this, g_browser_process->profile_manager())), |
352 window_has_shown_(false), | 347 window_has_shown_(false), |
353 chrome_updater_factory_(this), | 348 chrome_updater_factory_(this), |
354 weak_factory_(this), | 349 weak_factory_(this), |
355 translate_driver_observer_( | 350 translate_driver_observer_( |
356 new BrowserContentTranslateDriverObserver(this)) { | 351 new BrowserContentTranslateDriverObserver(this)) { |
| 352 app_name_ = params.app_name; |
| 353 |
357 // If this causes a crash then a window is being opened using a profile type | 354 // If this causes a crash then a window is being opened using a profile type |
358 // that is disallowed by policy. The crash prevents the disabled window type | 355 // that is disallowed by policy. The crash prevents the disabled window type |
359 // from opening at all, but the path that triggered it should be fixed. | 356 // from opening at all, but the path that triggered it should be fixed. |
360 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); | 357 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); |
361 CHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord()) | 358 CHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord()) |
362 << "Only off the record browser may be opened in guest mode"; | 359 << "Only off the record browser may be opened in guest mode"; |
363 | 360 |
364 // TODO(jeremy): Move to initializer list once flag is removed. | 361 // TODO(jeremy): Move to initializer list once flag is removed. |
365 if (IsFastTabUnloadEnabled()) | 362 if (IsFastTabUnloadEnabled()) |
366 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); | 363 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); |
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 if (is_type_tabbed()) | 2203 if (is_type_tabbed()) |
2207 features |= FEATURE_TOOLBAR; | 2204 features |= FEATURE_TOOLBAR; |
2208 | 2205 |
2209 ExtensionService* service = | 2206 ExtensionService* service = |
2210 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 2207 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
2211 const extensions::Extension* extension = | 2208 const extensions::Extension* extension = |
2212 service ? service->GetInstalledExtension( | 2209 service ? service->GetInstalledExtension( |
2213 web_app::GetExtensionIdFromApplicationName(app_name())) | 2210 web_app::GetExtensionIdFromApplicationName(app_name())) |
2214 : NULL; | 2211 : NULL; |
2215 | 2212 |
2216 if (!is_app() || (app_type() == APP_TYPE_HOST && | 2213 if (!is_app() || (type() == TYPE_HOSTED_POPUP && |
2217 app_name() != DevToolsWindow::kDevToolsApp && | 2214 app_name() != DevToolsWindow::kDevToolsApp && |
2218 (!extension || !extension->is_legacy_packaged_app()) && | 2215 (!extension || !extension->is_legacy_packaged_app()) && |
2219 CommandLine::ForCurrentProcess()->HasSwitch( | 2216 CommandLine::ForCurrentProcess()->HasSwitch( |
2220 switches::kEnableStreamlinedHostedApps))) { | 2217 switches::kEnableStreamlinedHostedApps))) { |
2221 features |= FEATURE_LOCATIONBAR; | 2218 features |= FEATURE_LOCATIONBAR; |
2222 } | 2219 } |
2223 } | 2220 } |
2224 return !!(features & feature); | 2221 return !!(features & feature); |
2225 } | 2222 } |
2226 | 2223 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 if (contents && !allow_js_access) { | 2342 if (contents && !allow_js_access) { |
2346 contents->web_contents()->GetController().LoadURL( | 2343 contents->web_contents()->GetController().LoadURL( |
2347 target_url, | 2344 target_url, |
2348 content::Referrer(), | 2345 content::Referrer(), |
2349 content::PAGE_TRANSITION_LINK, | 2346 content::PAGE_TRANSITION_LINK, |
2350 std::string()); // No extra headers. | 2347 std::string()); // No extra headers. |
2351 } | 2348 } |
2352 | 2349 |
2353 return contents != NULL; | 2350 return contents != NULL; |
2354 } | 2351 } |
OLD | NEW |