| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); | 578 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); |
| 579 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the | 579 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the |
| 580 // window during the window's creation (before tabs have been added). | 580 // window during the window's creation (before tabs have been added). |
| 581 favicon::FaviconDriver* favicon_driver = | 581 favicon::FaviconDriver* favicon_driver = |
| 582 web_contents | 582 web_contents |
| 583 ? favicon::ContentFaviconDriver::FromWebContents(web_contents) | 583 ? favicon::ContentFaviconDriver::FromWebContents(web_contents) |
| 584 : nullptr; | 584 : nullptr; |
| 585 return favicon_driver ? favicon_driver->GetFavicon() : gfx::Image(); | 585 return favicon_driver ? favicon_driver->GetFavicon() : gfx::Image(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 base::string16 Browser::GetWindowTitleForCurrentTab() const { | 588 base::string16 Browser::GetWindowTitleForCurrentTab(bool accessible) const { |
| 589 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 589 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
| 590 base::string16 title; | 590 base::string16 title; |
| 591 | 591 |
| 592 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 592 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
| 593 // window during the window's creation (before tabs have been added). | 593 // window during the window's creation (before tabs have been added). |
| 594 if (contents) { | 594 if (contents) { |
| 595 // The web app frame uses the host instead of the title. | 595 // The web app frame uses the host instead of the title. |
| 596 if (ShouldUseWebAppFrame()) | 596 if (ShouldUseWebAppFrame()) |
| 597 return base::UTF8ToUTF16(contents->GetURL().host()); | 597 return base::UTF8ToUTF16(contents->GetURL().host()); |
| 598 | 598 |
| 599 title = contents->GetTitle(); | 599 title = contents->GetTitle(); |
| 600 FormatTitleForDisplay(&title); | 600 FormatTitleForDisplay(&title); |
| 601 } | 601 } |
| 602 if (title.empty()) | 602 if (title.empty()) |
| 603 title = CoreTabHelper::GetDefaultTitle(); | 603 title = CoreTabHelper::GetDefaultTitle(); |
| 604 | 604 |
| 605 #if defined(OS_MACOSX) || defined(USE_ASH) | 605 #if defined(OS_MACOSX) |
| 606 // On Mac and Ash, we don't want to suffix the page title with the application | 606 // On Mac, we don't want to suffix the page title with the application name. |
| 607 // name. | |
| 608 return title; | 607 return title; |
| 609 #endif | 608 #endif |
| 610 // Don't append the app name to window titles on app frames and app popups | 609 // Don't append the app name to window titles on app frames and app popups or |
| 611 return is_app() ? | 610 // for accessibility. |
| 611 return (is_app() || accessible) ? |
| 612 title : | 612 title : |
| 613 l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, title); | 613 l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, title); |
| 614 } | 614 } |
| 615 | 615 |
| 616 // static | 616 // static |
| 617 void Browser::FormatTitleForDisplay(base::string16* title) { | 617 void Browser::FormatTitleForDisplay(base::string16* title) { |
| 618 size_t current_index = 0; | 618 size_t current_index = 0; |
| 619 size_t match_index; | 619 size_t match_index; |
| 620 while ((match_index = title->find(L'\n', current_index)) != | 620 while ((match_index = title->find(L'\n', current_index)) != |
| 621 base::string16::npos) { | 621 base::string16::npos) { |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2598 if (contents && !allow_js_access) { | 2598 if (contents && !allow_js_access) { |
| 2599 contents->web_contents()->GetController().LoadURL( | 2599 contents->web_contents()->GetController().LoadURL( |
| 2600 target_url, | 2600 target_url, |
| 2601 content::Referrer(), | 2601 content::Referrer(), |
| 2602 ui::PAGE_TRANSITION_LINK, | 2602 ui::PAGE_TRANSITION_LINK, |
| 2603 std::string()); // No extra headers. | 2603 std::string()); // No extra headers. |
| 2604 } | 2604 } |
| 2605 | 2605 |
| 2606 return contents != NULL; | 2606 return contents != NULL; |
| 2607 } | 2607 } |
| OLD | NEW |