OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window.h" | 5 #include "extensions/browser/app_window/app_window.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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 web_contents()->GetController().GetLastCommittedEntry() : nullptr; | 554 web_contents()->GetController().GetLastCommittedEntry() : nullptr; |
555 if (!entry || entry->GetTitle().empty()) { | 555 if (!entry || entry->GetTitle().empty()) { |
556 title = base::UTF8ToUTF16(extension->name()); | 556 title = base::UTF8ToUTF16(extension->name()); |
557 } else { | 557 } else { |
558 title = web_contents()->GetTitle(); | 558 title = web_contents()->GetTitle(); |
559 } | 559 } |
560 base::RemoveChars(title, base::ASCIIToUTF16("\n"), &title); | 560 base::RemoveChars(title, base::ASCIIToUTF16("\n"), &title); |
561 return title; | 561 return title; |
562 } | 562 } |
563 | 563 |
| 564 bool AppWindow::HasCustomIcon() const { |
| 565 return window_icon_url_.is_valid() || app_icon_url_.is_valid(); |
| 566 } |
| 567 |
564 void AppWindow::SetAppIconUrl(const GURL& url) { | 568 void AppWindow::SetAppIconUrl(const GURL& url) { |
565 // Avoid using any previous icons that were being downloaded. | 569 // Avoid using any previous icons that were being downloaded. |
566 image_loader_ptr_factory_.InvalidateWeakPtrs(); | 570 image_loader_ptr_factory_.InvalidateWeakPtrs(); |
567 | 571 |
568 // Reset |app_icon_image_| to abort pending image load (if any). | 572 // Reset |app_icon_image_| to abort pending image load (if any). |
569 if (!show_in_shelf_) { | 573 if (!show_in_shelf_) { |
570 app_icon_image_.reset(); | 574 app_icon_image_.reset(); |
571 app_icon_url_ = url; | 575 app_icon_url_ = url; |
572 } else { | 576 } else { |
573 window_icon_url_ = url; | 577 window_icon_url_ = url; |
(...skipping 14 matching lines...) Expand all Loading... |
588 | 592 |
589 void AppWindow::UpdateDraggableRegions( | 593 void AppWindow::UpdateDraggableRegions( |
590 const std::vector<DraggableRegion>& regions) { | 594 const std::vector<DraggableRegion>& regions) { |
591 native_app_window_->UpdateDraggableRegions(regions); | 595 native_app_window_->UpdateDraggableRegions(regions); |
592 } | 596 } |
593 | 597 |
594 void AppWindow::UpdateAppIcon(const gfx::Image& image) { | 598 void AppWindow::UpdateAppIcon(const gfx::Image& image) { |
595 // Set the showInShelf=true window icon and add the app_icon_image_ | 599 // Set the showInShelf=true window icon and add the app_icon_image_ |
596 // as a badge. If the image is empty, set the default app icon placeholder | 600 // as a badge. If the image is empty, set the default app icon placeholder |
597 // as the base image. | 601 // as the base image. |
598 if (window_icon_url_.is_valid() && !app_icon_image_->image().IsEmpty()) { | 602 if (window_icon_url_.is_valid() && app_icon_image_ && |
| 603 !app_icon_image_->image().IsEmpty()) { |
599 gfx::Image base_image = | 604 gfx::Image base_image = |
600 !image.IsEmpty() | 605 !image.IsEmpty() |
601 ? image | 606 ? image |
602 : gfx::Image(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 607 : gfx::Image(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
603 IDR_APP_DEFAULT_ICON)); | 608 IDR_APP_DEFAULT_ICON)); |
604 // Scale the icon to EXTENSION_ICON_LARGE. | 609 // Scale the icon to EXTENSION_ICON_LARGE. |
605 const int large_icon_size = extension_misc::EXTENSION_ICON_LARGE; | 610 const int large_icon_size = extension_misc::EXTENSION_ICON_LARGE; |
606 if (base_image.Width() != large_icon_size || | 611 if (base_image.Width() != large_icon_size || |
607 base_image.Height() != large_icon_size) { | 612 base_image.Height() != large_icon_size) { |
608 gfx::ImageSkia resized_image = | 613 gfx::ImageSkia resized_image = |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 region.bounds.x(), | 1118 region.bounds.x(), |
1114 region.bounds.y(), | 1119 region.bounds.y(), |
1115 region.bounds.right(), | 1120 region.bounds.right(), |
1116 region.bounds.bottom(), | 1121 region.bounds.bottom(), |
1117 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1122 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1118 } | 1123 } |
1119 return sk_region; | 1124 return sk_region; |
1120 } | 1125 } |
1121 | 1126 |
1122 } // namespace extensions | 1127 } // namespace extensions |
OLD | NEW |