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

Unified Diff: chrome/browser/chromeos/enrollment_dialog_view.cc

Issue 12089026: Fixing opening a new tab if none exists to show the enrollment URI for certificates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Sky's comment. Some more cleanup. Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/enrollment_dialog_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/enrollment_dialog_view.cc
diff --git a/chrome/browser/chromeos/enrollment_dialog_view.cc b/chrome/browser/chromeos/enrollment_dialog_view.cc
index cfab93da7affe423e7325dba572a92c394d86f0e..4b1266dba8153e58393129c87ad181e31692340b 100644
--- a/chrome/browser/chromeos/enrollment_dialog_view.cc
+++ b/chrome/browser/chromeos/enrollment_dialog_view.cc
@@ -8,10 +8,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_navigator.h"
#include "content/public/common/page_transition_types.h"
#include "extensions/common/constants.h"
#include "grit/generated_resources.h"
@@ -21,6 +19,7 @@
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/window/dialog_delegate.h"
namespace chromeos {
@@ -46,6 +45,7 @@ class EnrollmentDialogView : public views::DialogDelegateView {
// views::DialogDelegateView overrides
virtual int GetDialogButtons() const OVERRIDE;
virtual bool Accept() OVERRIDE;
+ virtual void OnClose() OVERRIDE;
virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
// views::WidgetDelegate overrides
@@ -62,6 +62,7 @@ class EnrollmentDialogView : public views::DialogDelegateView {
const base::Closure& connect);
void InitDialog();
+ bool accepted_;
std::string network_name_;
Profile* profile_;
GURL target_uri_;
@@ -76,7 +77,8 @@ EnrollmentDialogView::EnrollmentDialogView(const std::string& network_name,
Profile* profile,
const GURL& target_uri,
const base::Closure& connect)
- : network_name_(network_name),
+ : accepted_(false),
+ network_name_(network_name),
profile_(profile),
target_uri_(target_uri),
connect_(connect),
@@ -106,23 +108,21 @@ int EnrollmentDialogView::GetDialogButtons() const {
}
bool EnrollmentDialogView::Accept() {
- // TODO(beng): use Navigate().
- // Navigate to the target URI in a browser tab.
- Browser* browser = chrome::FindTabbedBrowser(profile_, false,
- chrome::HOST_DESKTOP_TYPE_ASH);
- if (!browser) {
- // Couldn't find a tabbed browser: create one.
- browser = new Browser(
- Browser::CreateParams(Browser::TYPE_TABBED,
- profile_,
- chrome::HOST_DESKTOP_TYPE_ASH));
- }
- DCHECK(browser);
- chrome::AddSelectedTabWithURL(browser, target_uri_,
- content::PAGE_TRANSITION_LINK);
+ accepted_ = true;
return true;
}
+void EnrollmentDialogView::OnClose() {
+ if (!accepted_)
+ return;
+ chrome::NavigateParams params(profile_,
+ GURL(target_uri_),
+ content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_FOREGROUND_TAB;
+ params.window_action = chrome::NavigateParams::SHOW_WINDOW;
+ chrome::Navigate(&params);
+}
+
string16 EnrollmentDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
« no previous file with comments | « chrome/browser/chromeos/enrollment_dialog_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698