| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/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.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 13 #include "chromeos/network/network_event_log.h" |
| 13 #include "content/public/common/page_transition_types.h" | 14 #include "content/public/common/page_transition_types.h" |
| 14 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
| 20 #include "ui/views/layout/layout_constants.h" | 21 #include "ui/views/layout/layout_constants.h" |
| 21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/window/dialog_delegate.h" | 23 #include "ui/views/window/dialog_delegate.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 186 |
| 186 class DialogEnrollmentDelegate : public EnrollmentDelegate { | 187 class DialogEnrollmentDelegate : public EnrollmentDelegate { |
| 187 public: | 188 public: |
| 188 // |owning_window| is the window that will own the dialog. | 189 // |owning_window| is the window that will own the dialog. |
| 189 explicit DialogEnrollmentDelegate(gfx::NativeWindow owning_window, | 190 explicit DialogEnrollmentDelegate(gfx::NativeWindow owning_window, |
| 190 const std::string& network_name, | 191 const std::string& network_name, |
| 191 Profile* profile); | 192 Profile* profile); |
| 192 virtual ~DialogEnrollmentDelegate(); | 193 virtual ~DialogEnrollmentDelegate(); |
| 193 | 194 |
| 194 // EnrollmentDelegate overrides | 195 // EnrollmentDelegate overrides |
| 195 virtual void Enroll(const std::vector<std::string>& uri_list, | 196 virtual bool Enroll(const std::vector<std::string>& uri_list, |
| 196 const base::Closure& connect) OVERRIDE; | 197 const base::Closure& connect) OVERRIDE; |
| 197 | 198 |
| 198 private: | 199 private: |
| 199 gfx::NativeWindow owning_window_; | 200 gfx::NativeWindow owning_window_; |
| 200 std::string network_name_; | 201 std::string network_name_; |
| 201 Profile* profile_; | 202 Profile* profile_; |
| 202 | 203 |
| 203 DISALLOW_COPY_AND_ASSIGN(DialogEnrollmentDelegate); | 204 DISALLOW_COPY_AND_ASSIGN(DialogEnrollmentDelegate); |
| 204 }; | 205 }; |
| 205 | 206 |
| 206 DialogEnrollmentDelegate::DialogEnrollmentDelegate( | 207 DialogEnrollmentDelegate::DialogEnrollmentDelegate( |
| 207 gfx::NativeWindow owning_window, | 208 gfx::NativeWindow owning_window, |
| 208 const std::string& network_name, | 209 const std::string& network_name, |
| 209 Profile* profile) : owning_window_(owning_window), | 210 Profile* profile) : owning_window_(owning_window), |
| 210 network_name_(network_name), | 211 network_name_(network_name), |
| 211 profile_(profile) {} | 212 profile_(profile) {} |
| 212 | 213 |
| 213 DialogEnrollmentDelegate::~DialogEnrollmentDelegate() {} | 214 DialogEnrollmentDelegate::~DialogEnrollmentDelegate() {} |
| 214 | 215 |
| 215 void DialogEnrollmentDelegate::Enroll(const std::vector<std::string>& uri_list, | 216 bool DialogEnrollmentDelegate::Enroll(const std::vector<std::string>& uri_list, |
| 216 const base::Closure& connect) { | 217 const base::Closure& post_action) { |
| 217 // Keep the closure for later activation if we notice that | 218 // Keep the closure for later activation if we notice that |
| 218 // a certificate has been added. | 219 // a certificate has been added. |
| 219 | 220 |
| 220 // TODO(gspencer): Do something smart with the closure. At the moment it is | 221 // TODO(gspencer): Do something smart with the closure. At the moment it is |
| 221 // being ignored because we don't know when the enrollment tab is closed. | 222 // being ignored because we don't know when the enrollment tab is closed. |
| 222 // http://crosbug.com/30422 | 223 // http://crosbug.com/30422 |
| 223 for (std::vector<std::string>::const_iterator iter = uri_list.begin(); | 224 for (std::vector<std::string>::const_iterator iter = uri_list.begin(); |
| 224 iter != uri_list.end(); ++iter) { | 225 iter != uri_list.end(); ++iter) { |
| 225 GURL uri(*iter); | 226 GURL uri(*iter); |
| 226 if (uri.IsStandard() || uri.scheme() == extensions::kExtensionScheme) { | 227 if (uri.IsStandard() || uri.scheme() == extensions::kExtensionScheme) { |
| 227 // If this is a "standard" scheme, like http, ftp, etc., then open that in | 228 // If this is a "standard" scheme, like http, ftp, etc., then open that in |
| 228 // the enrollment dialog. | 229 // the enrollment dialog. |
| 229 EnrollmentDialogView::ShowDialog(owning_window_, | 230 EnrollmentDialogView::ShowDialog(owning_window_, |
| 230 network_name_, | 231 network_name_, |
| 231 profile_, | 232 profile_, |
| 232 uri, connect); | 233 uri, post_action); |
| 233 return; | 234 return true; |
| 234 } | 235 } |
| 235 } | 236 } |
| 236 | 237 |
| 237 // If we didn't find a scheme we could handle, then don't continue connecting. | 238 // If we didn't find a scheme we could handle, then don't continue connecting. |
| 238 // TODO(gspencer): provide a path to display this failure to the user. (but | 239 // TODO(gspencer): provide a path to display this failure to the user. (but |
| 239 // for the most part they won't know what it means, since it's probably coming | 240 // for the most part they won't know what it means, since it's probably coming |
| 240 // from a policy-pushed ONC file). | 241 // from a policy-pushed ONC file). |
| 241 VLOG(1) << "Couldn't find usable scheme in enrollment URI(s)"; | 242 NET_LOG_EVENT("No usable enrollment URI", network_name_); |
| 243 return false; |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace | 246 } // namespace |
| 245 | 247 |
| 246 //////////////////////////////////////////////////////////////////////////////// | 248 //////////////////////////////////////////////////////////////////////////////// |
| 247 // Factory function. | 249 // Factory function. |
| 248 | 250 |
| 249 EnrollmentDelegate* CreateEnrollmentDelegate(gfx::NativeWindow owning_window, | 251 EnrollmentDelegate* CreateEnrollmentDelegate(gfx::NativeWindow owning_window, |
| 250 const std::string& network_name, | 252 const std::string& network_name, |
| 251 Profile* profile) { | 253 Profile* profile) { |
| 252 return new DialogEnrollmentDelegate(owning_window, network_name, profile); | 254 return new DialogEnrollmentDelegate(owning_window, network_name, profile); |
| 253 } | 255 } |
| 254 | 256 |
| 255 } // namespace chromeos | 257 } // namespace chromeos |
| OLD | NEW |