Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/media/window_icon_util_chromeos.cc

Issue 2270543003: Display Window Icon In Picker UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: App vs Browser Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media/window_icon_util.h"
6
7 #include "chrome/browser/ui/views/frame/browser_view.h"
8 #include "content/public/browser/desktop_media_id.h"
9 #include "extensions/grit/extensions_browser_resources.h"
10 #include "grit/theme_resources.h"
11 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/window.h"
13 #include "ui/base/resource/resource_bundle.h"
14
15 gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
16 DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW);
sky 2016/08/25 15:44:51 DCHECK_EQ
qiangchen 2016/08/25 17:07:59 Done.
17 aura::Window* window = content::DesktopMediaID::GetAuraWindowById(id);
18 if (!window)
19 return gfx::ImageSkia();
20
21 const gfx::ImageSkia* icon_image_ptr =
22 window->GetProperty(aura::client::kWindowIconKey);
23
24 if (icon_image_ptr)
25 return *icon_image_ptr;
26
27 // The following code deals with the default icon case:
28 // As aura framework uses empty icon to represent default icon, it relies on
29 // the caller to handle the case.
30 // Here we are going to display default app icon for app windows without an
31 // icon, and display product logo for chrome browser windows.
32
33 BrowserView* browser_view =
34 BrowserView::GetBrowserViewForNativeWindow(window);
35 Browser* browser = browser_view ? browser_view->browser() : nullptr;
36
37 // Apps could be launched in a view other than BrowserView, so we count those
38 // windows without Browser association as apps.
39 // Technically dev tool is actually a special app, but we would like to
40 // display product logo for it, because intuitively it is internal to browser.
41 bool is_app = browser ? browser->is_app() && !browser->is_devtools() : true;
42 int idr = is_app ? IDR_APP_DEFAULT_ICON : IDR_PRODUCT_LOGO_32;
43
44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
45 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.
46 if (icon_image_ptr)
47 return *icon_image_ptr;
48 return gfx::ImageSkia();
49 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/window_icon_util_x11.cc » ('j') | chrome/browser/media/window_icon_util_x11.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698