Commit 722b2c30 authored by oshima@google.com's avatar oshima@google.com

Use Delegate method to control context menu and eliminate HtmlDialogWithoutContextMenuView

BUG=none
TEST=none. no functional change. all test should still pass.

Review URL: http://codereview.chromium.org/7124001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88347 0039d316-1c4b-4281-b951-d872f2087c98
parent 694a1c74
...@@ -18,20 +18,6 @@ namespace { ...@@ -18,20 +18,6 @@ namespace {
const int kDefaultWidth = 350; const int kDefaultWidth = 350;
const int kDefaultHeight = 225; const int kDefaultHeight = 225;
// Custom HtmlDialogView with disabled context menu.
class HtmlDialogWithoutContextMenuView : public HtmlDialogView {
public:
HtmlDialogWithoutContextMenuView(Profile* profile,
HtmlDialogUIDelegate* delegate)
: HtmlDialogView(profile, delegate) {}
// TabContentsDelegate implementation.
bool HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
};
} // namespace } // namespace
namespace chromeos { namespace chromeos {
...@@ -46,8 +32,8 @@ void ChooseMobileNetworkDialog::ShowDialog(gfx::NativeWindow owning_window) { ...@@ -46,8 +32,8 @@ void ChooseMobileNetworkDialog::ShowDialog(gfx::NativeWindow owning_window) {
} else { } else {
profile = ProfileManager::GetDefaultProfile(); profile = ProfileManager::GetDefaultProfile();
} }
HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( HtmlDialogView* html_view =
profile, new ChooseMobileNetworkDialog); new HtmlDialogView(profile, new ChooseMobileNetworkDialog);
html_view->InitDialog(); html_view->InitDialog();
chromeos::BubbleWindow::Create(owning_window, chromeos::BubbleWindow::Create(owning_window,
gfx::Rect(), gfx::Rect(),
...@@ -97,4 +83,10 @@ bool ChooseMobileNetworkDialog::ShouldShowDialogTitle() const { ...@@ -97,4 +83,10 @@ bool ChooseMobileNetworkDialog::ShouldShowDialogTitle() const {
return false; return false;
} }
bool ChooseMobileNetworkDialog::HandleContextMenu(
const ContextMenuParams& params) {
// Disable context menu.
return true;
}
} // namespace chromeos } // namespace chromeos
...@@ -20,16 +20,18 @@ class ChooseMobileNetworkDialog : private HtmlDialogUIDelegate { ...@@ -20,16 +20,18 @@ class ChooseMobileNetworkDialog : private HtmlDialogUIDelegate {
ChooseMobileNetworkDialog(); ChooseMobileNetworkDialog();
// Overridden from HtmlDialogUI::Delegate: // Overridden from HtmlDialogUI::Delegate:
virtual bool IsDialogModal() const; virtual bool IsDialogModal() const OVERRIDE;
virtual std::wstring GetDialogTitle() const; virtual std::wstring GetDialogTitle() const OVERRIDE;
virtual GURL GetDialogContentURL() const; virtual GURL GetDialogContentURL() const OVERRIDE;
virtual void GetWebUIMessageHandlers( virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const; std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
virtual void GetDialogSize(gfx::Size* size) const; virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
virtual std::string GetDialogArgs() const; virtual std::string GetDialogArgs() const OVERRIDE;
virtual void OnDialogClosed(const std::string& json_retval); virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual void OnCloseContents(
virtual bool ShouldShowDialogTitle() const; TabContents* source, bool* out_close_dialog) OVERRIDE;
virtual bool ShouldShowDialogTitle() const OVERRIDE;
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(ChooseMobileNetworkDialog); DISALLOW_COPY_AND_ASSIGN(ChooseMobileNetworkDialog);
}; };
......
...@@ -22,21 +22,6 @@ namespace { ...@@ -22,21 +22,6 @@ namespace {
const double kDefaultWidthRatio = 0.6; const double kDefaultWidthRatio = 0.6;
const double kDefaultHeightRatio = 0.6; const double kDefaultHeightRatio = 0.6;
// Custom HtmlDialogView with disabled context menu.
class HtmlDialogWithoutContextMenuView : public HtmlDialogView {
public:
HtmlDialogWithoutContextMenuView(Profile* profile,
HtmlDialogUIDelegate* delegate)
: HtmlDialogView(profile, delegate) {}
virtual ~HtmlDialogWithoutContextMenuView() {}
// TabContentsDelegate implementation.
bool HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
};
} // namespace } // namespace
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -64,9 +49,8 @@ LoginHtmlDialog::~LoginHtmlDialog() { ...@@ -64,9 +49,8 @@ LoginHtmlDialog::~LoginHtmlDialog() {
} }
void LoginHtmlDialog::Show() { void LoginHtmlDialog::Show() {
HtmlDialogWithoutContextMenuView* html_view = HtmlDialogView* html_view =
new HtmlDialogWithoutContextMenuView(ProfileManager::GetDefaultProfile(), new HtmlDialogView(ProfileManager::GetDefaultProfile(), this);
this);
if (style_ & STYLE_BUBBLE) { if (style_ & STYLE_BUBBLE) {
views::Window* bubble_window = BubbleWindow::Create( views::Window* bubble_window = BubbleWindow::Create(
parent_window_, gfx::Rect(), parent_window_, gfx::Rect(),
...@@ -139,6 +123,11 @@ bool LoginHtmlDialog::ShouldShowDialogTitle() const { ...@@ -139,6 +123,11 @@ bool LoginHtmlDialog::ShouldShowDialogTitle() const {
return true; return true;
} }
bool LoginHtmlDialog::HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
void LoginHtmlDialog::Observe(NotificationType type, void LoginHtmlDialog::Observe(NotificationType type,
const NotificationSource& source, const NotificationSource& source,
const NotificationDetails& details) { const NotificationDetails& details) {
......
...@@ -55,16 +55,18 @@ class LoginHtmlDialog : public HtmlDialogUIDelegate, ...@@ -55,16 +55,18 @@ class LoginHtmlDialog : public HtmlDialogUIDelegate,
protected: protected:
// HtmlDialogUIDelegate implementation. // HtmlDialogUIDelegate implementation.
virtual bool IsDialogModal() const; virtual bool IsDialogModal() const OVERRIDE;
virtual std::wstring GetDialogTitle() const; virtual std::wstring GetDialogTitle() const OVERRIDE;
virtual GURL GetDialogContentURL() const; virtual GURL GetDialogContentURL() const OVERRIDE;
virtual void GetWebUIMessageHandlers( virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const; std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
virtual void GetDialogSize(gfx::Size* size) const; virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
virtual std::string GetDialogArgs() const; virtual std::string GetDialogArgs() const OVERRIDE;
virtual void OnDialogClosed(const std::string& json_retval); virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual void OnCloseContents(
virtual bool ShouldShowDialogTitle() const; TabContents* source, bool* out_close_dialog) OVERRIDE;
virtual bool ShouldShowDialogTitle() const OVERRIDE;
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
// NotificationObserver implementation. // NotificationObserver implementation.
virtual void Observe(NotificationType type, virtual void Observe(NotificationType type,
......
...@@ -36,27 +36,13 @@ const char kSimDialogChangePinMode[] = "change-pin"; ...@@ -36,27 +36,13 @@ const char kSimDialogChangePinMode[] = "change-pin";
const char kSimDialogSetLockOnMode[] = "set-lock-on"; const char kSimDialogSetLockOnMode[] = "set-lock-on";
const char kSimDialogSetLockOffMode[] = "set-lock-off"; const char kSimDialogSetLockOffMode[] = "set-lock-off";
// Custom HtmlDialogView with disabled context menu.
class HtmlDialogWithoutContextMenuView : public HtmlDialogView {
public:
HtmlDialogWithoutContextMenuView(Profile* profile,
HtmlDialogUIDelegate* delegate)
: HtmlDialogView(profile, delegate) {}
// TabContentsDelegate implementation.
bool HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
};
} // namespace } // namespace
namespace chromeos { namespace chromeos {
// static // static
void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window,
SimDialogMode mode) { SimDialogMode mode) {
Profile* profile; Profile* profile;
if (UserManager::Get()->user_is_logged_in()) { if (UserManager::Get()->user_is_logged_in()) {
Browser* browser = BrowserList::GetLastActive(); Browser* browser = BrowserList::GetLastActive();
...@@ -65,8 +51,8 @@ void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, ...@@ -65,8 +51,8 @@ void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window,
} else { } else {
profile = ProfileManager::GetDefaultProfile(); profile = ProfileManager::GetDefaultProfile();
} }
HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( HtmlDialogView* html_view =
profile, new SimDialogDelegate(mode)); new HtmlDialogView(profile, new SimDialogDelegate(mode));
html_view->InitDialog(); html_view->InitDialog();
chromeos::BubbleWindow::Create(owning_window, chromeos::BubbleWindow::Create(owning_window,
gfx::Rect(), gfx::Rect(),
...@@ -136,4 +122,9 @@ bool SimDialogDelegate::ShouldShowDialogTitle() const { ...@@ -136,4 +122,9 @@ bool SimDialogDelegate::ShouldShowDialogTitle() const {
return false; return false;
} }
bool SimDialogDelegate::HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
} // namespace chromeos } // namespace chromeos
...@@ -30,16 +30,18 @@ class SimDialogDelegate : public HtmlDialogUIDelegate { ...@@ -30,16 +30,18 @@ class SimDialogDelegate : public HtmlDialogUIDelegate {
virtual ~SimDialogDelegate(); virtual ~SimDialogDelegate();
// Overridden from HtmlDialogUI::Delegate: // Overridden from HtmlDialogUI::Delegate:
virtual bool IsDialogModal() const; virtual bool IsDialogModal() const OVERRIDE;
virtual std::wstring GetDialogTitle() const; virtual std::wstring GetDialogTitle() const OVERRIDE;
virtual GURL GetDialogContentURL() const; virtual GURL GetDialogContentURL() const OVERRIDE;
virtual void GetWebUIMessageHandlers( virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const; std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
virtual void GetDialogSize(gfx::Size* size) const; virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
virtual std::string GetDialogArgs() const; virtual std::string GetDialogArgs() const OVERRIDE;
virtual void OnDialogClosed(const std::string& json_retval); virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual void OnCloseContents(
virtual bool ShouldShowDialogTitle() const; TabContents* source, bool* out_close_dialog) OVERRIDE;
virtual bool ShouldShowDialogTitle() const OVERRIDE;
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
SimDialogMode dialog_mode_; SimDialogMode dialog_mode_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment