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

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

Issue 10965052: Provide hook to abort dialog cancellation, disable cancellation during install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Combined if clauses. Created 8 years, 2 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
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 virtual void ButtonPressed(views::Button* sender, 765 virtual void ButtonPressed(views::Button* sender,
766 const ui::Event& event) OVERRIDE; 766 const ui::Event& event) OVERRIDE;
767 767
768 // views::DialogDelegate implementation. 768 // views::DialogDelegate implementation.
769 virtual void WindowClosing() OVERRIDE; 769 virtual void WindowClosing() OVERRIDE;
770 virtual void DeleteDelegate() OVERRIDE; 770 virtual void DeleteDelegate() OVERRIDE;
771 virtual views::Widget* GetWidget() OVERRIDE; 771 virtual views::Widget* GetWidget() OVERRIDE;
772 virtual const views::Widget* GetWidget() const OVERRIDE; 772 virtual const views::Widget* GetWidget() const OVERRIDE;
773 virtual views::View* GetContentsView() OVERRIDE; 773 virtual views::View* GetContentsView() OVERRIDE;
774 virtual int GetDialogButtons() const OVERRIDE; 774 virtual int GetDialogButtons() const OVERRIDE;
775 virtual bool Cancel() OVERRIDE;
775 776
776 // LinkListener implementation. 777 // LinkListener implementation.
777 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 778 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
778 779
779 // WebIntentPicker implementation. 780 // WebIntentPicker implementation.
780 virtual void Close() OVERRIDE; 781 virtual void Close() OVERRIDE;
781 virtual void SetActionString(const string16& action) OVERRIDE; 782 virtual void SetActionString(const string16& action) OVERRIDE;
782 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; 783 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
783 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE; 784 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE;
784 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE; 785 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 string16 action_text_; 875 string16 action_text_;
875 876
876 // Ownership of the WebContents we are displaying in the inline disposition. 877 // Ownership of the WebContents we are displaying in the inline disposition.
877 scoped_ptr<WebContents> inline_web_contents_; 878 scoped_ptr<WebContents> inline_web_contents_;
878 879
879 // Indicate if dialog should display its own close button. 880 // Indicate if dialog should display its own close button.
880 // TODO(groby): Only relevant until new ConstrainedWindow is implemented, 881 // TODO(groby): Only relevant until new ConstrainedWindow is implemented,
881 // from then on always true. 882 // from then on always true.
882 bool use_close_button_; 883 bool use_close_button_;
883 884
885 // Signals if the picker can be closed. False during extension install.
886 bool can_close_;
887
884 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews); 888 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews);
885 }; 889 };
886 890
887 // static 891 // static
888 WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents, 892 WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents,
889 WebIntentPickerDelegate* delegate, 893 WebIntentPickerDelegate* delegate,
890 WebIntentPickerModel* model) { 894 WebIntentPickerModel* model) {
891 return new WebIntentPickerViews(tab_contents, delegate, model); 895 return new WebIntentPickerViews(tab_contents, delegate, model);
892 } 896 }
893 897
894 WebIntentPickerViews::WebIntentPickerViews(TabContents* tab_contents, 898 WebIntentPickerViews::WebIntentPickerViews(TabContents* tab_contents,
895 WebIntentPickerDelegate* delegate, 899 WebIntentPickerDelegate* delegate,
896 WebIntentPickerModel* model) 900 WebIntentPickerModel* model)
897 : delegate_(delegate), 901 : delegate_(delegate),
898 model_(model), 902 model_(model),
899 action_label_(NULL), 903 action_label_(NULL),
900 suggestions_label_(NULL), 904 suggestions_label_(NULL),
901 extensions_(NULL), 905 extensions_(NULL),
902 tab_contents_(tab_contents), 906 tab_contents_(tab_contents),
903 webview_(new views::WebView(tab_contents->profile())), 907 webview_(new views::WebView(tab_contents->profile())),
904 contents_(NULL), 908 contents_(NULL),
905 window_(NULL), 909 window_(NULL),
906 more_suggestions_link_(NULL), 910 more_suggestions_link_(NULL),
907 choose_another_service_link_(NULL), 911 choose_another_service_link_(NULL),
908 waiting_view_(NULL), 912 waiting_view_(NULL),
909 displaying_web_contents_(false) { 913 displaying_web_contents_(false),
914 can_close_(true) {
910 use_close_button_ = CommandLine::ForCurrentProcess()->HasSwitch( 915 use_close_button_ = CommandLine::ForCurrentProcess()->HasSwitch(
911 switches::kEnableFramelessConstrainedDialogs); 916 switches::kEnableFramelessConstrainedDialogs);
912 917
913 model_->set_observer(this); 918 model_->set_observer(this);
914 InitContents(); 919 InitContents();
915 920
916 // Show the dialog. 921 // Show the dialog.
917 window_ = new ConstrainedWindowViews(tab_contents, this); 922 window_ = new ConstrainedWindowViews(tab_contents, this);
918 } 923 }
919 924
(...skipping 23 matching lines...) Expand all
943 } 948 }
944 949
945 views::View* WebIntentPickerViews::GetContentsView() { 950 views::View* WebIntentPickerViews::GetContentsView() {
946 return contents_; 951 return contents_;
947 } 952 }
948 953
949 int WebIntentPickerViews::GetDialogButtons() const { 954 int WebIntentPickerViews::GetDialogButtons() const {
950 return ui::DIALOG_BUTTON_NONE; 955 return ui::DIALOG_BUTTON_NONE;
951 } 956 }
952 957
958 bool WebIntentPickerViews::Cancel() {
959 return can_close_;
960 }
961
953 void WebIntentPickerViews::LinkClicked(views::Link* source, int event_flags) { 962 void WebIntentPickerViews::LinkClicked(views::Link* source, int event_flags) {
954 if (source == more_suggestions_link_) { 963 if (source == more_suggestions_link_) {
955 delegate_->OnSuggestionsLinkClicked( 964 delegate_->OnSuggestionsLinkClicked(
956 chrome::DispositionFromEventFlags(event_flags)); 965 chrome::DispositionFromEventFlags(event_flags));
957 } else if (source == choose_another_service_link_) { 966 } else if (source == choose_another_service_link_) {
958 // Signal cancellation of inline disposition. 967 // Signal cancellation of inline disposition.
959 delegate_->OnChooseAnotherService(); 968 delegate_->OnChooseAnotherService();
960 ResetContents(); 969 ResetContents();
961 } else { 970 } else {
962 NOTREACHED(); 971 NOTREACHED();
963 } 972 }
964 } 973 }
965 974
966 void WebIntentPickerViews::Close() { 975 void WebIntentPickerViews::Close() {
967 window_->CloseConstrainedWindow(); 976 window_->CloseConstrainedWindow();
968 } 977 }
969 978
970 void WebIntentPickerViews::SetActionString(const string16& action) { 979 void WebIntentPickerViews::SetActionString(const string16& action) {
971 action_text_ = action; 980 action_text_ = action;
972 981
973 if (action_label_) 982 if (action_label_)
974 action_label_->SetText(action); 983 action_label_->SetText(action);
975 } 984 }
976 985
977 void WebIntentPickerViews::OnExtensionInstallSuccess(const std::string& id) { 986 void WebIntentPickerViews::OnExtensionInstallSuccess(const std::string& id) {
987 can_close_ = true;
978 } 988 }
979 989
980 void WebIntentPickerViews::OnExtensionInstallFailure(const std::string& id) { 990 void WebIntentPickerViews::OnExtensionInstallFailure(const std::string& id) {
981 extensions_->StopThrobber(); 991 extensions_->StopThrobber();
982 more_suggestions_link_->SetEnabled(true); 992 more_suggestions_link_->SetEnabled(true);
993 can_close_ = true;
983 contents_->Layout(); 994 contents_->Layout();
984 995
985 // TODO(binji): What to display to user on failure? 996 // TODO(binji): What to display to user on failure?
986 } 997 }
987 998
988 void WebIntentPickerViews::OnInlineDispositionAutoResize( 999 void WebIntentPickerViews::OnInlineDispositionAutoResize(
989 const gfx::Size& size) { 1000 const gfx::Size& size) {
990 webview_->SetPreferredSize(size); 1001 webview_->SetPreferredSize(size);
991 contents_->Layout(); 1002 contents_->Layout();
992 SizeToContents(); 1003 SizeToContents();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1179
1169 // Disable all buttons. 1180 // Disable all buttons.
1170 // TODO(groby): Add throbber for inline dispo - see http://crbug.com/142519. 1181 // TODO(groby): Add throbber for inline dispo - see http://crbug.com/142519.
1171 extensions_->SetEnabled(false); 1182 extensions_->SetEnabled(false);
1172 more_suggestions_link_->SetEnabled(false); 1183 more_suggestions_link_->SetEnabled(false);
1173 contents_->Layout(); 1184 contents_->Layout();
1174 } 1185 }
1175 1186
1176 void WebIntentPickerViews::OnExtensionInstallClicked( 1187 void WebIntentPickerViews::OnExtensionInstallClicked(
1177 const string16& extension_id) { 1188 const string16& extension_id) {
1189 can_close_ = false;
1178 extensions_->StartThrobber(extension_id); 1190 extensions_->StartThrobber(extension_id);
1179 more_suggestions_link_->SetEnabled(false); 1191 more_suggestions_link_->SetEnabled(false);
1180 contents_->Layout(); 1192 contents_->Layout();
1181 delegate_->OnExtensionInstallRequested(UTF16ToUTF8(extension_id)); 1193 delegate_->OnExtensionInstallRequested(UTF16ToUTF8(extension_id));
1182 } 1194 }
1183 1195
1184 void WebIntentPickerViews::OnExtensionLinkClicked( 1196 void WebIntentPickerViews::OnExtensionLinkClicked(
1185 const string16& extension_id, 1197 const string16& extension_id,
1186 WindowOpenDisposition disposition) { 1198 WindowOpenDisposition disposition) {
1187 delegate_->OnExtensionLinkClicked(UTF16ToUTF8(extension_id), disposition); 1199 delegate_->OnExtensionLinkClicked(UTF16ToUTF8(extension_id), disposition);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 SizeToContents(); 1320 SizeToContents();
1309 } 1321 }
1310 1322
1311 void WebIntentPickerViews::SizeToContents() { 1323 void WebIntentPickerViews::SizeToContents() {
1312 gfx::Size client_size = contents_->GetPreferredSize(); 1324 gfx::Size client_size = contents_->GetPreferredSize();
1313 gfx::Rect client_bounds(client_size); 1325 gfx::Rect client_bounds(client_size);
1314 gfx::Rect new_window_bounds = window_->non_client_view()->frame_view()-> 1326 gfx::Rect new_window_bounds = window_->non_client_view()->frame_view()->
1315 GetWindowBoundsForClientBounds(client_bounds); 1327 GetWindowBoundsForClientBounds(client_bounds);
1316 window_->CenterWindow(new_window_bounds.size()); 1328 window_->CenterWindow(new_window_bounds.size());
1317 } 1329 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698