OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" | 5 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/frame/bubble_window.h" | 7 #include "chrome/browser/chromeos/frame/bubble_window.h" |
8 #include "chrome/browser/chromeos/login/user_manager.h" | 8 #include "chrome/browser/chromeos/login/user_manager.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/browser/ui/views/html_dialog_view.h" | 12 #include "chrome/browser/ui/views/html_dialog_view.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Default width/height of the dialog. | 17 // Default width/height of the dialog. |
18 const int kDefaultWidth = 350; | 18 const int kDefaultWidth = 350; |
19 const int kDefaultHeight = 225; | 19 const int kDefaultHeight = 225; |
20 | 20 |
21 // Custom HtmlDialogView with disabled context menu. | |
22 class 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 | 21 } // namespace |
36 | 22 |
37 namespace chromeos { | 23 namespace chromeos { |
38 | 24 |
39 // static | 25 // static |
40 void ChooseMobileNetworkDialog::ShowDialog(gfx::NativeWindow owning_window) { | 26 void ChooseMobileNetworkDialog::ShowDialog(gfx::NativeWindow owning_window) { |
41 Profile* profile; | 27 Profile* profile; |
42 if (UserManager::Get()->user_is_logged_in()) { | 28 if (UserManager::Get()->user_is_logged_in()) { |
43 Browser* browser = BrowserList::GetLastActive(); | 29 Browser* browser = BrowserList::GetLastActive(); |
44 DCHECK(browser); | 30 DCHECK(browser); |
45 profile = browser->profile(); | 31 profile = browser->profile(); |
46 } else { | 32 } else { |
47 profile = ProfileManager::GetDefaultProfile(); | 33 profile = ProfileManager::GetDefaultProfile(); |
48 } | 34 } |
49 HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( | 35 HtmlDialogView* html_view = |
50 profile, new ChooseMobileNetworkDialog); | 36 new HtmlDialogView(profile, new ChooseMobileNetworkDialog); |
51 html_view->InitDialog(); | 37 html_view->InitDialog(); |
52 chromeos::BubbleWindow::Create(owning_window, | 38 chromeos::BubbleWindow::Create(owning_window, |
53 gfx::Rect(), | 39 gfx::Rect(), |
54 chromeos::BubbleWindow::STYLE_GENERIC, | 40 chromeos::BubbleWindow::STYLE_GENERIC, |
55 html_view); | 41 html_view); |
56 html_view->window()->Show(); | 42 html_view->window()->Show(); |
57 } | 43 } |
58 | 44 |
59 ChooseMobileNetworkDialog::ChooseMobileNetworkDialog() { | 45 ChooseMobileNetworkDialog::ChooseMobileNetworkDialog() { |
60 } | 46 } |
(...skipping 29 matching lines...) Expand all Loading... |
90 void ChooseMobileNetworkDialog::OnCloseContents(TabContents* source, | 76 void ChooseMobileNetworkDialog::OnCloseContents(TabContents* source, |
91 bool* out_close_dialog) { | 77 bool* out_close_dialog) { |
92 if (out_close_dialog) | 78 if (out_close_dialog) |
93 *out_close_dialog = true; | 79 *out_close_dialog = true; |
94 } | 80 } |
95 | 81 |
96 bool ChooseMobileNetworkDialog::ShouldShowDialogTitle() const { | 82 bool ChooseMobileNetworkDialog::ShouldShowDialogTitle() const { |
97 return false; | 83 return false; |
98 } | 84 } |
99 | 85 |
| 86 bool ChooseMobileNetworkDialog::HandleContextMenu( |
| 87 const ContextMenuParams& params) { |
| 88 // Disable context menu. |
| 89 return true; |
| 90 } |
| 91 |
100 } // namespace chromeos | 92 } // namespace chromeos |
OLD | NEW |