Add a method in InspectableWebContentDelegate to set icon for devtools window.

This commit is contained in:
Cheng Zhao 2014-09-09 15:28:48 +08:00
parent c67ba6de6a
commit a6627a7286
6 changed files with 28 additions and 0 deletions

View file

@ -52,6 +52,7 @@
'browser/download_manager_delegate.h',
'browser/inspectable_web_contents.cc',
'browser/inspectable_web_contents.h',
'browser/inspectable_web_contents_delegate.cc',
'browser/inspectable_web_contents_delegate.h',
'browser/inspectable_web_contents_impl.cc',
'browser/inspectable_web_contents_impl.h',

View file

@ -29,6 +29,7 @@ class InspectableWebContents {
// The delegate manages its own life.
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0;
virtual InspectableWebContentsDelegate* GetDelegate() const = 0;
};
} // namespace brightray

View file

@ -0,0 +1,9 @@
#include "browser/inspectable_web_contents_delegate.h"
namespace brightray {
gfx::ImageSkia InspectableWebContentsDelegate::GetDevToolsWindowIcon() {
return gfx::ImageSkia();
}
} // namespace brightray

View file

@ -3,12 +3,17 @@
#include <string>
#include "ui/gfx/image/image_skia.h"
namespace brightray {
class InspectableWebContentsDelegate {
public:
virtual ~InspectableWebContentsDelegate() {}
// Returns the icon of devtools window.
virtual gfx::ImageSkia GetDevToolsWindowIcon();
// Requested by WebContents of devtools.
virtual void DevToolsSaveToFile(
const std::string& url, const std::string& content, bool save_as) {}

View file

@ -54,6 +54,9 @@ class InspectableWebContentsImpl :
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) {
delegate_ = delegate;
}
virtual InspectableWebContentsDelegate* GetDelegate() const {
return delegate_;
}
content::WebContents* devtools_web_contents() {
return devtools_web_contents_.get();

View file

@ -1,5 +1,6 @@
#include "browser/views/inspectable_web_contents_view_views.h"
#include "browser/inspectable_web_contents_delegate.h"
#include "browser/inspectable_web_contents_impl.h"
#include "base/strings/utf_string_conversions.h"
@ -25,6 +26,10 @@ class DevToolsWindowDelegate : public views::ClientView,
title_(base::ASCIIToUTF16("Developer Tools")) {
// A WidgetDelegate should be deleted on DeleteDelegate.
set_owned_by_client();
InspectableWebContentsDelegate* delegate = shell->inspectable_web_contents()->GetDelegate();
if (delegate)
icon_ = delegate->GetDevToolsWindowIcon();
}
virtual ~DevToolsWindowDelegate() {}
@ -34,6 +39,8 @@ class DevToolsWindowDelegate : public views::ClientView,
virtual bool CanResize() const OVERRIDE { return true; }
virtual bool CanMaximize() const OVERRIDE { return false; }
virtual base::string16 GetWindowTitle() const OVERRIDE { return title_; }
virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE { return GetWindowIcon(); }
virtual gfx::ImageSkia GetWindowIcon() OVERRIDE { return icon_; }
virtual views::Widget* GetWidget() OVERRIDE { return widget_; }
virtual const views::Widget* GetWidget() const OVERRIDE { return widget_; }
virtual views::View* GetContentsView() OVERRIDE { return view_; }
@ -50,6 +57,7 @@ class DevToolsWindowDelegate : public views::ClientView,
views::View* view_;
views::Widget* widget_;
base::string16 title_;
gfx::ImageSkia icon_;
DISALLOW_COPY_AND_ASSIGN(DevToolsWindowDelegate);
};
@ -144,6 +152,7 @@ void InspectableWebContentsViewViews::SetIsDocked(bool docked) {
params.remove_standard_frame = true;
#endif
devtools_window_->Init(params);
devtools_window_->UpdateWindowIcon();
}
ShowDevTools();