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