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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 } | 576 } |
577 | 577 |
578 base::string16 Browser::GetWindowTitleForCurrentTab( | 578 base::string16 Browser::GetWindowTitleForCurrentTab( |
579 bool include_app_name) const { | 579 bool include_app_name) const { |
580 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 580 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
581 base::string16 title; | 581 base::string16 title; |
582 | 582 |
583 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 583 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
584 // window during the window's creation (before tabs have been added). | 584 // window during the window's creation (before tabs have been added). |
585 if (contents) { | 585 if (contents) { |
586 // The web app frame uses the host instead of the title. | |
587 if (ShouldUseWebAppFrame()) | |
588 return base::UTF8ToUTF16(contents->GetURL().host()); | |
589 | |
590 title = contents->GetTitle(); | 586 title = contents->GetTitle(); |
591 FormatTitleForDisplay(&title); | 587 FormatTitleForDisplay(&title); |
592 } | 588 } |
593 if (title.empty()) | 589 if (title.empty()) |
594 title = CoreTabHelper::GetDefaultTitle(); | 590 title = CoreTabHelper::GetDefaultTitle(); |
595 | 591 |
596 #if defined(OS_MACOSX) | 592 #if defined(OS_MACOSX) |
597 // On Mac, we don't want to suffix the page title with the application name. | 593 // On Mac, we don't want to suffix the page title with the application name. |
598 return title; | 594 return title; |
599 #endif | 595 #endif |
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 bool Browser::SupportsLocationBar() const { | 2397 bool Browser::SupportsLocationBar() const { |
2402 // Tabbed browser always show a location bar. | 2398 // Tabbed browser always show a location bar. |
2403 if (is_type_tabbed()) | 2399 if (is_type_tabbed()) |
2404 return true; | 2400 return true; |
2405 | 2401 |
2406 // Non-app windows that aren't tabbed or system windows should always show a | 2402 // Non-app windows that aren't tabbed or system windows should always show a |
2407 // location bar, unless they are from a trusted source. | 2403 // location bar, unless they are from a trusted source. |
2408 if (!is_app()) | 2404 if (!is_app()) |
2409 return !is_trusted_source(); | 2405 return !is_trusted_source(); |
2410 | 2406 |
| 2407 // Hosted apps always support a location bar. |
2411 if (hosted_app_controller_) | 2408 if (hosted_app_controller_) |
2412 return hosted_app_controller_->SupportsLocationBar(); | 2409 return true; |
2413 | 2410 |
2414 return false; | 2411 return false; |
2415 } | 2412 } |
2416 | |
2417 bool Browser::ShouldUseWebAppFrame() const { | |
2418 // Only use the web app frame for apps in ash, and only if the web app frame | |
2419 // is enabled. | |
2420 if (!is_app()) | |
2421 return false; | |
2422 | |
2423 if (hosted_app_controller_) | |
2424 return hosted_app_controller_->should_use_web_app_frame(); | |
2425 | |
2426 return false; | |
2427 } | |
2428 | 2413 |
2429 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, | 2414 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, |
2430 bool check_fullscreen) const { | 2415 bool check_fullscreen) const { |
2431 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); | 2416 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); |
2432 | 2417 |
2433 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; | 2418 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; |
2434 | 2419 |
2435 if (is_type_tabbed()) | 2420 if (is_type_tabbed()) |
2436 features |= FEATURE_BOOKMARKBAR; | 2421 features |= FEATURE_BOOKMARKBAR; |
2437 | 2422 |
2438 if (!hide_ui_for_fullscreen) { | 2423 if (!hide_ui_for_fullscreen) { |
2439 if (!is_type_tabbed()) | 2424 if (!is_type_tabbed()) |
2440 features |= FEATURE_TITLEBAR; | 2425 features |= FEATURE_TITLEBAR; |
2441 | 2426 |
2442 if (is_type_tabbed()) | 2427 if (is_type_tabbed()) |
2443 features |= FEATURE_TABSTRIP; | 2428 features |= FEATURE_TABSTRIP; |
2444 | 2429 |
2445 if (is_type_tabbed()) | 2430 if (is_type_tabbed()) |
2446 features |= FEATURE_TOOLBAR; | 2431 features |= FEATURE_TOOLBAR; |
2447 | 2432 |
2448 if (SupportsLocationBar()) | 2433 if (SupportsLocationBar()) |
2449 features |= FEATURE_LOCATIONBAR; | 2434 features |= FEATURE_LOCATIONBAR; |
2450 | |
2451 if (ShouldUseWebAppFrame()) | |
2452 features |= FEATURE_WEBAPPFRAME; | |
2453 } | 2435 } |
2454 return !!(features & feature); | 2436 return !!(features & feature); |
2455 } | 2437 } |
2456 | 2438 |
2457 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 2439 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
2458 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is | 2440 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is |
2459 // fixed. | 2441 // fixed. |
2460 tracked_objects::ScopedTracker tracking_profile1( | 2442 tracked_objects::ScopedTracker tracking_profile1( |
2461 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2443 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
2462 "467185 Browser::UpdateBookmarkBarState1")); | 2444 "467185 Browser::UpdateBookmarkBarState1")); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 // new window later, thus we need to navigate the window now. | 2582 // new window later, thus we need to navigate the window now. |
2601 if (contents) { | 2583 if (contents) { |
2602 contents->web_contents()->GetController().LoadURL( | 2584 contents->web_contents()->GetController().LoadURL( |
2603 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2585 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2604 std::string()); // No extra headers. | 2586 std::string()); // No extra headers. |
2605 } | 2587 } |
2606 } | 2588 } |
2607 | 2589 |
2608 return contents != NULL; | 2590 return contents != NULL; |
2609 } | 2591 } |
OLD | NEW |