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 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 using ui::WebDialogDelegate; | 243 using ui::WebDialogDelegate; |
244 using web_modal::WebContentsModalDialogManager; | 244 using web_modal::WebContentsModalDialogManager; |
245 | 245 |
246 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
247 | 247 |
248 namespace { | 248 namespace { |
249 | 249 |
250 // How long we wait before updating the browser chrome while loading a page. | 250 // How long we wait before updating the browser chrome while loading a page. |
251 const int kUIUpdateCoalescingTimeMS = 200; | 251 const int kUIUpdateCoalescingTimeMS = 200; |
252 | 252 |
253 BrowserWindow* CreateBrowserWindow(Browser* browser) { | 253 BrowserWindow* CreateBrowserWindow(Browser* browser, bool user_gesture) { |
254 return BrowserWindow::CreateBrowserWindow(browser); | 254 return BrowserWindow::CreateBrowserWindow(browser, user_gesture); |
255 } | 255 } |
256 | 256 |
257 // Is the fast tab unload experiment enabled? | 257 // Is the fast tab unload experiment enabled? |
258 bool IsFastTabUnloadEnabled() { | 258 bool IsFastTabUnloadEnabled() { |
259 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 259 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
260 switches::kEnableFastUnload); | 260 switches::kEnableFastUnload); |
261 } | 261 } |
262 | 262 |
263 const extensions::Extension* GetExtensionForOrigin( | 263 const extensions::Extension* GetExtensionForOrigin( |
264 Profile* profile, | 264 Profile* profile, |
(...skipping 10 matching lines...) Expand all Loading... |
275 #else | 275 #else |
276 return nullptr; | 276 return nullptr; |
277 #endif | 277 #endif |
278 } | 278 } |
279 | 279 |
280 } // namespace | 280 } // namespace |
281 | 281 |
282 //////////////////////////////////////////////////////////////////////////////// | 282 //////////////////////////////////////////////////////////////////////////////// |
283 // Browser, CreateParams: | 283 // Browser, CreateParams: |
284 | 284 |
285 Browser::CreateParams::CreateParams(Profile* profile) | 285 Browser::CreateParams::CreateParams(Profile* profile, bool user_gesture) |
286 : type(TYPE_TABBED), | 286 : type(TYPE_TABBED), |
287 profile(profile), | 287 profile(profile), |
288 trusted_source(false), | 288 trusted_source(false), |
289 initial_show_state(ui::SHOW_STATE_DEFAULT), | 289 initial_show_state(ui::SHOW_STATE_DEFAULT), |
290 is_session_restore(false), | 290 is_session_restore(false), |
| 291 user_gesture(user_gesture), |
291 window(NULL) {} | 292 window(NULL) {} |
292 | 293 |
293 Browser::CreateParams::CreateParams(Type type, Profile* profile) | 294 Browser::CreateParams::CreateParams(Type type, |
| 295 Profile* profile, |
| 296 bool user_gesture) |
294 : type(type), | 297 : type(type), |
295 profile(profile), | 298 profile(profile), |
296 trusted_source(false), | 299 trusted_source(false), |
297 initial_show_state(ui::SHOW_STATE_DEFAULT), | 300 initial_show_state(ui::SHOW_STATE_DEFAULT), |
298 is_session_restore(false), | 301 is_session_restore(false), |
| 302 user_gesture(user_gesture), |
299 window(NULL) {} | 303 window(NULL) {} |
300 | 304 |
301 Browser::CreateParams::CreateParams(const CreateParams& other) = default; | 305 Browser::CreateParams::CreateParams(const CreateParams& other) = default; |
302 | 306 |
303 // static | 307 // static |
304 Browser::CreateParams Browser::CreateParams::CreateForApp( | 308 Browser::CreateParams Browser::CreateParams::CreateForApp( |
305 const std::string& app_name, | 309 const std::string& app_name, |
306 bool trusted_source, | 310 bool trusted_source, |
307 const gfx::Rect& window_bounds, | 311 const gfx::Rect& window_bounds, |
308 Profile* profile) { | 312 Profile* profile, |
| 313 bool user_gesture) { |
309 DCHECK(!app_name.empty()); | 314 DCHECK(!app_name.empty()); |
310 | 315 |
311 CreateParams params(TYPE_POPUP, profile); | 316 CreateParams params(TYPE_POPUP, profile, user_gesture); |
312 params.app_name = app_name; | 317 params.app_name = app_name; |
313 params.trusted_source = trusted_source; | 318 params.trusted_source = trusted_source; |
314 params.initial_bounds = window_bounds; | 319 params.initial_bounds = window_bounds; |
315 | 320 |
316 return params; | 321 return params; |
317 } | 322 } |
318 | 323 |
319 // static | 324 // static |
320 Browser::CreateParams Browser::CreateParams::CreateForDevTools( | 325 Browser::CreateParams Browser::CreateParams::CreateForDevTools( |
321 Profile* profile) { | 326 Profile* profile) { |
322 CreateParams params(TYPE_POPUP, profile); | 327 CreateParams params(TYPE_POPUP, profile, true); |
323 params.app_name = DevToolsWindow::kDevToolsApp; | 328 params.app_name = DevToolsWindow::kDevToolsApp; |
324 params.trusted_source = true; | 329 params.trusted_source = true; |
325 return params; | 330 return params; |
326 } | 331 } |
327 | 332 |
328 //////////////////////////////////////////////////////////////////////////////// | 333 //////////////////////////////////////////////////////////////////////////////// |
329 // Browser, InterstitialObserver: | 334 // Browser, InterstitialObserver: |
330 | 335 |
331 class Browser::InterstitialObserver : public content::WebContentsObserver { | 336 class Browser::InterstitialObserver : public content::WebContentsObserver { |
332 public: | 337 public: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 436 |
432 if (extensions::HostedAppBrowserController::IsForHostedApp(this)) { | 437 if (extensions::HostedAppBrowserController::IsForHostedApp(this)) { |
433 hosted_app_controller_.reset( | 438 hosted_app_controller_.reset( |
434 new extensions::HostedAppBrowserController(this)); | 439 new extensions::HostedAppBrowserController(this)); |
435 } | 440 } |
436 | 441 |
437 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); | 442 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); |
438 | 443 |
439 ProfileMetrics::LogProfileLaunch(profile_); | 444 ProfileMetrics::LogProfileLaunch(profile_); |
440 | 445 |
441 window_ = params.window ? params.window : CreateBrowserWindow(this); | 446 window_ = params.window ? params.window |
| 447 : CreateBrowserWindow(this, params.user_gesture); |
442 | 448 |
443 if (hosted_app_controller_) | 449 if (hosted_app_controller_) |
444 hosted_app_controller_->UpdateLocationBarVisibility(false); | 450 hosted_app_controller_->UpdateLocationBarVisibility(false); |
445 | 451 |
446 // Create the extension window controller before sending notifications. | 452 // Create the extension window controller before sending notifications. |
447 extension_window_controller_.reset( | 453 extension_window_controller_.reset( |
448 new BrowserExtensionWindowController(this)); | 454 new BrowserExtensionWindowController(this)); |
449 | 455 |
450 SessionService* session_service = | 456 SessionService* session_service = |
451 SessionServiceFactory::GetForProfileForSessionRestore(profile_); | 457 SessionServiceFactory::GetForProfileForSessionRestore(profile_); |
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 // new window later, thus we need to navigate the window now. | 2676 // new window later, thus we need to navigate the window now. |
2671 if (contents) { | 2677 if (contents) { |
2672 contents->web_contents()->GetController().LoadURL( | 2678 contents->web_contents()->GetController().LoadURL( |
2673 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2679 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2674 std::string()); // No extra headers. | 2680 std::string()); // No extra headers. |
2675 } | 2681 } |
2676 } | 2682 } |
2677 | 2683 |
2678 return contents != NULL; | 2684 return contents != NULL; |
2679 } | 2685 } |
OLD | NEW |