1// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/chromeos/choose_mobile_network_dialog.h" 6 7#include "chrome/browser/chromeos/frame/bubble_window.h" 8#include "chrome/browser/chromeos/login/user_manager.h" 9#include "chrome/browser/profiles/profile_manager.h" 10#include "chrome/browser/ui/browser.h" 11#include "chrome/browser/ui/browser_list.h" 12#include "chrome/browser/ui/views/html_dialog_view.h" 13#include "chrome/common/url_constants.h" 14 15namespace { 16 17// Default width/height of the dialog. 18const int kDefaultWidth = 350; 19const int kDefaultHeight = 225; 20 21// Custom HtmlDialogView with disabled context menu. 22class HtmlDialogWithoutContextMenuView : public HtmlDialogView { 23 public: 24 HtmlDialogWithoutContextMenuView(Profile* profile, 25 HtmlDialogUIDelegate* delegate) 26 : HtmlDialogView(profile, delegate) {} 27 28 // TabContentsDelegate implementation. 29 bool HandleContextMenu(const ContextMenuParams& params) { 30 // Disable context menu. 31 return true; 32 } 33}; 34 35} // namespace 36 37namespace chromeos { 38 39// static 40void ChooseMobileNetworkDialog::ShowDialog(gfx::NativeWindow owning_window) { 41 Profile* profile; 42 if (UserManager::Get()->user_is_logged_in()) { 43 Browser* browser = BrowserList::GetLastActive(); 44 DCHECK(browser); 45 profile = browser->profile(); 46 } else { 47 profile = ProfileManager::GetDefaultProfile(); 48 } 49 HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( 50 profile, new ChooseMobileNetworkDialog); 51 html_view->InitDialog(); 52 chromeos::BubbleWindow::Create(owning_window, 53 gfx::Rect(), 54 chromeos::BubbleWindow::STYLE_GENERIC, 55 html_view); 56 html_view->window()->Show(); 57} 58 59ChooseMobileNetworkDialog::ChooseMobileNetworkDialog() { 60} 61 62bool ChooseMobileNetworkDialog::IsDialogModal() const { 63 return true; 64} 65 66std::wstring ChooseMobileNetworkDialog::GetDialogTitle() const { 67 return std::wstring(); 68} 69 70GURL ChooseMobileNetworkDialog::GetDialogContentURL() const { 71 return GURL(chrome::kChromeUIChooseMobileNetworkURL); 72} 73 74void ChooseMobileNetworkDialog::GetWebUIMessageHandlers( 75 std::vector<WebUIMessageHandler*>* handlers) const { 76} 77 78void ChooseMobileNetworkDialog::GetDialogSize(gfx::Size* size) const { 79 size->SetSize(kDefaultWidth, kDefaultHeight); 80} 81 82std::string ChooseMobileNetworkDialog::GetDialogArgs() const { 83 return "[]"; 84} 85 86void ChooseMobileNetworkDialog::OnDialogClosed(const std::string& json_retval) { 87 delete this; 88} 89 90void ChooseMobileNetworkDialog::OnCloseContents(TabContents* source, 91 bool* out_close_dialog) { 92 if (out_close_dialog) 93 *out_close_dialog = true; 94} 95 96bool ChooseMobileNetworkDialog::ShouldShowDialogTitle() const { 97 return false; 98} 99 100} // namespace chromeos 101