This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task manager's apps and extensions should show the correct favicon
We need to get the correct favicon of the app or extension so that it's easier to identify in the table. Before and after screenshots are available on the BUG thread. BUG=525293 TEST=browser_tests --gtest_filter=ExtensionTagsTest.* Review URL: https://codereview.chromium.org/1302423005 Cr-Commit-Position: refs/heads/master@{#346155}
- Loading branch information
afakhry
authored and
Commit bot
committed
Aug 28, 2015
1 parent
8f7bea6
commit d91a619
Showing
7 changed files
with
180 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2015 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 "extensions/browser/test_image_loader.h" | ||
|
||
#include "base/bind.h" | ||
#include "extensions/browser/image_loader.h" | ||
#include "extensions/common/extension.h" | ||
|
||
namespace extensions { | ||
|
||
TestImageLoader::TestImageLoader() : waiting_(false), image_loaded_(false) {} | ||
|
||
TestImageLoader::~TestImageLoader() {} | ||
|
||
// static | ||
SkBitmap TestImageLoader::LoadAndGetExtensionBitmap( | ||
const Extension* extension, | ||
const std::string& image_path, | ||
int size) { | ||
TestImageLoader image_loader; | ||
return image_loader.LoadAndGetBitmap(extension, image_path, size); | ||
} | ||
|
||
void TestImageLoader::OnImageLoaded(const gfx::Image& image) { | ||
image_ = image; | ||
image_loaded_ = true; | ||
if (waiting_) | ||
loader_message_loop_quit_.Run(); | ||
} | ||
|
||
SkBitmap TestImageLoader::LoadAndGetBitmap(const Extension* extension, | ||
const std::string& path, | ||
int size) { | ||
image_loaded_ = false; | ||
|
||
ImageLoader image_loader; | ||
image_loader.LoadImageAsync( | ||
extension, extension->GetResource(path), gfx::Size(size, size), | ||
base::Bind(&TestImageLoader::OnImageLoaded, base::Unretained(this))); | ||
|
||
// If |image_| still hasn't been loaded (i.e. it is being loaded | ||
// asynchronously), wait for it. | ||
if (!image_loaded_) { | ||
waiting_ = true; | ||
base::RunLoop run_loop; | ||
loader_message_loop_quit_ = run_loop.QuitClosure(); | ||
run_loop.Run(); | ||
waiting_ = false; | ||
} | ||
|
||
DCHECK(image_loaded_); | ||
|
||
return image_.IsEmpty() ? SkBitmap() : *image_.ToSkBitmap(); | ||
} | ||
|
||
} // namespace extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2015 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. | ||
|
||
#ifndef EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ | ||
#define EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ | ||
|
||
#include "base/run_loop.h" | ||
#include "ui/gfx/image/image.h" | ||
|
||
namespace extensions { | ||
|
||
class Extension; | ||
|
||
// Helper class for synchronously loading an extension image resource. | ||
class TestImageLoader { | ||
public: | ||
TestImageLoader(); | ||
~TestImageLoader(); | ||
|
||
// Loads an image to be used in test from |extension|. | ||
// The image will be loaded from the relative path |image_path|. | ||
static SkBitmap LoadAndGetExtensionBitmap(const Extension* extension, | ||
const std::string& image_path, | ||
int size); | ||
|
||
private: | ||
void OnImageLoaded(const gfx::Image& image); | ||
|
||
SkBitmap LoadAndGetBitmap(const Extension* extension, | ||
const std::string& path, | ||
int size); | ||
|
||
gfx::Image image_; | ||
base::Closure loader_message_loop_quit_; | ||
bool waiting_; | ||
bool image_loaded_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(TestImageLoader); | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ |
Oops, something went wrong.