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/views/chrome_to_mobile_bubble_view.h" | 5 #include "chrome/browser/ui/views/chrome_to_mobile_bubble_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 void ChromeToMobileBubbleView::Hide() { | 122 void ChromeToMobileBubbleView::Hide() { |
123 if (IsShowing()) | 123 if (IsShowing()) |
124 bubble_->GetWidget()->Close(); | 124 bubble_->GetWidget()->Close(); |
125 } | 125 } |
126 | 126 |
127 views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() { | 127 views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() { |
128 return send_; | 128 return send_; |
129 } | 129 } |
130 | 130 |
131 gfx::Rect ChromeToMobileBubbleView::GetAnchorRect() { | |
132 // Compensate for some built-in padding in the page action icon image. | |
133 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); | |
134 rect.Inset(0, anchor_view() ? 5 : 0); | |
135 return rect; | |
136 } | |
137 | |
138 void ChromeToMobileBubbleView::WindowClosing() { | 131 void ChromeToMobileBubbleView::WindowClosing() { |
139 // We have to reset |bubble_| here, not in our destructor, because we'll be | 132 // We have to reset |bubble_| here, not in our destructor, because we'll be |
140 // destroyed asynchronously and the shown state will be checked before then. | 133 // destroyed asynchronously and the shown state will be checked before then. |
141 DCHECK(bubble_ == this); | 134 DCHECK(bubble_ == this); |
142 bubble_ = NULL; | 135 bubble_ = NULL; |
143 | 136 |
144 // Instruct the service to delete the snapshot file. | 137 // Instruct the service to delete the snapshot file. |
145 service_->DeleteSnapshot(snapshot_path_); | 138 service_->DeleteSnapshot(snapshot_path_); |
146 | 139 |
147 // Restore the resting state mobile device icon. | 140 // Restore the resting state mobile device icon. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 317 |
325 ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view, | 318 ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view, |
326 Browser* browser) | 319 Browser* browser) |
327 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 320 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
328 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | 321 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
329 browser_(browser), | 322 browser_(browser), |
330 service_(ChromeToMobileServiceFactory::GetForProfile(browser->profile())), | 323 service_(ChromeToMobileServiceFactory::GetForProfile(browser->profile())), |
331 send_copy_(NULL), | 324 send_copy_(NULL), |
332 send_(NULL), | 325 send_(NULL), |
333 cancel_(NULL) { | 326 cancel_(NULL) { |
| 327 // Compensate for built-in vertical padding in the anchor view's image. |
| 328 set_anchor_insets(gfx::Insets(5, 0, 5, 0)); |
| 329 |
334 // Generate the MHTML snapshot now to report its size in the bubble. | 330 // Generate the MHTML snapshot now to report its size in the bubble. |
335 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); | 331 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); |
336 | 332 |
337 // Request a mobile device list update. | 333 // Request a mobile device list update. |
338 service_->RequestMobileListUpdate(); | 334 service_->RequestMobileListUpdate(); |
339 } | 335 } |
340 | 336 |
341 void ChromeToMobileBubbleView::LinkClicked(views::Link* source, | 337 void ChromeToMobileBubbleView::LinkClicked(views::Link* source, |
342 int event_flags) { | 338 int event_flags) { |
343 service_->LearnMore(browser_); | 339 service_->LearnMore(browser_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 371 } |
376 | 372 |
377 // Update the view's contents to show the "Sending..." progress animation. | 373 // Update the view's contents to show the "Sending..." progress animation. |
378 cancel_->SetEnabled(false); | 374 cancel_->SetEnabled(false); |
379 send_->SetEnabled(false); | 375 send_->SetEnabled(false); |
380 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); | 376 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); |
381 progress_animation_.reset(new ui::ThrobAnimation(this)); | 377 progress_animation_.reset(new ui::ThrobAnimation(this)); |
382 progress_animation_->SetDuration(kProgressThrobDurationMS); | 378 progress_animation_->SetDuration(kProgressThrobDurationMS); |
383 progress_animation_->StartThrobbing(-1); | 379 progress_animation_->StartThrobbing(-1); |
384 } | 380 } |
OLD | NEW |