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

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

Issue 10703121: [WebIntents, Views] Add dialog for empty picker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | no next file » | 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/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 // LinkListener implementation. 683 // LinkListener implementation.
684 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 684 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
685 685
686 // WebIntentPicker implementation. 686 // WebIntentPicker implementation.
687 virtual void Close() OVERRIDE; 687 virtual void Close() OVERRIDE;
688 virtual void SetActionString(const string16& action) OVERRIDE; 688 virtual void SetActionString(const string16& action) OVERRIDE;
689 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; 689 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
690 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE; 690 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE;
691 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE; 691 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE;
692 virtual void OnPendingAsyncCompleted() OVERRIDE;
692 virtual void OnInlineDispositionWebContentsLoaded( 693 virtual void OnInlineDispositionWebContentsLoaded(
693 content::WebContents* web_contents) OVERRIDE; 694 content::WebContents* web_contents) OVERRIDE;
694 695
695 // WebIntentPickerModelObserver implementation. 696 // WebIntentPickerModelObserver implementation.
696 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE; 697 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE;
697 virtual void OnFaviconChanged(WebIntentPickerModel* model, 698 virtual void OnFaviconChanged(WebIntentPickerModel* model,
698 size_t index) OVERRIDE; 699 size_t index) OVERRIDE;
699 virtual void OnExtensionIconChanged(WebIntentPickerModel* model, 700 virtual void OnExtensionIconChanged(WebIntentPickerModel* model,
700 const string16& extension_id) OVERRIDE; 701 const string16& extension_id) OVERRIDE;
701 virtual void OnInlineDisposition(const string16& title, 702 virtual void OnInlineDisposition(const string16& title,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 // TODO(binji): What to display to user on failure? 886 // TODO(binji): What to display to user on failure?
886 } 887 }
887 888
888 void WebIntentPickerViews::OnInlineDispositionAutoResize( 889 void WebIntentPickerViews::OnInlineDispositionAutoResize(
889 const gfx::Size& size) { 890 const gfx::Size& size) {
890 webview_->SetPreferredSize(size); 891 webview_->SetPreferredSize(size);
891 contents_->Layout(); 892 contents_->Layout();
892 SizeToContents(); 893 SizeToContents();
893 } 894 }
894 895
896 void WebIntentPickerViews::OnPendingAsyncCompleted() {
897 // Requests to both the WebIntentService and the Chrome Web Store have
898 // completed. If there are any services, installed or suggested, there's
899 // nothing to do.
900 if (model_->GetInstalledServiceCount() ||
901 model_->GetSuggestedExtensionCount())
902 return;
903
904 // If there are no installed or suggested services at this point,
905 // inform the user about it.
906 contents_->RemoveAllChildViews(true);
907 more_suggestions_link_ = NULL;
908
909 views::GridLayout* grid_layout = new views::GridLayout(contents_);
910 contents_->SetLayoutManager(grid_layout);
911
912 grid_layout->SetInsets(kContentAreaBorder, kContentAreaBorder,
913 kContentAreaBorder, kContentAreaBorder);
914 views::ColumnSet* main_cs = grid_layout->AddColumnSet(0);
915 main_cs->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
916 GridLayout::USE_PREF, 0, 0);
917
918 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
919
920 grid_layout->StartRow(0, 0);
921 views::Label* header = new views::Label();
922 header->SetVisible(true);
923 header->SetMultiLine(false);
Peter Kasting 2012/07/11 23:47:47 Nit: Isn't multiline=false the default? I thought
groby-ooo-7-16 2012/07/12 00:00:38 Yes, it is - thanks for pointing it out. On 2012/0
924 header->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
925 header->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont));
926 header->SetText(l10n_util::GetStringUTF16(
927 IDS_INTENT_PICKER_NO_SERVICES_TITLE));
928 grid_layout->AddView(header);
929
930 grid_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
931
932 grid_layout->StartRow(0, 0);
933 views::Label* body = new views::Label();
934 body->SetVisible(true);
935 body->SetMultiLine(true);
936 body->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
937 body->SetText(l10n_util::GetStringUTF16(IDS_INTENT_PICKER_NO_SERVICES));
938 grid_layout->AddView(body);
939
940 contents_->Layout();
941 SizeToContents();
942 }
943
895 void WebIntentPickerViews::OnInlineDispositionWebContentsLoaded( 944 void WebIntentPickerViews::OnInlineDispositionWebContentsLoaded(
896 content::WebContents* web_contents) { 945 content::WebContents* web_contents) {
897 if (displaying_web_contents_) 946 if (displaying_web_contents_)
898 return; 947 return;
899 948
900 // Replace the picker with the inline disposition. 949 // Replace the picker with the inline disposition.
901 contents_->RemoveAllChildViews(true); 950 contents_->RemoveAllChildViews(true);
902 more_suggestions_link_ = NULL; 951 more_suggestions_link_ = NULL;
903 952
904 views::GridLayout* grid_layout = new views::GridLayout(contents_); 953 views::GridLayout* grid_layout = new views::GridLayout(contents_);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 views::ImageButton* close_button = new views::ImageButton(this); 1213 views::ImageButton* close_button = new views::ImageButton(this);
1165 close_button->SetImage(views::CustomButton::BS_NORMAL, 1214 close_button->SetImage(views::CustomButton::BS_NORMAL,
1166 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); 1215 rb.GetImageSkiaNamed(IDR_CLOSE_BAR));
1167 close_button->SetImage(views::CustomButton::BS_HOT, 1216 close_button->SetImage(views::CustomButton::BS_HOT,
1168 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); 1217 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H));
1169 close_button->SetImage(views::CustomButton::BS_PUSHED, 1218 close_button->SetImage(views::CustomButton::BS_PUSHED,
1170 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); 1219 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P));
1171 return close_button; 1220 return close_button;
1172 } 1221 }
1173 #endif 1222 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698