OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/enrollment_dialog_view.h" | 5 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
14 #include "chrome/browser/ui/browser_window.h" | |
14 #include "chrome/browser/ui/host_desktop.h" | 15 #include "chrome/browser/ui/host_desktop.h" |
16 #include "chrome/browser/ui/singleton_tabs.h" | |
15 #include "content/public/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
16 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
17 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
21 #include "ui/views/layout/grid_layout.h" | 23 #include "ui/views/layout/grid_layout.h" |
22 #include "ui/views/layout/layout_constants.h" | 24 #include "ui/views/layout/layout_constants.h" |
23 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
24 | 26 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 views::Widget* widget = dialog_view->GetWidget(); | 101 views::Widget* widget = dialog_view->GetWidget(); |
100 DCHECK(widget); | 102 DCHECK(widget); |
101 widget->Show(); | 103 widget->Show(); |
102 } | 104 } |
103 | 105 |
104 int EnrollmentDialogView::GetDialogButtons() const { | 106 int EnrollmentDialogView::GetDialogButtons() const { |
105 return ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK; | 107 return ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK; |
106 } | 108 } |
107 | 109 |
108 bool EnrollmentDialogView::Accept() { | 110 bool EnrollmentDialogView::Accept() { |
109 // TODO(beng): use Navigate(). | 111 Browser* browser = chrome::FindOrCreateTabbedBrowser( |
110 // Navigate to the target URI in a browser tab. | 112 profile_, |
111 Browser* browser = chrome::FindTabbedBrowser(profile_, false, | 113 chrome::HOST_DESKTOP_TYPE_ASH); |
112 chrome::HOST_DESKTOP_TYPE_ASH); | |
113 if (!browser) { | |
114 // Couldn't find a tabbed browser: create one. | |
sky
2013/01/30 22:46:27
This does not show the browser.
| |
115 browser = new Browser( | |
116 Browser::CreateParams(Browser::TYPE_TABBED, | |
117 profile_, | |
118 chrome::HOST_DESKTOP_TYPE_ASH)); | |
119 } | |
120 DCHECK(browser); | 114 DCHECK(browser); |
121 chrome::AddSelectedTabWithURL(browser, target_uri_, | 115 chrome::NavigateParams params( |
sky
2013/01/30 22:46:27
This does not show browser. So if you created a ne
| |
122 content::PAGE_TRANSITION_LINK); | 116 chrome::GetSingletonTabNavigateParams(browser, GURL(target_uri_))); |
117 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | |
118 chrome::ShowSingletonTabOverwritingNTP(browser, params); | |
119 browser->window()->Restore(); | |
123 return true; | 120 return true; |
124 } | 121 } |
125 | 122 |
126 string16 EnrollmentDialogView::GetDialogButtonLabel( | 123 string16 EnrollmentDialogView::GetDialogButtonLabel( |
127 ui::DialogButton button) const { | 124 ui::DialogButton button) const { |
128 if (button == ui::DIALOG_BUTTON_OK) | 125 if (button == ui::DIALOG_BUTTON_OK) |
129 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); | 126 return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_BUTTON); |
130 return views::DialogDelegateView::GetDialogButtonLabel(button); | 127 return views::DialogDelegateView::GetDialogButtonLabel(button); |
131 } | 128 } |
132 | 129 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 //////////////////////////////////////////////////////////////////////////////// | 243 //////////////////////////////////////////////////////////////////////////////// |
247 // Factory function. | 244 // Factory function. |
248 | 245 |
249 EnrollmentDelegate* CreateEnrollmentDelegate(gfx::NativeWindow owning_window, | 246 EnrollmentDelegate* CreateEnrollmentDelegate(gfx::NativeWindow owning_window, |
250 const std::string& network_name, | 247 const std::string& network_name, |
251 Profile* profile) { | 248 Profile* profile) { |
252 return new DialogEnrollmentDelegate(owning_window, network_name, profile); | 249 return new DialogEnrollmentDelegate(owning_window, network_name, profile); |
253 } | 250 } |
254 | 251 |
255 } // namespace chromeos | 252 } // namespace chromeos |
OLD | NEW |