| 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/ui/intents/web_intent_constrained_dialog_factory.h" | 5 #include "chrome/browser/ui/intents/web_intent_constrained_dialog_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/intents/web_intent_picker.h" | 7 #include "chrome/browser/ui/intents/web_intent_picker.h" |
| 8 #include "content/browser/tab_contents/constrained_window.h" | 8 #include "content/browser/tab_contents/constrained_window.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" | 9 #include "content/browser/tab_contents/tab_contents.h" |
| 10 | 10 |
| 11 WebIntentConstrainedDialogFactory::WebIntentConstrainedDialogFactory() | 11 WebIntentConstrainedDialogFactory::WebIntentConstrainedDialogFactory() |
| 12 : picker_(NULL) { | 12 : picker_(NULL) { |
| 13 } | 13 } |
| 14 | 14 |
| 15 WebIntentConstrainedDialogFactory::~WebIntentConstrainedDialogFactory() { | 15 WebIntentConstrainedDialogFactory::~WebIntentConstrainedDialogFactory() { |
| 16 CloseDialog(); | 16 CloseDialog(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 WebIntentPicker* WebIntentConstrainedDialogFactory::Create( | 19 WebIntentPicker* WebIntentConstrainedDialogFactory::Create( |
| 20 TabContents* tab_contents, | 20 TabContentsWrapper* wrapper, |
| 21 WebIntentPickerDelegate* delegate) { | 21 WebIntentPickerDelegate* delegate) { |
| 22 // Only allow one picker per factory. | 22 // Only allow one picker per factory. |
| 23 DCHECK(picker_ == NULL); | 23 DCHECK(picker_ == NULL); |
| 24 | 24 |
| 25 picker_ = WebIntentPicker::Create(tab_contents, delegate); | 25 picker_ = WebIntentPicker::Create(wrapper, delegate); |
| 26 | 26 |
| 27 // TODO(binji) Remove this check when there are implementations of the picker | 27 // TODO(binji) Remove this check when there are implementations of the picker |
| 28 // for windows and mac. | 28 // for windows and mac. |
| 29 if (picker_ == NULL) | 29 if (picker_ == NULL) |
| 30 return NULL; | 30 return NULL; |
| 31 | 31 |
| 32 picker_->Show(); | 32 picker_->Show(); |
| 33 | 33 |
| 34 return picker_; | 34 return picker_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void WebIntentConstrainedDialogFactory::ClosePicker(WebIntentPicker* picker) { | 37 void WebIntentConstrainedDialogFactory::ClosePicker(WebIntentPicker* picker) { |
| 38 DCHECK(picker == picker_); | 38 DCHECK(picker == picker_); |
| 39 CloseDialog(); | 39 CloseDialog(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WebIntentConstrainedDialogFactory::CloseDialog() { | 42 void WebIntentConstrainedDialogFactory::CloseDialog() { |
| 43 if (picker_) { | 43 if (picker_) { |
| 44 picker_->Close(); | 44 picker_->Close(); |
| 45 picker_ = NULL; | 45 picker_ = NULL; |
| 46 } | 46 } |
| 47 } | 47 } |
| OLD | NEW |