create iconmanager as singleton class and cleanup code (#1)
* create iconmanager as singleton class and cleanup code
This commit is contained in:
parent
1b3cd87fc9
commit
b25b141642
15 changed files with 275 additions and 216 deletions
55
chromium_src/chrome/browser/icon_loader_auralinux.cc
Normal file
55
chromium_src/chrome/browser/icon_loader_auralinux.cc
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Copyright 2013 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/icon_loader.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/nix/mime_util_xdg.h"
|
||||
#include "ui/views/linux_ui/linux_ui.h"
|
||||
|
||||
// static
|
||||
IconGroupID IconLoader::ReadGroupIDFromFilepath(
|
||||
const base::FilePath& filepath) {
|
||||
return base::nix::GetFileMimeType(filepath);
|
||||
}
|
||||
|
||||
// static
|
||||
bool IconLoader::IsIconMutableFromFilepath(const base::FilePath&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
content::BrowserThread::ID IconLoader::ReadIconThreadID() {
|
||||
// ReadIcon() calls into views::LinuxUI and GTK2 code, so it must be on the UI
|
||||
// thread.
|
||||
return content::BrowserThread::UI;
|
||||
}
|
||||
|
||||
void IconLoader::ReadIcon() {
|
||||
int size_pixels = 0;
|
||||
switch (icon_size_) {
|
||||
case IconLoader::SMALL:
|
||||
size_pixels = 16;
|
||||
break;
|
||||
case IconLoader::NORMAL:
|
||||
size_pixels = 32;
|
||||
break;
|
||||
case IconLoader::LARGE:
|
||||
size_pixels = 48;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
views::LinuxUI* ui = views::LinuxUI::instance();
|
||||
if (ui) {
|
||||
gfx::Image image = ui->GetIconForContentType(group_, size_pixels);
|
||||
if (!image.IsEmpty())
|
||||
image_.reset(new gfx::Image(image));
|
||||
}
|
||||
|
||||
target_task_runner_->PostTask(FROM_HERE,
|
||||
base::Bind(&IconLoader::NotifyDelegate, this));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue