#include "atom/browser/window_list.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/atom_version.h"
+#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#endif
// Read icon before window is created.
- std::string icon;
- if (options.Get(switches::kIcon, &icon) && !SetIcon(icon))
- LOG(ERROR) << "Failed to set icon to " << icon;
+ gfx::ImageSkia icon;
+ if (options.Get(switches::kIcon, &icon))
+ icon_.reset(new gfx::Image(icon));
// Read iframe security before any navigation.
options.Get(switches::kNodeIntegration, &node_integration_);
return host_view && host_view->HasFocus();
}
-bool NativeWindow::SetIcon(const std::string& str_path) {
- base::FilePath path = base::FilePath::FromUTF8Unsafe(str_path);
-
- // Read the file from disk.
- std::string file_contents;
- if (path.empty() || !base::ReadFileToString(path, &file_contents))
- return false;
-
- // Decode the bitmap using WebKit's image decoder.
- const unsigned char* data =
- reinterpret_cast<const unsigned char*>(file_contents.data());
- scoped_ptr<SkBitmap> decoded(new SkBitmap());
- gfx::PNGCodec::Decode(data, file_contents.length(), decoded.get());
- if (decoded->empty())
- return false; // Unable to decode.
-
- icon_ = gfx::Image::CreateFrom1xBitmap(*decoded.release());
- return true;
-}
-
base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
return GetWebContents()->GetRenderProcessHost()->GetHandle();
}
#include "atom/browser/native_window_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_observer.h"
-#include "ui/gfx/image/image.h"
#include "vendor/brightray/browser/default_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
}
namespace gfx {
+class Image;
class Point;
class Rect;
class Size;
virtual void BlurWebView();
virtual bool IsWebViewFocused();
- virtual bool SetIcon(const std::string& path);
-
// Returns the process handle of render process, useful for killing the
// render process manually
virtual base::ProcessHandle GetRenderProcessHandle();
bool has_frame_;
// Window icon.
- gfx::Image icon_;
+ scoped_ptr<gfx::Image> icon_;
private:
// Schedule a notification unresponsive event.
#include "ui/base/x/x11_util.h"
#include "ui/gfx/font_render_params_linux.h"
#include "ui/gfx/gtk_util.h"
+#include "ui/gfx/image.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_utils_gtk.h"
// Create the underlying gdk window.
gtk_widget_realize(GTK_WIDGET(window_));
- if (!icon_.IsEmpty())
- gtk_window_set_icon(window_, icon_.ToGdkPixbuf());
+ if (icon_)
+ gtk_window_set_icon(window_, icon_->ToGdkPixbuf());
ui::ActiveWindowWatcherX::AddObserver(this);
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "native_mate/dictionary.h"
+#include "ui/gfx/image.h"
#include "ui/gfx/path.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/widget/widget.h"
}
gfx::ImageSkia NativeWindowWin::GetWindowAppIcon() {
- if (icon_.IsEmpty())
- return gfx::ImageSkia();
+ if (icon_)
+ return *(icon_->ToImageSkia());
else
- return *icon_.ToImageSkia();
+ return gfx::ImageSkia();
}
gfx::ImageSkia NativeWindowWin::GetWindowIcon() {