| 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/ui/cocoa/web_intent_picker_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 parentWindow:parentWindow | 68 parentWindow:parentWindow |
| 69 anchoredAt:anchor]; | 69 anchoredAt:anchor]; |
| 70 } | 70 } |
| 71 | 71 |
| 72 WebIntentPickerCocoa::~WebIntentPickerCocoa() { | 72 WebIntentPickerCocoa::~WebIntentPickerCocoa() { |
| 73 if (model_ != NULL) | 73 if (model_ != NULL) |
| 74 model_->set_observer(NULL); | 74 model_->set_observer(NULL); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void WebIntentPickerCocoa::Close() { | 77 void WebIntentPickerCocoa::Close() { |
| 78 DCHECK(controller_); |
| 79 [controller_ close]; |
| 80 if (inline_disposition_tab_contents_.get()) |
| 81 inline_disposition_tab_contents_->web_contents()->OnCloseStarted(); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void WebIntentPickerCocoa::PerformDelayedLayout() { | 84 void WebIntentPickerCocoa::PerformDelayedLayout() { |
| 81 // Check to see if a layout has already been scheduled. | 85 // Check to see if a layout has already been scheduled. |
| 82 if (weak_ptr_factory_.HasWeakPtrs()) | 86 if (weak_ptr_factory_.HasWeakPtrs()) |
| 83 return; | 87 return; |
| 84 | 88 |
| 85 // Delay performing layout by a second so that all the animations from | 89 // Delay performing layout by a second so that all the animations from |
| 86 // InfoBubbleWindow and origin updates from BaseBubbleController finish, so | 90 // InfoBubbleWindow and origin updates from BaseBubbleController finish, so |
| 87 // that we don't all race trying to change the frame's origin. | 91 // that we don't all race trying to change the frame's origin. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 [controller_ setInlineDispositionTabContents: | 139 [controller_ setInlineDispositionTabContents: |
| 136 inline_disposition_tab_contents_.get()]; | 140 inline_disposition_tab_contents_.get()]; |
| 137 PerformDelayedLayout(); | 141 PerformDelayedLayout(); |
| 138 | 142 |
| 139 delegate_->OnInlineDispositionWebContentsCreated(web_contents); | 143 delegate_->OnInlineDispositionWebContentsCreated(web_contents); |
| 140 } | 144 } |
| 141 | 145 |
| 142 void WebIntentPickerCocoa::OnCancelled() { | 146 void WebIntentPickerCocoa::OnCancelled() { |
| 143 DCHECK(delegate_); | 147 DCHECK(delegate_); |
| 144 delegate_->OnCancelled(); | 148 delegate_->OnCancelled(); |
| 145 controller_ = NULL; // Controller will be unusable soon, abandon. | 149 delegate_->OnClosing(); |
| 150 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 146 } | 151 } |
| 147 | 152 |
| 148 void WebIntentPickerCocoa::OnServiceChosen(size_t index) { | 153 void WebIntentPickerCocoa::OnServiceChosen(size_t index) { |
| 149 DCHECK(delegate_); | 154 DCHECK(delegate_); |
| 150 const WebIntentPickerModel::Item& item = model_->GetItemAt(index); | 155 const WebIntentPickerModel::Item& item = model_->GetItemAt(index); |
| 151 delegate_->OnServiceChosen(index, item.disposition); | 156 delegate_->OnServiceChosen(index, item.disposition); |
| 152 } | 157 } |
| 153 | 158 |
| 154 void WebIntentPickerCocoa::set_controller( | 159 void WebIntentPickerCocoa::set_controller( |
| 155 WebIntentBubbleController* controller) { | 160 WebIntentBubbleController* controller) { |
| 156 controller_ = controller; | 161 controller_ = controller; |
| 157 } | 162 } |
| OLD | NEW |