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_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/metrics/user_metrics.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
17 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 18 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
18 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 72 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
72 #include "components/zoom/page_zoom.h" | 73 #include "components/zoom/page_zoom.h" |
73 #include "components/zoom/zoom_controller.h" | 74 #include "components/zoom/zoom_controller.h" |
74 #include "content/public/browser/devtools_agent_host.h" | 75 #include "content/public/browser/devtools_agent_host.h" |
75 #include "content/public/browser/navigation_controller.h" | 76 #include "content/public/browser/navigation_controller.h" |
76 #include "content/public/browser/navigation_entry.h" | 77 #include "content/public/browser/navigation_entry.h" |
77 #include "content/public/browser/notification_service.h" | 78 #include "content/public/browser/notification_service.h" |
78 #include "content/public/browser/page_navigator.h" | 79 #include "content/public/browser/page_navigator.h" |
79 #include "content/public/browser/render_view_host.h" | 80 #include "content/public/browser/render_view_host.h" |
80 #include "content/public/browser/render_widget_host_view.h" | 81 #include "content/public/browser/render_widget_host_view.h" |
81 #include "content/public/browser/user_metrics.h" | |
82 #include "content/public/browser/web_contents.h" | 82 #include "content/public/browser/web_contents.h" |
83 #include "content/public/common/page_state.h" | 83 #include "content/public/common/page_state.h" |
84 #include "content/public/common/renderer_preferences.h" | 84 #include "content/public/common/renderer_preferences.h" |
85 #include "content/public/common/url_constants.h" | 85 #include "content/public/common/url_constants.h" |
86 #include "content/public/common/url_utils.h" | 86 #include "content/public/common/url_utils.h" |
87 #include "content/public/common/user_agent.h" | 87 #include "content/public/common/user_agent.h" |
88 #include "extensions/features/features.h" | 88 #include "extensions/features/features.h" |
89 #include "net/base/escape.h" | 89 #include "net/base/escape.h" |
90 #include "printing/features/features.h" | 90 #include "printing/features/features.h" |
91 #include "rlz/features/features.h" | 91 #include "rlz/features/features.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 incognito = false; | 371 incognito = false; |
372 } | 372 } |
373 } else if (profile->IsGuestSession() || | 373 } else if (profile->IsGuestSession() || |
374 (browser_defaults::kAlwaysOpenIncognitoWindow && | 374 (browser_defaults::kAlwaysOpenIncognitoWindow && |
375 IncognitoModePrefs::ShouldLaunchIncognito( | 375 IncognitoModePrefs::ShouldLaunchIncognito( |
376 *base::CommandLine::ForCurrentProcess(), prefs))) { | 376 *base::CommandLine::ForCurrentProcess(), prefs))) { |
377 incognito = true; | 377 incognito = true; |
378 } | 378 } |
379 | 379 |
380 if (incognito) { | 380 if (incognito) { |
381 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 381 base::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
382 OpenEmptyWindow(profile->GetOffTheRecordProfile()); | 382 OpenEmptyWindow(profile->GetOffTheRecordProfile()); |
383 } else { | 383 } else { |
384 content::RecordAction(UserMetricsAction("NewWindow")); | 384 base::RecordAction(UserMetricsAction("NewWindow")); |
385 SessionService* session_service = | 385 SessionService* session_service = |
386 SessionServiceFactory::GetForProfileForSessionRestore( | 386 SessionServiceFactory::GetForProfileForSessionRestore( |
387 profile->GetOriginalProfile()); | 387 profile->GetOriginalProfile()); |
388 if (!session_service || | 388 if (!session_service || |
389 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 389 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
390 OpenEmptyWindow(profile->GetOriginalProfile()); | 390 OpenEmptyWindow(profile->GetOriginalProfile()); |
391 } | 391 } |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
(...skipping 18 matching lines...) Expand all Loading... |
413 AddSelectedTabWithURL(displayer.browser(), url, | 413 AddSelectedTabWithURL(displayer.browser(), url, |
414 ui::PAGE_TRANSITION_LINK); | 414 ui::PAGE_TRANSITION_LINK); |
415 } | 415 } |
416 | 416 |
417 bool CanGoBack(const Browser* browser) { | 417 bool CanGoBack(const Browser* browser) { |
418 return browser->tab_strip_model()->GetActiveWebContents()-> | 418 return browser->tab_strip_model()->GetActiveWebContents()-> |
419 GetController().CanGoBack(); | 419 GetController().CanGoBack(); |
420 } | 420 } |
421 | 421 |
422 void GoBack(Browser* browser, WindowOpenDisposition disposition) { | 422 void GoBack(Browser* browser, WindowOpenDisposition disposition) { |
423 content::RecordAction(UserMetricsAction("Back")); | 423 base::RecordAction(UserMetricsAction("Back")); |
424 | 424 |
425 if (CanGoBack(browser)) { | 425 if (CanGoBack(browser)) { |
426 WebContents* current_tab = | 426 WebContents* current_tab = |
427 browser->tab_strip_model()->GetActiveWebContents(); | 427 browser->tab_strip_model()->GetActiveWebContents(); |
428 WebContents* new_tab = GetTabAndRevertIfNecessary(browser, disposition); | 428 WebContents* new_tab = GetTabAndRevertIfNecessary(browser, disposition); |
429 // If we are on an interstitial page and clone the tab, it won't be copied | 429 // If we are on an interstitial page and clone the tab, it won't be copied |
430 // to the new tab, so we don't need to go back. | 430 // to the new tab, so we don't need to go back. |
431 if ((new_tab == current_tab) || !current_tab->ShowingInterstitialPage()) | 431 if ((new_tab == current_tab) || !current_tab->ShowingInterstitialPage()) |
432 new_tab->GetController().GoBack(); | 432 new_tab->GetController().GoBack(); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 bool CanGoForward(const Browser* browser) { | 436 bool CanGoForward(const Browser* browser) { |
437 return browser->tab_strip_model()->GetActiveWebContents()-> | 437 return browser->tab_strip_model()->GetActiveWebContents()-> |
438 GetController().CanGoForward(); | 438 GetController().CanGoForward(); |
439 } | 439 } |
440 | 440 |
441 void GoForward(Browser* browser, WindowOpenDisposition disposition) { | 441 void GoForward(Browser* browser, WindowOpenDisposition disposition) { |
442 content::RecordAction(UserMetricsAction("Forward")); | 442 base::RecordAction(UserMetricsAction("Forward")); |
443 if (CanGoForward(browser)) { | 443 if (CanGoForward(browser)) { |
444 GetTabAndRevertIfNecessary(browser, disposition)-> | 444 GetTabAndRevertIfNecessary(browser, disposition)-> |
445 GetController().GoForward(); | 445 GetController().GoForward(); |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 bool NavigateToIndexWithDisposition(Browser* browser, | 449 bool NavigateToIndexWithDisposition(Browser* browser, |
450 int index, | 450 int index, |
451 WindowOpenDisposition disposition) { | 451 WindowOpenDisposition disposition) { |
452 NavigationController* controller = | 452 NavigationController* controller = |
453 &GetTabAndRevertIfNecessary(browser, disposition)->GetController(); | 453 &GetTabAndRevertIfNecessary(browser, disposition)->GetController(); |
454 if (index < 0 || index >= controller->GetEntryCount()) | 454 if (index < 0 || index >= controller->GetEntryCount()) |
455 return false; | 455 return false; |
456 controller->GoToIndex(index); | 456 controller->GoToIndex(index); |
457 return true; | 457 return true; |
458 } | 458 } |
459 | 459 |
460 void Reload(Browser* browser, WindowOpenDisposition disposition) { | 460 void Reload(Browser* browser, WindowOpenDisposition disposition) { |
461 content::RecordAction(UserMetricsAction("Reload")); | 461 base::RecordAction(UserMetricsAction("Reload")); |
462 ReloadInternal(browser, disposition, false); | 462 ReloadInternal(browser, disposition, false); |
463 } | 463 } |
464 | 464 |
465 void ReloadBypassingCache(Browser* browser, WindowOpenDisposition disposition) { | 465 void ReloadBypassingCache(Browser* browser, WindowOpenDisposition disposition) { |
466 content::RecordAction(UserMetricsAction("ReloadBypassingCache")); | 466 base::RecordAction(UserMetricsAction("ReloadBypassingCache")); |
467 ReloadInternal(browser, disposition, true); | 467 ReloadInternal(browser, disposition, true); |
468 } | 468 } |
469 | 469 |
470 bool CanReload(const Browser* browser) { | 470 bool CanReload(const Browser* browser) { |
471 return !browser->is_devtools(); | 471 return !browser->is_devtools(); |
472 } | 472 } |
473 | 473 |
474 void Home(Browser* browser, WindowOpenDisposition disposition) { | 474 void Home(Browser* browser, WindowOpenDisposition disposition) { |
475 content::RecordAction(UserMetricsAction("Home")); | 475 base::RecordAction(UserMetricsAction("Home")); |
476 | 476 |
477 std::string extra_headers; | 477 std::string extra_headers; |
478 #if BUILDFLAG(ENABLE_RLZ) | 478 #if BUILDFLAG(ENABLE_RLZ) |
479 // If the home page is a Google home page, add the RLZ header to the request. | 479 // If the home page is a Google home page, add the RLZ header to the request. |
480 PrefService* pref_service = browser->profile()->GetPrefs(); | 480 PrefService* pref_service = browser->profile()->GetPrefs(); |
481 if (pref_service) { | 481 if (pref_service) { |
482 if (google_util::IsGoogleHomePageUrl( | 482 if (google_util::IsGoogleHomePageUrl( |
483 GURL(pref_service->GetString(prefs::kHomePage)))) { | 483 GURL(pref_service->GetString(prefs::kHomePage)))) { |
484 extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader( | 484 extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader( |
485 rlz::RLZTracker::ChromeHomePage()); | 485 rlz::RLZTracker::ChromeHomePage()); |
(...skipping 27 matching lines...) Expand all Loading... |
513 url, Referrer(), disposition, | 513 url, Referrer(), disposition, |
514 ui::PageTransitionFromInt( | 514 ui::PageTransitionFromInt( |
515 ui::PAGE_TRANSITION_AUTO_BOOKMARK | | 515 ui::PAGE_TRANSITION_AUTO_BOOKMARK | |
516 ui::PAGE_TRANSITION_HOME_PAGE), | 516 ui::PAGE_TRANSITION_HOME_PAGE), |
517 false); | 517 false); |
518 params.extra_headers = extra_headers; | 518 params.extra_headers = extra_headers; |
519 browser->OpenURL(params); | 519 browser->OpenURL(params); |
520 } | 520 } |
521 | 521 |
522 void OpenCurrentURL(Browser* browser) { | 522 void OpenCurrentURL(Browser* browser) { |
523 content::RecordAction(UserMetricsAction("LoadURL")); | 523 base::RecordAction(UserMetricsAction("LoadURL")); |
524 LocationBar* location_bar = browser->window()->GetLocationBar(); | 524 LocationBar* location_bar = browser->window()->GetLocationBar(); |
525 if (!location_bar) | 525 if (!location_bar) |
526 return; | 526 return; |
527 | 527 |
528 GURL url(location_bar->GetDestinationURL()); | 528 GURL url(location_bar->GetDestinationURL()); |
529 | 529 |
530 ui::PageTransition page_transition = location_bar->GetPageTransition(); | 530 ui::PageTransition page_transition = location_bar->GetPageTransition(); |
531 WindowOpenDisposition open_disposition = | 531 WindowOpenDisposition open_disposition = |
532 location_bar->GetWindowOpenDisposition(); | 532 location_bar->GetWindowOpenDisposition(); |
533 // A PAGE_TRANSITION_TYPED means the user has typed a URL. We do not want to | 533 // A PAGE_TRANSITION_TYPED means the user has typed a URL. We do not want to |
(...skipping 28 matching lines...) Expand all Loading... |
562 extensions::ExtensionRegistry::Get(browser->profile()) | 562 extensions::ExtensionRegistry::Get(browser->profile()) |
563 ->enabled_extensions().GetAppByURL(url); | 563 ->enabled_extensions().GetAppByURL(url); |
564 if (extension) { | 564 if (extension) { |
565 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, | 565 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, |
566 extension->GetType()); | 566 extension->GetType()); |
567 } | 567 } |
568 #endif | 568 #endif |
569 } | 569 } |
570 | 570 |
571 void Stop(Browser* browser) { | 571 void Stop(Browser* browser) { |
572 content::RecordAction(UserMetricsAction("Stop")); | 572 base::RecordAction(UserMetricsAction("Stop")); |
573 browser->tab_strip_model()->GetActiveWebContents()->Stop(); | 573 browser->tab_strip_model()->GetActiveWebContents()->Stop(); |
574 } | 574 } |
575 | 575 |
576 void NewWindow(Browser* browser) { | 576 void NewWindow(Browser* browser) { |
577 NewEmptyWindow(browser->profile()->GetOriginalProfile()); | 577 NewEmptyWindow(browser->profile()->GetOriginalProfile()); |
578 } | 578 } |
579 | 579 |
580 void NewIncognitoWindow(Browser* browser) { | 580 void NewIncognitoWindow(Browser* browser) { |
581 NewEmptyWindow(browser->profile()->GetOffTheRecordProfile()); | 581 NewEmptyWindow(browser->profile()->GetOffTheRecordProfile()); |
582 } | 582 } |
583 | 583 |
584 void CloseWindow(Browser* browser) { | 584 void CloseWindow(Browser* browser) { |
585 content::RecordAction(UserMetricsAction("CloseWindow")); | 585 base::RecordAction(UserMetricsAction("CloseWindow")); |
586 browser->window()->Close(); | 586 browser->window()->Close(); |
587 } | 587 } |
588 | 588 |
589 void NewTab(Browser* browser) { | 589 void NewTab(Browser* browser) { |
590 content::RecordAction(UserMetricsAction("NewTab")); | 590 base::RecordAction(UserMetricsAction("NewTab")); |
591 // TODO(asvitkine): This is invoked programmatically from several places. | 591 // TODO(asvitkine): This is invoked programmatically from several places. |
592 // Audit the code and change it so that the histogram only gets collected for | 592 // Audit the code and change it so that the histogram only gets collected for |
593 // user-initiated commands. | 593 // user-initiated commands. |
594 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, | 594 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, |
595 TabStripModel::NEW_TAB_ENUM_COUNT); | 595 TabStripModel::NEW_TAB_ENUM_COUNT); |
596 | 596 |
597 if (browser->is_type_tabbed()) { | 597 if (browser->is_type_tabbed()) { |
598 AddTabAt(browser, GURL(), -1, true); | 598 AddTabAt(browser, GURL(), -1, true); |
599 browser->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); | 599 browser->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); |
600 } else { | 600 } else { |
601 ScopedTabbedBrowserDisplayer displayer(browser->profile()); | 601 ScopedTabbedBrowserDisplayer displayer(browser->profile()); |
602 Browser* b = displayer.browser(); | 602 Browser* b = displayer.browser(); |
603 AddTabAt(b, GURL(), -1, true); | 603 AddTabAt(b, GURL(), -1, true); |
604 b->window()->Show(); | 604 b->window()->Show(); |
605 // The call to AddBlankTabAt above did not set the focus to the tab as its | 605 // The call to AddBlankTabAt above did not set the focus to the tab as its |
606 // window was not active, so we have to do it explicitly. | 606 // window was not active, so we have to do it explicitly. |
607 // See http://crbug.com/6380. | 607 // See http://crbug.com/6380. |
608 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); | 608 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); |
609 } | 609 } |
610 } | 610 } |
611 | 611 |
612 void CloseTab(Browser* browser) { | 612 void CloseTab(Browser* browser) { |
613 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); | 613 base::RecordAction(UserMetricsAction("CloseTab_Accelerator")); |
614 browser->tab_strip_model()->CloseSelectedTabs(); | 614 browser->tab_strip_model()->CloseSelectedTabs(); |
615 } | 615 } |
616 | 616 |
617 bool CanZoomIn(content::WebContents* contents) { | 617 bool CanZoomIn(content::WebContents* contents) { |
618 return contents && !contents->IsCrashed() && | 618 return contents && !contents->IsCrashed() && |
619 zoom::ZoomController::FromWebContents(contents)->GetZoomPercent() != | 619 zoom::ZoomController::FromWebContents(contents)->GetZoomPercent() != |
620 contents->GetMaximumZoomPercent(); | 620 contents->GetMaximumZoomPercent(); |
621 } | 621 } |
622 | 622 |
623 bool CanZoomOut(content::WebContents* contents) { | 623 bool CanZoomOut(content::WebContents* contents) { |
(...skipping 14 matching lines...) Expand all Loading... |
638 sessions::TabRestoreService* service = | 638 sessions::TabRestoreService* service = |
639 TabRestoreServiceFactory::GetForProfile(browser->profile()); | 639 TabRestoreServiceFactory::GetForProfile(browser->profile()); |
640 if (!service || service->entries().empty()) | 640 if (!service || service->entries().empty()) |
641 return TabStripModelDelegate::RESTORE_NONE; | 641 return TabStripModelDelegate::RESTORE_NONE; |
642 if (service->entries().front()->type == sessions::TabRestoreService::WINDOW) | 642 if (service->entries().front()->type == sessions::TabRestoreService::WINDOW) |
643 return TabStripModelDelegate::RESTORE_WINDOW; | 643 return TabStripModelDelegate::RESTORE_WINDOW; |
644 return TabStripModelDelegate::RESTORE_TAB; | 644 return TabStripModelDelegate::RESTORE_TAB; |
645 } | 645 } |
646 | 646 |
647 void SelectNextTab(Browser* browser) { | 647 void SelectNextTab(Browser* browser) { |
648 content::RecordAction(UserMetricsAction("SelectNextTab")); | 648 base::RecordAction(UserMetricsAction("SelectNextTab")); |
649 browser->tab_strip_model()->SelectNextTab(); | 649 browser->tab_strip_model()->SelectNextTab(); |
650 } | 650 } |
651 | 651 |
652 void SelectPreviousTab(Browser* browser) { | 652 void SelectPreviousTab(Browser* browser) { |
653 content::RecordAction(UserMetricsAction("SelectPrevTab")); | 653 base::RecordAction(UserMetricsAction("SelectPrevTab")); |
654 browser->tab_strip_model()->SelectPreviousTab(); | 654 browser->tab_strip_model()->SelectPreviousTab(); |
655 } | 655 } |
656 | 656 |
657 void MoveTabNext(Browser* browser) { | 657 void MoveTabNext(Browser* browser) { |
658 content::RecordAction(UserMetricsAction("MoveTabNext")); | 658 base::RecordAction(UserMetricsAction("MoveTabNext")); |
659 browser->tab_strip_model()->MoveTabNext(); | 659 browser->tab_strip_model()->MoveTabNext(); |
660 } | 660 } |
661 | 661 |
662 void MoveTabPrevious(Browser* browser) { | 662 void MoveTabPrevious(Browser* browser) { |
663 content::RecordAction(UserMetricsAction("MoveTabPrevious")); | 663 base::RecordAction(UserMetricsAction("MoveTabPrevious")); |
664 browser->tab_strip_model()->MoveTabPrevious(); | 664 browser->tab_strip_model()->MoveTabPrevious(); |
665 } | 665 } |
666 | 666 |
667 void SelectNumberedTab(Browser* browser, int index) { | 667 void SelectNumberedTab(Browser* browser, int index) { |
668 if (index < browser->tab_strip_model()->count()) { | 668 if (index < browser->tab_strip_model()->count()) { |
669 content::RecordAction(UserMetricsAction("SelectNumberedTab")); | 669 base::RecordAction(UserMetricsAction("SelectNumberedTab")); |
670 browser->tab_strip_model()->ActivateTabAt(index, true); | 670 browser->tab_strip_model()->ActivateTabAt(index, true); |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
674 void SelectLastTab(Browser* browser) { | 674 void SelectLastTab(Browser* browser) { |
675 content::RecordAction(UserMetricsAction("SelectLastTab")); | 675 base::RecordAction(UserMetricsAction("SelectLastTab")); |
676 browser->tab_strip_model()->SelectLastTab(); | 676 browser->tab_strip_model()->SelectLastTab(); |
677 } | 677 } |
678 | 678 |
679 void DuplicateTab(Browser* browser) { | 679 void DuplicateTab(Browser* browser) { |
680 content::RecordAction(UserMetricsAction("Duplicate")); | 680 base::RecordAction(UserMetricsAction("Duplicate")); |
681 DuplicateTabAt(browser, browser->tab_strip_model()->active_index()); | 681 DuplicateTabAt(browser, browser->tab_strip_model()->active_index()); |
682 } | 682 } |
683 | 683 |
684 bool CanDuplicateTab(const Browser* browser) { | 684 bool CanDuplicateTab(const Browser* browser) { |
685 return CanDuplicateTabAt(browser, browser->tab_strip_model()->active_index()); | 685 return CanDuplicateTabAt(browser, browser->tab_strip_model()->active_index()); |
686 } | 686 } |
687 | 687 |
688 WebContents* DuplicateTabAt(Browser* browser, int index) { | 688 WebContents* DuplicateTabAt(Browser* browser, int index) { |
689 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(index); | 689 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(index); |
690 CHECK(contents); | 690 CHECK(contents); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 bool CanDuplicateTabAt(const Browser* browser, int index) { | 738 bool CanDuplicateTabAt(const Browser* browser, int index) { |
739 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(index); | 739 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(index); |
740 // If an interstitial is showing, do not allow tab duplication, since | 740 // If an interstitial is showing, do not allow tab duplication, since |
741 // the last committed entry is what would get duplicated and is not | 741 // the last committed entry is what would get duplicated and is not |
742 // what the user expects to duplicate. | 742 // what the user expects to duplicate. |
743 return contents && !contents->ShowingInterstitialPage() && | 743 return contents && !contents->ShowingInterstitialPage() && |
744 contents->GetController().GetLastCommittedEntry(); | 744 contents->GetController().GetLastCommittedEntry(); |
745 } | 745 } |
746 | 746 |
747 void ConvertPopupToTabbedBrowser(Browser* browser) { | 747 void ConvertPopupToTabbedBrowser(Browser* browser) { |
748 content::RecordAction(UserMetricsAction("ShowAsTab")); | 748 base::RecordAction(UserMetricsAction("ShowAsTab")); |
749 TabStripModel* tab_strip = browser->tab_strip_model(); | 749 TabStripModel* tab_strip = browser->tab_strip_model(); |
750 WebContents* contents = | 750 WebContents* contents = |
751 tab_strip->DetachWebContentsAt(tab_strip->active_index()); | 751 tab_strip->DetachWebContentsAt(tab_strip->active_index()); |
752 Browser* b = new Browser(Browser::CreateParams(browser->profile(), true)); | 752 Browser* b = new Browser(Browser::CreateParams(browser->profile(), true)); |
753 b->tab_strip_model()->AppendWebContents(contents, true); | 753 b->tab_strip_model()->AppendWebContents(contents, true); |
754 b->window()->Show(); | 754 b->window()->Show(); |
755 } | 755 } |
756 | 756 |
757 void Exit() { | 757 void Exit() { |
758 content::RecordAction(UserMetricsAction("Exit")); | 758 base::RecordAction(UserMetricsAction("Exit")); |
759 chrome::AttemptUserExit(); | 759 chrome::AttemptUserExit(); |
760 } | 760 } |
761 | 761 |
762 void BookmarkCurrentPageIgnoringExtensionOverrides(Browser* browser) { | 762 void BookmarkCurrentPageIgnoringExtensionOverrides(Browser* browser) { |
763 content::RecordAction(UserMetricsAction("Star")); | 763 base::RecordAction(UserMetricsAction("Star")); |
764 | 764 |
765 BookmarkModel* model = | 765 BookmarkModel* model = |
766 BookmarkModelFactory::GetForBrowserContext(browser->profile()); | 766 BookmarkModelFactory::GetForBrowserContext(browser->profile()); |
767 if (!model || !model->loaded()) | 767 if (!model || !model->loaded()) |
768 return; // Ignore requests until bookmarks are loaded. | 768 return; // Ignore requests until bookmarks are loaded. |
769 | 769 |
770 GURL url; | 770 GURL url; |
771 base::string16 title; | 771 base::string16 title; |
772 WebContents* web_contents = | 772 WebContents* web_contents = |
773 browser->tab_strip_model()->GetActiveWebContents(); | 773 browser->tab_strip_model()->GetActiveWebContents(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 } | 818 } |
819 #endif | 819 #endif |
820 BookmarkCurrentPageIgnoringExtensionOverrides(browser); | 820 BookmarkCurrentPageIgnoringExtensionOverrides(browser); |
821 } | 821 } |
822 | 822 |
823 bool CanBookmarkCurrentPage(const Browser* browser) { | 823 bool CanBookmarkCurrentPage(const Browser* browser) { |
824 return CanBookmarkCurrentPageInternal(browser, true); | 824 return CanBookmarkCurrentPageInternal(browser, true); |
825 } | 825 } |
826 | 826 |
827 void BookmarkAllTabs(Browser* browser) { | 827 void BookmarkAllTabs(Browser* browser) { |
828 content::RecordAction(UserMetricsAction("BookmarkAllTabs")); | 828 base::RecordAction(UserMetricsAction("BookmarkAllTabs")); |
829 chrome::ShowBookmarkAllTabsDialog(browser); | 829 chrome::ShowBookmarkAllTabsDialog(browser); |
830 } | 830 } |
831 | 831 |
832 bool CanBookmarkAllTabs(const Browser* browser) { | 832 bool CanBookmarkAllTabs(const Browser* browser) { |
833 return browser->tab_strip_model()->count() > 1 && | 833 return browser->tab_strip_model()->count() > 1 && |
834 !chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile()) && | 834 !chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile()) && |
835 CanBookmarkCurrentPageInternal(browser, false); | 835 CanBookmarkCurrentPageInternal(browser, false); |
836 } | 836 } |
837 | 837 |
838 void SaveCreditCard(Browser* browser) { | 838 void SaveCreditCard(Browser* browser) { |
(...skipping 29 matching lines...) Expand all Loading... |
868 void ManagePasswordsForPage(Browser* browser) { | 868 void ManagePasswordsForPage(Browser* browser) { |
869 WebContents* web_contents = | 869 WebContents* web_contents = |
870 browser->tab_strip_model()->GetActiveWebContents(); | 870 browser->tab_strip_model()->GetActiveWebContents(); |
871 ManagePasswordsUIController* controller = | 871 ManagePasswordsUIController* controller = |
872 ManagePasswordsUIController::FromWebContents(web_contents); | 872 ManagePasswordsUIController::FromWebContents(web_contents); |
873 TabDialogs::FromWebContents(web_contents)->ShowManagePasswordsBubble( | 873 TabDialogs::FromWebContents(web_contents)->ShowManagePasswordsBubble( |
874 !controller->IsAutomaticallyOpeningBubble()); | 874 !controller->IsAutomaticallyOpeningBubble()); |
875 } | 875 } |
876 | 876 |
877 void SavePage(Browser* browser) { | 877 void SavePage(Browser* browser) { |
878 content::RecordAction(UserMetricsAction("SavePage")); | 878 base::RecordAction(UserMetricsAction("SavePage")); |
879 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); | 879 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); |
880 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") | 880 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") |
881 content::RecordAction(UserMetricsAction("PDF.SavePage")); | 881 base::RecordAction(UserMetricsAction("PDF.SavePage")); |
882 current_tab->OnSavePage(); | 882 current_tab->OnSavePage(); |
883 } | 883 } |
884 | 884 |
885 bool CanSavePage(const Browser* browser) { | 885 bool CanSavePage(const Browser* browser) { |
886 // LocalState can be NULL in tests. | 886 // LocalState can be NULL in tests. |
887 if (g_browser_process->local_state() && | 887 if (g_browser_process->local_state() && |
888 !g_browser_process->local_state()->GetBoolean( | 888 !g_browser_process->local_state()->GetBoolean( |
889 prefs::kAllowFileSelectionDialogs)) { | 889 prefs::kAllowFileSelectionDialogs)) { |
890 return false; | 890 return false; |
891 } | 891 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 970 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
971 browser->tab_strip_model()->GetActiveWebContents()); | 971 browser->tab_strip_model()->GetActiveWebContents()); |
972 if (!dialog_controller) | 972 if (!dialog_controller) |
973 return; | 973 return; |
974 | 974 |
975 dialog_controller->ShowMediaRouterDialog(); | 975 dialog_controller->ShowMediaRouterDialog(); |
976 #endif // defined(ENABLE_MEDIA_ROUTER) | 976 #endif // defined(ENABLE_MEDIA_ROUTER) |
977 } | 977 } |
978 | 978 |
979 void EmailPageLocation(Browser* browser) { | 979 void EmailPageLocation(Browser* browser) { |
980 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 980 base::RecordAction(UserMetricsAction("EmailPageLocation")); |
981 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); | 981 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); |
982 DCHECK(wc); | 982 DCHECK(wc); |
983 | 983 |
984 std::string title = net::EscapeQueryParamValue( | 984 std::string title = net::EscapeQueryParamValue( |
985 base::UTF16ToUTF8(wc->GetTitle()), false); | 985 base::UTF16ToUTF8(wc->GetTitle()), false); |
986 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); | 986 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
987 std::string mailto = std::string("mailto:?subject=Fwd:%20") + | 987 std::string mailto = std::string("mailto:?subject=Fwd:%20") + |
988 title + "&body=%0A%0A" + page_url; | 988 title + "&body=%0A%0A" + page_url; |
989 platform_util::OpenExternal(browser->profile(), GURL(mailto)); | 989 platform_util::OpenExternal(browser->profile(), GURL(mailto)); |
990 } | 990 } |
991 | 991 |
992 bool CanEmailPageLocation(const Browser* browser) { | 992 bool CanEmailPageLocation(const Browser* browser) { |
993 return browser->toolbar_model()->ShouldDisplayURL() && | 993 return browser->toolbar_model()->ShouldDisplayURL() && |
994 browser->tab_strip_model()->GetActiveWebContents()->GetURL().is_valid(); | 994 browser->tab_strip_model()->GetActiveWebContents()->GetURL().is_valid(); |
995 } | 995 } |
996 | 996 |
997 void CutCopyPaste(Browser* browser, int command_id) { | 997 void CutCopyPaste(Browser* browser, int command_id) { |
998 if (command_id == IDC_CUT) | 998 if (command_id == IDC_CUT) |
999 content::RecordAction(UserMetricsAction("Cut")); | 999 base::RecordAction(UserMetricsAction("Cut")); |
1000 else if (command_id == IDC_COPY) | 1000 else if (command_id == IDC_COPY) |
1001 content::RecordAction(UserMetricsAction("Copy")); | 1001 base::RecordAction(UserMetricsAction("Copy")); |
1002 else | 1002 else |
1003 content::RecordAction(UserMetricsAction("Paste")); | 1003 base::RecordAction(UserMetricsAction("Paste")); |
1004 browser->window()->CutCopyPaste(command_id); | 1004 browser->window()->CutCopyPaste(command_id); |
1005 } | 1005 } |
1006 | 1006 |
1007 void Find(Browser* browser) { | 1007 void Find(Browser* browser) { |
1008 content::RecordAction(UserMetricsAction("Find")); | 1008 base::RecordAction(UserMetricsAction("Find")); |
1009 FindInPage(browser, false, false); | 1009 FindInPage(browser, false, false); |
1010 } | 1010 } |
1011 | 1011 |
1012 void FindNext(Browser* browser) { | 1012 void FindNext(Browser* browser) { |
1013 content::RecordAction(UserMetricsAction("FindNext")); | 1013 base::RecordAction(UserMetricsAction("FindNext")); |
1014 FindInPage(browser, true, true); | 1014 FindInPage(browser, true, true); |
1015 } | 1015 } |
1016 | 1016 |
1017 void FindPrevious(Browser* browser) { | 1017 void FindPrevious(Browser* browser) { |
1018 content::RecordAction(UserMetricsAction("FindPrevious")); | 1018 base::RecordAction(UserMetricsAction("FindPrevious")); |
1019 FindInPage(browser, true, false); | 1019 FindInPage(browser, true, false); |
1020 } | 1020 } |
1021 | 1021 |
1022 void FindInPage(Browser* browser, bool find_next, bool forward_direction) { | 1022 void FindInPage(Browser* browser, bool find_next, bool forward_direction) { |
1023 ShowFindBar(browser); | 1023 ShowFindBar(browser); |
1024 if (find_next) { | 1024 if (find_next) { |
1025 base::string16 find_text; | 1025 base::string16 find_text; |
1026 FindTabHelper* find_helper = FindTabHelper::FromWebContents( | 1026 FindTabHelper* find_helper = FindTabHelper::FromWebContents( |
1027 browser->tab_strip_model()->GetActiveWebContents()); | 1027 browser->tab_strip_model()->GetActiveWebContents()); |
1028 #if defined(OS_MACOSX) | 1028 #if defined(OS_MACOSX) |
1029 // We always want to search for the current contents of the find bar on | 1029 // We always want to search for the current contents of the find bar on |
1030 // OS X. For regular profile it's always the current find pboard. For | 1030 // OS X. For regular profile it's always the current find pboard. For |
1031 // Incognito window it's the newest value of the find pboard content and | 1031 // Incognito window it's the newest value of the find pboard content and |
1032 // user-typed text. | 1032 // user-typed text. |
1033 FindBar* find_bar = browser->GetFindBarController()->find_bar(); | 1033 FindBar* find_bar = browser->GetFindBarController()->find_bar(); |
1034 find_text = find_bar->GetFindText(); | 1034 find_text = find_bar->GetFindText(); |
1035 #endif | 1035 #endif |
1036 find_helper->StartFinding(find_text, forward_direction, false); | 1036 find_helper->StartFinding(find_text, forward_direction, false); |
1037 } | 1037 } |
1038 } | 1038 } |
1039 | 1039 |
1040 void Zoom(Browser* browser, content::PageZoom zoom) { | 1040 void Zoom(Browser* browser, content::PageZoom zoom) { |
1041 zoom::PageZoom::Zoom(browser->tab_strip_model()->GetActiveWebContents(), | 1041 zoom::PageZoom::Zoom(browser->tab_strip_model()->GetActiveWebContents(), |
1042 zoom); | 1042 zoom); |
1043 } | 1043 } |
1044 | 1044 |
1045 void FocusToolbar(Browser* browser) { | 1045 void FocusToolbar(Browser* browser) { |
1046 content::RecordAction(UserMetricsAction("FocusToolbar")); | 1046 base::RecordAction(UserMetricsAction("FocusToolbar")); |
1047 browser->window()->FocusToolbar(); | 1047 browser->window()->FocusToolbar(); |
1048 } | 1048 } |
1049 | 1049 |
1050 void FocusLocationBar(Browser* browser) { | 1050 void FocusLocationBar(Browser* browser) { |
1051 content::RecordAction(UserMetricsAction("FocusLocation")); | 1051 base::RecordAction(UserMetricsAction("FocusLocation")); |
1052 browser->window()->SetFocusToLocationBar(true); | 1052 browser->window()->SetFocusToLocationBar(true); |
1053 } | 1053 } |
1054 | 1054 |
1055 void FocusSearch(Browser* browser) { | 1055 void FocusSearch(Browser* browser) { |
1056 // TODO(beng): replace this with FocusLocationBar | 1056 // TODO(beng): replace this with FocusLocationBar |
1057 content::RecordAction(UserMetricsAction("FocusSearch")); | 1057 base::RecordAction(UserMetricsAction("FocusSearch")); |
1058 browser->window()->GetLocationBar()->FocusSearch(); | 1058 browser->window()->GetLocationBar()->FocusSearch(); |
1059 } | 1059 } |
1060 | 1060 |
1061 void FocusAppMenu(Browser* browser) { | 1061 void FocusAppMenu(Browser* browser) { |
1062 content::RecordAction(UserMetricsAction("FocusAppMenu")); | 1062 base::RecordAction(UserMetricsAction("FocusAppMenu")); |
1063 browser->window()->FocusAppMenu(); | 1063 browser->window()->FocusAppMenu(); |
1064 } | 1064 } |
1065 | 1065 |
1066 void FocusBookmarksToolbar(Browser* browser) { | 1066 void FocusBookmarksToolbar(Browser* browser) { |
1067 content::RecordAction(UserMetricsAction("FocusBookmarksToolbar")); | 1067 base::RecordAction(UserMetricsAction("FocusBookmarksToolbar")); |
1068 browser->window()->FocusBookmarksToolbar(); | 1068 browser->window()->FocusBookmarksToolbar(); |
1069 } | 1069 } |
1070 | 1070 |
1071 void FocusInfobars(Browser* browser) { | 1071 void FocusInfobars(Browser* browser) { |
1072 content::RecordAction(UserMetricsAction("FocusInfobars")); | 1072 base::RecordAction(UserMetricsAction("FocusInfobars")); |
1073 browser->window()->FocusInfobars(); | 1073 browser->window()->FocusInfobars(); |
1074 } | 1074 } |
1075 | 1075 |
1076 void FocusNextPane(Browser* browser) { | 1076 void FocusNextPane(Browser* browser) { |
1077 content::RecordAction(UserMetricsAction("FocusNextPane")); | 1077 base::RecordAction(UserMetricsAction("FocusNextPane")); |
1078 browser->window()->RotatePaneFocus(true); | 1078 browser->window()->RotatePaneFocus(true); |
1079 } | 1079 } |
1080 | 1080 |
1081 void FocusPreviousPane(Browser* browser) { | 1081 void FocusPreviousPane(Browser* browser) { |
1082 content::RecordAction(UserMetricsAction("FocusPreviousPane")); | 1082 base::RecordAction(UserMetricsAction("FocusPreviousPane")); |
1083 browser->window()->RotatePaneFocus(false); | 1083 browser->window()->RotatePaneFocus(false); |
1084 } | 1084 } |
1085 | 1085 |
1086 void ToggleDevToolsWindow(Browser* browser, DevToolsToggleAction action) { | 1086 void ToggleDevToolsWindow(Browser* browser, DevToolsToggleAction action) { |
1087 if (action.type() == DevToolsToggleAction::kShowConsolePanel) | 1087 if (action.type() == DevToolsToggleAction::kShowConsolePanel) |
1088 content::RecordAction(UserMetricsAction("DevTools_ToggleConsole")); | 1088 base::RecordAction(UserMetricsAction("DevTools_ToggleConsole")); |
1089 else | 1089 else |
1090 content::RecordAction(UserMetricsAction("DevTools_ToggleWindow")); | 1090 base::RecordAction(UserMetricsAction("DevTools_ToggleWindow")); |
1091 DevToolsWindow::ToggleDevToolsWindow(browser, action); | 1091 DevToolsWindow::ToggleDevToolsWindow(browser, action); |
1092 } | 1092 } |
1093 | 1093 |
1094 bool CanOpenTaskManager() { | 1094 bool CanOpenTaskManager() { |
1095 #if !defined(OS_ANDROID) | 1095 #if !defined(OS_ANDROID) |
1096 return true; | 1096 return true; |
1097 #else | 1097 #else |
1098 return false; | 1098 return false; |
1099 #endif | 1099 #endif |
1100 } | 1100 } |
1101 | 1101 |
1102 void OpenTaskManager(Browser* browser) { | 1102 void OpenTaskManager(Browser* browser) { |
1103 #if !defined(OS_ANDROID) | 1103 #if !defined(OS_ANDROID) |
1104 content::RecordAction(UserMetricsAction("TaskManager")); | 1104 base::RecordAction(UserMetricsAction("TaskManager")); |
1105 chrome::ShowTaskManager(browser); | 1105 chrome::ShowTaskManager(browser); |
1106 #else | 1106 #else |
1107 NOTREACHED(); | 1107 NOTREACHED(); |
1108 #endif | 1108 #endif |
1109 } | 1109 } |
1110 | 1110 |
1111 void OpenFeedbackDialog(Browser* browser) { | 1111 void OpenFeedbackDialog(Browser* browser) { |
1112 content::RecordAction(UserMetricsAction("Feedback")); | 1112 base::RecordAction(UserMetricsAction("Feedback")); |
1113 chrome::ShowFeedbackPage(browser, std::string(), std::string()); | 1113 chrome::ShowFeedbackPage(browser, std::string(), std::string()); |
1114 } | 1114 } |
1115 | 1115 |
1116 void ToggleBookmarkBar(Browser* browser) { | 1116 void ToggleBookmarkBar(Browser* browser) { |
1117 content::RecordAction(UserMetricsAction("ShowBookmarksBar")); | 1117 base::RecordAction(UserMetricsAction("ShowBookmarksBar")); |
1118 ToggleBookmarkBarWhenVisible(browser->profile()); | 1118 ToggleBookmarkBarWhenVisible(browser->profile()); |
1119 } | 1119 } |
1120 | 1120 |
1121 void ShowAppMenu(Browser* browser) { | 1121 void ShowAppMenu(Browser* browser) { |
1122 // We record the user metric for this event in AppMenu::RunMenu. | 1122 // We record the user metric for this event in AppMenu::RunMenu. |
1123 browser->window()->ShowAppMenu(); | 1123 browser->window()->ShowAppMenu(); |
1124 } | 1124 } |
1125 | 1125 |
1126 void ShowAvatarMenu(Browser* browser) { | 1126 void ShowAvatarMenu(Browser* browser) { |
1127 browser->window()->ShowAvatarBubbleFromAvatarButton( | 1127 browser->window()->ShowAvatarBubbleFromAvatarButton( |
1128 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT, signin::ManageAccountsParams(), | 1128 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT, signin::ManageAccountsParams(), |
1129 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN, true); | 1129 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN, true); |
1130 } | 1130 } |
1131 | 1131 |
1132 void OpenUpdateChromeDialog(Browser* browser) { | 1132 void OpenUpdateChromeDialog(Browser* browser) { |
1133 if (UpgradeDetector::GetInstance()->is_outdated_install()) { | 1133 if (UpgradeDetector::GetInstance()->is_outdated_install()) { |
1134 content::NotificationService::current()->Notify( | 1134 content::NotificationService::current()->Notify( |
1135 chrome::NOTIFICATION_OUTDATED_INSTALL, | 1135 chrome::NOTIFICATION_OUTDATED_INSTALL, |
1136 content::NotificationService::AllSources(), | 1136 content::NotificationService::AllSources(), |
1137 content::NotificationService::NoDetails()); | 1137 content::NotificationService::NoDetails()); |
1138 } else if (UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { | 1138 } else if (UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { |
1139 content::NotificationService::current()->Notify( | 1139 content::NotificationService::current()->Notify( |
1140 chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU, | 1140 chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU, |
1141 content::NotificationService::AllSources(), | 1141 content::NotificationService::AllSources(), |
1142 content::NotificationService::NoDetails()); | 1142 content::NotificationService::NoDetails()); |
1143 } else { | 1143 } else { |
1144 content::RecordAction(UserMetricsAction("UpdateChrome")); | 1144 base::RecordAction(UserMetricsAction("UpdateChrome")); |
1145 browser->window()->ShowUpdateChromeDialog(); | 1145 browser->window()->ShowUpdateChromeDialog(); |
1146 } | 1146 } |
1147 } | 1147 } |
1148 | 1148 |
1149 void DistillCurrentPage(Browser* browser) { | 1149 void DistillCurrentPage(Browser* browser) { |
1150 DistillCurrentPageAndView(browser->tab_strip_model()->GetActiveWebContents()); | 1150 DistillCurrentPageAndView(browser->tab_strip_model()->GetActiveWebContents()); |
1151 } | 1151 } |
1152 | 1152 |
1153 bool CanRequestTabletSite(WebContents* current_tab) { | 1153 bool CanRequestTabletSite(WebContents* current_tab) { |
1154 return current_tab && | 1154 return current_tab && |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 if (!entry) | 1216 if (!entry) |
1217 return; | 1217 return; |
1218 | 1218 |
1219 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); | 1219 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); |
1220 } | 1220 } |
1221 | 1221 |
1222 void ViewSource(Browser* browser, | 1222 void ViewSource(Browser* browser, |
1223 WebContents* contents, | 1223 WebContents* contents, |
1224 const GURL& url, | 1224 const GURL& url, |
1225 const content::PageState& page_state) { | 1225 const content::PageState& page_state) { |
1226 content::RecordAction(UserMetricsAction("ViewSource")); | 1226 base::RecordAction(UserMetricsAction("ViewSource")); |
1227 DCHECK(contents); | 1227 DCHECK(contents); |
1228 | 1228 |
1229 WebContents* view_source_contents = contents->Clone(); | 1229 WebContents* view_source_contents = contents->Clone(); |
1230 DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted()); | 1230 DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted()); |
1231 view_source_contents->GetController().PruneAllButLastCommitted(); | 1231 view_source_contents->GetController().PruneAllButLastCommitted(); |
1232 NavigationEntry* last_committed_entry = | 1232 NavigationEntry* last_committed_entry = |
1233 view_source_contents->GetController().GetLastCommittedEntry(); | 1233 view_source_contents->GetController().GetLastCommittedEntry(); |
1234 if (!last_committed_entry) | 1234 if (!last_committed_entry) |
1235 return; | 1235 return; |
1236 | 1236 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 } | 1288 } |
1289 | 1289 |
1290 bool CanViewSource(const Browser* browser) { | 1290 bool CanViewSource(const Browser* browser) { |
1291 return !browser->is_devtools() && | 1291 return !browser->is_devtools() && |
1292 browser->tab_strip_model()->GetActiveWebContents()->GetController(). | 1292 browser->tab_strip_model()->GetActiveWebContents()->GetController(). |
1293 CanViewSource(); | 1293 CanViewSource(); |
1294 } | 1294 } |
1295 | 1295 |
1296 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1296 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1297 void CreateApplicationShortcuts(Browser* browser) { | 1297 void CreateApplicationShortcuts(Browser* browser) { |
1298 content::RecordAction(UserMetricsAction("CreateShortcut")); | 1298 base::RecordAction(UserMetricsAction("CreateShortcut")); |
1299 extensions::TabHelper::FromWebContents( | 1299 extensions::TabHelper::FromWebContents( |
1300 browser->tab_strip_model()->GetActiveWebContents())-> | 1300 browser->tab_strip_model()->GetActiveWebContents())-> |
1301 CreateApplicationShortcuts(); | 1301 CreateApplicationShortcuts(); |
1302 } | 1302 } |
1303 | 1303 |
1304 void CreateBookmarkAppFromCurrentWebContents(Browser* browser) { | 1304 void CreateBookmarkAppFromCurrentWebContents(Browser* browser) { |
1305 content::RecordAction(UserMetricsAction("CreateHostedApp")); | 1305 base::RecordAction(UserMetricsAction("CreateHostedApp")); |
1306 extensions::TabHelper::FromWebContents( | 1306 extensions::TabHelper::FromWebContents( |
1307 browser->tab_strip_model()->GetActiveWebContents())-> | 1307 browser->tab_strip_model()->GetActiveWebContents())-> |
1308 CreateHostedAppFromWebContents(); | 1308 CreateHostedAppFromWebContents(); |
1309 } | 1309 } |
1310 | 1310 |
1311 bool CanCreateApplicationShortcuts(const Browser* browser) { | 1311 bool CanCreateApplicationShortcuts(const Browser* browser) { |
1312 return extensions::TabHelper::FromWebContents( | 1312 return extensions::TabHelper::FromWebContents( |
1313 browser->tab_strip_model()->GetActiveWebContents())-> | 1313 browser->tab_strip_model()->GetActiveWebContents())-> |
1314 CanCreateApplicationShortcuts(); | 1314 CanCreateApplicationShortcuts(); |
1315 } | 1315 } |
(...skipping 18 matching lines...) Expand all Loading... |
1334 true)); | 1334 true)); |
1335 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1335 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1336 | 1336 |
1337 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1337 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1338 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1338 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1339 app_browser->window()->Show(); | 1339 app_browser->window()->Show(); |
1340 } | 1340 } |
1341 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 1341 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
1342 | 1342 |
1343 } // namespace chrome | 1343 } // namespace chrome |
OLD | NEW |