OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 NavigationEntry* entry = controller_.GetTransientEntry(); | 528 NavigationEntry* entry = controller_.GetTransientEntry(); |
529 if (entry) | 529 if (entry) |
530 return entry->favicon().bitmap(); | 530 return entry->favicon().bitmap(); |
531 | 531 |
532 entry = controller_.GetLastCommittedEntry(); | 532 entry = controller_.GetLastCommittedEntry(); |
533 if (entry) | 533 if (entry) |
534 return entry->favicon().bitmap(); | 534 return entry->favicon().bitmap(); |
535 return SkBitmap(); | 535 return SkBitmap(); |
536 } | 536 } |
537 | 537 |
| 538 bool TabContents::FavIconIsValid() const { |
| 539 NavigationEntry* entry = controller_.GetTransientEntry(); |
| 540 if (entry) |
| 541 return entry->favicon().is_valid(); |
| 542 |
| 543 entry = controller_.GetLastCommittedEntry(); |
| 544 if (entry) |
| 545 return entry->favicon().is_valid(); |
| 546 |
| 547 return false; |
| 548 } |
| 549 |
538 bool TabContents::ShouldDisplayFavIcon() { | 550 bool TabContents::ShouldDisplayFavIcon() { |
539 // Always display a throbber during pending loads. | 551 // Always display a throbber during pending loads. |
540 if (controller_.GetLastCommittedEntry() && controller_.pending_entry()) | 552 if (controller_.GetLastCommittedEntry() && controller_.pending_entry()) |
541 return true; | 553 return true; |
542 | 554 |
543 DOMUI* dom_ui = GetDOMUIForCurrentState(); | 555 DOMUI* dom_ui = GetDOMUIForCurrentState(); |
544 if (dom_ui) | 556 if (dom_ui) |
545 return !dom_ui->hide_favicon(); | 557 return !dom_ui->hide_favicon(); |
546 return true; | 558 return true; |
547 } | 559 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 tc->controller().CopyStateFrom(controller_); | 772 tc->controller().CopyStateFrom(controller_); |
761 return tc; | 773 return tc; |
762 } | 774 } |
763 | 775 |
764 void TabContents::CreateShortcut() { | 776 void TabContents::CreateShortcut() { |
765 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 777 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
766 if (!entry) | 778 if (!entry) |
767 return; | 779 return; |
768 | 780 |
769 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) | 781 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
| 782 SkBitmap bitmap; |
| 783 if (FavIconIsValid()) |
| 784 bitmap = GetFavIcon(); |
770 CreateApplicationShortcutsDialogGtk::Show(view()->GetTopLevelNativeWindow(), | 785 CreateApplicationShortcutsDialogGtk::Show(view()->GetTopLevelNativeWindow(), |
771 GetURL(), GetTitle()); | 786 GetURL(), GetTitle(), bitmap); |
772 #else | 787 #else |
773 // We only allow one pending install request. By resetting the page id we | 788 // We only allow one pending install request. By resetting the page id we |
774 // effectively cancel the pending install request. | 789 // effectively cancel the pending install request. |
775 pending_install_.page_id = entry->page_id(); | 790 pending_install_.page_id = entry->page_id(); |
776 pending_install_.icon = GetFavIcon(); | 791 pending_install_.icon = GetFavIcon(); |
777 pending_install_.title = UTF16ToWideHack(GetTitle()); | 792 pending_install_.title = UTF16ToWideHack(GetTitle()); |
778 pending_install_.url = GetURL(); | 793 pending_install_.url = GetURL(); |
779 if (pending_install_.callback_functor) { | 794 if (pending_install_.callback_functor) { |
780 pending_install_.callback_functor->Cancel(); | 795 pending_install_.callback_functor->Cancel(); |
781 pending_install_.callback_functor = NULL; | 796 pending_install_.callback_functor = NULL; |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 | 2575 |
2561 default: | 2576 default: |
2562 NOTREACHED(); | 2577 NOTREACHED(); |
2563 } | 2578 } |
2564 } | 2579 } |
2565 | 2580 |
2566 void TabContents::set_encoding(const std::string& encoding) { | 2581 void TabContents::set_encoding(const std::string& encoding) { |
2567 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2582 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
2568 } | 2583 } |
2569 | 2584 |
OLD | NEW |