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

Side by Side Diff: chrome/browser/ui/views/chrome_to_mobile_bubble_view.cc

Issue 10885024: Integrate Chrome To Mobile with Action Box UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nil/NULL checks in ChromeToMobileBubbleController. Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_to_mobile_service.h" 15 #include "chrome/browser/chrome_to_mobile_service.h"
16 #include "chrome/browser/chrome_to_mobile_service_factory.h" 16 #include "chrome/browser/chrome_to_mobile_service_factory.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "ui/base/animation/throb_animation.h" 20 #include "ui/base/animation/throb_animation.h"
21 #include "ui/base/keycodes/keyboard_codes.h" 21 #include "ui/base/keycodes/keyboard_codes.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/base/text/bytes_formatting.h" 24 #include "ui/base/text/bytes_formatting.h"
25 #include "ui/views/controls/button/checkbox.h" 25 #include "ui/views/controls/button/checkbox.h"
26 #include "ui/views/controls/button/radio_button.h" 26 #include "ui/views/controls/button/radio_button.h"
27 #include "ui/views/controls/button/text_button.h" 27 #include "ui/views/controls/button/text_button.h"
28 #include "ui/views/controls/image_view.h"
29 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
30 #include "ui/views/controls/link.h" 29 #include "ui/views/controls/link.h"
31 #include "ui/views/layout/grid_layout.h" 30 #include "ui/views/layout/grid_layout.h"
32 #include "ui/views/layout/layout_constants.h" 31 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
34 33
35 using views::GridLayout; 34 using views::GridLayout;
36 35
37 namespace { 36 namespace {
38 37
(...skipping 23 matching lines...) Expand all
62 views::NativeThemeDelegate* delegate) 61 views::NativeThemeDelegate* delegate)
63 : views::TextButtonNativeThemeBorder(delegate) {} 62 : views::TextButtonNativeThemeBorder(delegate) {}
64 63
65 CheckboxNativeThemeBorder::~CheckboxNativeThemeBorder() {} 64 CheckboxNativeThemeBorder::~CheckboxNativeThemeBorder() {}
66 65
67 void CheckboxNativeThemeBorder::GetInsets(gfx::Insets* insets) const { 66 void CheckboxNativeThemeBorder::GetInsets(gfx::Insets* insets) const {
68 views::TextButtonNativeThemeBorder::GetInsets(insets); 67 views::TextButtonNativeThemeBorder::GetInsets(insets);
69 insets->Set(insets->top(), 0, insets->bottom(), insets->right()); 68 insets->Set(insets->top(), 0, insets->bottom(), insets->right());
70 } 69 }
71 70
72 // Downcast the View to an ImageView and set the image with the resource |id|. 71 // Downcast TextButton |view| and set the icon image with the resource |id|.
73 void SetImageViewToId(views::View* image_view, int id) { 72 void SetTextButtonIconToId(views::View* view, int id) {
74 static_cast<views::ImageView*>(image_view)-> 73 static_cast<views::TextButton*>(view)->
75 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id)); 74 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id));
76 } 75 }
77 76
78 } // namespace 77 } // namespace
79 78
80 // Declared in browser_dialogs.h so callers don't have to depend on our header. 79 // Declared in browser_dialogs.h so callers don't have to depend on our header.
81 80
82 namespace chrome { 81 namespace chrome {
83 82
84 void ShowChromeToMobileBubbleView(views::View* anchor_view, Browser* browser) { 83 void ShowChromeToMobileBubbleView(views::View* anchor_view, Browser* browser) {
85 ChromeToMobileBubbleView::ShowBubble(anchor_view, browser); 84 ChromeToMobileBubbleView::ShowBubble(anchor_view, browser);
(...skipping 15 matching lines...) Expand all
101 100
102 ChromeToMobileBubbleView::~ChromeToMobileBubbleView() {} 101 ChromeToMobileBubbleView::~ChromeToMobileBubbleView() {}
103 102
104 // static 103 // static
105 void ChromeToMobileBubbleView::ShowBubble(views::View* anchor_view, 104 void ChromeToMobileBubbleView::ShowBubble(views::View* anchor_view,
106 Browser* browser) { 105 Browser* browser) {
107 if (IsShowing()) 106 if (IsShowing())
108 return; 107 return;
109 108
110 // Show the lit mobile device icon during the bubble's lifetime. 109 // Show the lit mobile device icon during the bubble's lifetime.
111 SetImageViewToId(anchor_view, IDR_MOBILE_LIT); 110 SetTextButtonIconToId(anchor_view, IDR_MOBILE_LIT);
112 bubble_ = new ChromeToMobileBubbleView(anchor_view, browser); 111 bubble_ = new ChromeToMobileBubbleView(anchor_view, browser);
113 views::BubbleDelegateView::CreateBubble(bubble_); 112 views::BubbleDelegateView::CreateBubble(bubble_);
114 bubble_->Show(); 113 bubble_->Show();
115 } 114 }
116 115
117 // static 116 // static
118 bool ChromeToMobileBubbleView::IsShowing() { 117 bool ChromeToMobileBubbleView::IsShowing() {
119 return bubble_ != NULL; 118 return bubble_ != NULL;
120 } 119 }
121 120
122 void ChromeToMobileBubbleView::Hide() { 121 void ChromeToMobileBubbleView::Hide() {
123 if (IsShowing()) 122 if (IsShowing())
124 bubble_->GetWidget()->Close(); 123 bubble_->GetWidget()->Close();
125 } 124 }
126 125
127 views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() { 126 views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() {
128 return send_; 127 return send_;
129 } 128 }
130 129
131 void ChromeToMobileBubbleView::WindowClosing() { 130 void ChromeToMobileBubbleView::WindowClosing() {
132 // We have to reset |bubble_| here, not in our destructor, because we'll be 131 // We have to reset |bubble_| here, not in our destructor, because we'll be
133 // destroyed asynchronously and the shown state will be checked before then. 132 // destroyed asynchronously and the shown state will be checked before then.
134 DCHECK(bubble_ == this); 133 DCHECK(bubble_ == this);
135 bubble_ = NULL; 134 bubble_ = NULL;
136 135
137 // Instruct the service to delete the snapshot file. 136 // Instruct the service to delete the snapshot file.
138 service_->DeleteSnapshot(snapshot_path_); 137 service_->DeleteSnapshot(snapshot_path_);
139 138
140 // Restore the resting state mobile device icon. 139 // Restore the resting state action box icon.
141 SetImageViewToId(anchor_view(), IDR_MOBILE); 140 SetTextButtonIconToId(anchor_view(), IDR_ACTION_BOX_BUTTON);
142 } 141 }
143 142
144 bool ChromeToMobileBubbleView::AcceleratorPressed( 143 bool ChromeToMobileBubbleView::AcceleratorPressed(
145 const ui::Accelerator& accelerator) { 144 const ui::Accelerator& accelerator) {
146 if (accelerator.key_code() == ui::VKEY_RETURN && 145 if (accelerator.key_code() == ui::VKEY_RETURN &&
147 (send_->HasFocus() || cancel_->HasFocus())) { 146 (send_->HasFocus() || cancel_->HasFocus())) {
148 HandleButtonPressed(send_->HasFocus() ? send_ : cancel_); 147 HandleButtonPressed(send_->HasFocus() ? send_ : cancel_);
149 return true; 148 return true;
150 } 149 }
151 return BubbleDelegateView::AcceleratorPressed(accelerator); 150 return BubbleDelegateView::AcceleratorPressed(accelerator);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 367 }
369 368
370 // Update the view's contents to show the "Sending..." progress animation. 369 // Update the view's contents to show the "Sending..." progress animation.
371 cancel_->SetEnabled(false); 370 cancel_->SetEnabled(false);
372 send_->SetEnabled(false); 371 send_->SetEnabled(false);
373 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); 372 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT);
374 progress_animation_.reset(new ui::ThrobAnimation(this)); 373 progress_animation_.reset(new ui::ThrobAnimation(this));
375 progress_animation_->SetDuration(kProgressThrobDurationMS); 374 progress_animation_->SetDuration(kProgressThrobDurationMS);
376 progress_animation_->StartThrobbing(-1); 375 progress_animation_->StartThrobbing(-1);
377 } 376 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/view_ids.h ('k') | chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698