Index: chrome/browser/media/window_icon_util_chromeos.cc |
diff --git a/chrome/browser/media/window_icon_util_chromeos.cc b/chrome/browser/media/window_icon_util_chromeos.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..734e356105d8e6d5f1e6d91b6aad0e9c74cc0d8c |
--- /dev/null |
+++ b/chrome/browser/media/window_icon_util_chromeos.cc |
@@ -0,0 +1,49 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/media/window_icon_util.h" |
+ |
+#include "chrome/browser/ui/views/frame/browser_view.h" |
+#include "content/public/browser/desktop_media_id.h" |
+#include "extensions/grit/extensions_browser_resources.h" |
+#include "grit/theme_resources.h" |
+#include "ui/aura/client/aura_constants.h" |
+#include "ui/aura/window.h" |
+#include "ui/base/resource/resource_bundle.h" |
+ |
+gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { |
+ DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW); |
sky
2016/08/25 15:44:51
DCHECK_EQ
qiangchen
2016/08/25 17:07:59
Done.
|
+ aura::Window* window = content::DesktopMediaID::GetAuraWindowById(id); |
+ if (!window) |
+ return gfx::ImageSkia(); |
+ |
+ const gfx::ImageSkia* icon_image_ptr = |
+ window->GetProperty(aura::client::kWindowIconKey); |
+ |
+ if (icon_image_ptr) |
+ return *icon_image_ptr; |
+ |
+ // The following code deals with the default icon case: |
+ // As aura framework uses empty icon to represent default icon, it relies on |
+ // the caller to handle the case. |
+ // Here we are going to display default app icon for app windows without an |
+ // icon, and display product logo for chrome browser windows. |
+ |
+ BrowserView* browser_view = |
+ BrowserView::GetBrowserViewForNativeWindow(window); |
+ Browser* browser = browser_view ? browser_view->browser() : nullptr; |
+ |
+ // Apps could be launched in a view other than BrowserView, so we count those |
+ // windows without Browser association as apps. |
+ // Technically dev tool is actually a special app, but we would like to |
+ // display product logo for it, because intuitively it is internal to browser. |
+ bool is_app = browser ? browser->is_app() && !browser->is_devtools() : true; |
+ int idr = is_app ? IDR_APP_DEFAULT_ICON : IDR_PRODUCT_LOGO_32; |
+ |
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
+ icon_image_ptr = rb.GetImageSkiaNamed(idr); |
sky
2016/08/25 15:44:51
GetImageSkiaNamed always returns non-null.
qiangchen
2016/08/25 17:07:59
Done.
|
+ if (icon_image_ptr) |
+ return *icon_image_ptr; |
+ return gfx::ImageSkia(); |
+} |