Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/chromeos/sim_dialog_delegate.cc

Issue 7124001: [cleanup] Use Delegate method to control context menu and eliminate HtmlDialogWithoutContextMenuView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/sim_dialog_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sim_dialog_delegate.h" 5 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "chrome/browser/chromeos/frame/bubble_window.h" 8 #include "chrome/browser/chromeos/frame/bubble_window.h"
9 #include "chrome/browser/chromeos/login/user_manager.h" 9 #include "chrome/browser/chromeos/login/user_manager.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 18 matching lines...) Expand all
29 // set-lock-on - enable RequirePin restriction. 29 // set-lock-on - enable RequirePin restriction.
30 // set-lock-off - disable RequirePin restriction. 30 // set-lock-off - disable RequirePin restriction.
31 // In general SIM unlock case sim-unlock URL is loaded w/o parameters. 31 // In general SIM unlock case sim-unlock URL is loaded w/o parameters.
32 const char kSimDialogSpecialModeURL[] = "chrome://sim-unlock/?mode=%s"; 32 const char kSimDialogSpecialModeURL[] = "chrome://sim-unlock/?mode=%s";
33 33
34 // Dialog mode constants. 34 // Dialog mode constants.
35 const char kSimDialogChangePinMode[] = "change-pin"; 35 const char kSimDialogChangePinMode[] = "change-pin";
36 const char kSimDialogSetLockOnMode[] = "set-lock-on"; 36 const char kSimDialogSetLockOnMode[] = "set-lock-on";
37 const char kSimDialogSetLockOffMode[] = "set-lock-off"; 37 const char kSimDialogSetLockOffMode[] = "set-lock-off";
38 38
39 // Custom HtmlDialogView with disabled context menu.
40 class HtmlDialogWithoutContextMenuView : public HtmlDialogView {
41 public:
42 HtmlDialogWithoutContextMenuView(Profile* profile,
43 HtmlDialogUIDelegate* delegate)
44 : HtmlDialogView(profile, delegate) {}
45
46 // TabContentsDelegate implementation.
47 bool HandleContextMenu(const ContextMenuParams& params) {
48 // Disable context menu.
49 return true;
50 }
51 };
52
53 } // namespace 39 } // namespace
54 40
55 namespace chromeos { 41 namespace chromeos {
56 42
57 // static 43 // static
58 void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, 44 void SimDialogDelegate::ShowDialog(gfx::NativeWindow owning_window,
59 SimDialogMode mode) { 45 SimDialogMode mode) {
60 Profile* profile; 46 Profile* profile;
61 if (UserManager::Get()->user_is_logged_in()) { 47 if (UserManager::Get()->user_is_logged_in()) {
62 Browser* browser = BrowserList::GetLastActive(); 48 Browser* browser = BrowserList::GetLastActive();
63 DCHECK(browser); 49 DCHECK(browser);
64 profile = browser->profile(); 50 profile = browser->profile();
65 } else { 51 } else {
66 profile = ProfileManager::GetDefaultProfile(); 52 profile = ProfileManager::GetDefaultProfile();
67 } 53 }
68 HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( 54 HtmlDialogView* html_view =
69 profile, new SimDialogDelegate(mode)); 55 new HtmlDialogView(profile, new SimDialogDelegate(mode));
70 html_view->InitDialog(); 56 html_view->InitDialog();
71 chromeos::BubbleWindow::Create(owning_window, 57 chromeos::BubbleWindow::Create(owning_window,
72 gfx::Rect(), 58 gfx::Rect(),
73 chromeos::BubbleWindow::STYLE_GENERIC, 59 chromeos::BubbleWindow::STYLE_GENERIC,
74 html_view); 60 html_view);
75 html_view->window()->Show(); 61 html_view->window()->Show();
76 } 62 }
77 63
78 SimDialogDelegate::SimDialogDelegate(SimDialogMode dialog_mode) 64 SimDialogDelegate::SimDialogDelegate(SimDialogMode dialog_mode)
79 : dialog_mode_(dialog_mode) { 65 : dialog_mode_(dialog_mode) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void SimDialogDelegate::OnCloseContents(TabContents* source, 115 void SimDialogDelegate::OnCloseContents(TabContents* source,
130 bool* out_close_dialog) { 116 bool* out_close_dialog) {
131 if (out_close_dialog) 117 if (out_close_dialog)
132 *out_close_dialog = true; 118 *out_close_dialog = true;
133 } 119 }
134 120
135 bool SimDialogDelegate::ShouldShowDialogTitle() const { 121 bool SimDialogDelegate::ShouldShowDialogTitle() const {
136 return false; 122 return false;
137 } 123 }
138 124
125 bool SimDialogDelegate::HandleContextMenu(const ContextMenuParams& params) {
126 // Disable context menu.
127 return true;
128 }
129
139 } // namespace chromeos 130 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/sim_dialog_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698