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