Index: chrome/browser/chromeos/sim_unlock_dialog_delegate.cc |
diff --git a/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc b/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eae831633ebc4f5eefaa324a554e0f01fbd20b70 |
--- /dev/null |
+++ b/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc |
@@ -0,0 +1,94 @@ |
+// Copyright (c) 2011 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/chromeos/sim_unlock_dialog_delegate.h" |
+ |
+#include "chrome/browser/browser_list.h" |
+#include "chrome/browser/chromeos/frame/bubble_window.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/views/html_dialog_view.h" |
+#include "chrome/common/url_constants.h" |
+ |
+namespace { |
+// Default width/height of the dialog. |
whywhat
2011/03/30 19:12:15
Empty line before?
Nikita (slow)
2011/03/31 08:44:17
Done.
|
+const int kDefaultWidth = 350; |
+const int kDefaultHeight = 225; |
+ |
+// Custom HtmlDialogView with disabled context menu. |
+class HtmlDialogWithoutContextMenuView : public HtmlDialogView { |
+ public: |
+ HtmlDialogWithoutContextMenuView(Profile* profile, |
+ HtmlDialogUIDelegate* delegate) |
+ : HtmlDialogView(profile, delegate) {} |
+ virtual ~HtmlDialogWithoutContextMenuView() {} |
whywhat
2011/03/30 19:12:15
I think you can live with auto generated one.
Nikita (slow)
2011/03/31 08:44:17
Done.
|
+ |
+ // TabContentsDelegate implementation. |
+ bool HandleContextMenu(const ContextMenuParams& params) { |
+ // Disable context menu. |
+ return true; |
+ } |
+}; |
+ |
+} // namespace |
+ |
+namespace chromeos { |
+ |
+// static |
+void SimUnlockDialogDelegate::ShowDialog(gfx::NativeWindow owning_window) { |
+ Browser* browser = BrowserList::GetLastActive(); |
+ HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( |
+ browser->profile(), new SimUnlockDialogDelegate()); |
+ html_view->InitDialog(); |
+ chromeos::BubbleWindow::Create(owning_window, |
+ gfx::Rect(), |
+ chromeos::BubbleWindow::STYLE_GENERIC, |
+ html_view); |
+ html_view->window()->Show(); |
+} |
+ |
+SimUnlockDialogDelegate::SimUnlockDialogDelegate() {} |
+ |
+SimUnlockDialogDelegate::~SimUnlockDialogDelegate() {} |
+ |
+bool SimUnlockDialogDelegate::IsDialogModal() const { |
+ return true; |
+} |
+ |
+std::wstring SimUnlockDialogDelegate::GetDialogTitle() const { |
+ return std::wstring(); |
+} |
+ |
+GURL SimUnlockDialogDelegate::GetDialogContentURL() const { |
+ std::string url_string(chrome::kChromeUISimUnlockURL); |
+ return GURL(url_string); |
+} |
+ |
+void SimUnlockDialogDelegate::GetWebUIMessageHandlers( |
+ std::vector<WebUIMessageHandler*>* handlers) const {} |
whywhat
2011/03/30 19:12:15
Could you move the closing bracket to the next lin
Nikita (slow)
2011/03/30 19:47:55
That would mean that we're inlining virtual functi
whywhat
2011/03/30 20:05:29
Well, I think it's better to leave it in .cc file
Nikita (slow)
2011/03/31 08:44:17
Done.
Nikita (slow)
2011/03/31 08:44:17
Done.
|
+ |
+void SimUnlockDialogDelegate::GetDialogSize(gfx::Size* size) const { |
+ // TODO(nkostylev): Set custom size based on locale settings. |
+ size->SetSize(kDefaultWidth, kDefaultHeight); |
+} |
+ |
+std::string SimUnlockDialogDelegate::GetDialogArgs() const { |
+ return "[]"; |
+} |
+ |
+void SimUnlockDialogDelegate::OnDialogClosed(const std::string& json_retval) { |
+ delete this; |
whywhat
2011/03/30 19:12:15
Is this really needed?
Nikita (slow)
2011/03/30 19:47:55
Yes, delegate is created in static method and not
|
+ return; |
whywhat
2011/03/30 20:05:29
You don't need return here.
Nikita (slow)
2011/03/31 08:44:17
Done.
|
+} |
+ |
+void SimUnlockDialogDelegate::OnCloseContents(TabContents* source, |
+ bool* out_close_dialog) { |
+ if (out_close_dialog) |
+ *out_close_dialog = true; |
+} |
+ |
+bool SimUnlockDialogDelegate::ShouldShowDialogTitle() const { |
+ return false; |
+} |
+ |
+} // namespace chromeos |