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

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

Issue 10134026: Remove browser from web intents UI code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Browser test compilation Created 8 years, 7 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
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 "chrome/browser/tab_contents/tab_util.h" 10 #include "chrome/browser/tab_contents/tab_util.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_navigator.h" 11 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" 12 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
14 #include "chrome/browser/ui/intents/web_intent_picker.h" 13 #include "chrome/browser/ui/intents/web_intent_picker.h"
15 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 14 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
16 #include "chrome/browser/ui/intents/web_intent_picker_model.h" 15 #include "chrome/browser/ui/intents/web_intent_picker_model.h"
17 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" 16 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/browser/ui/views/constrained_window_views.h" 18 #include "chrome/browser/ui/views/constrained_window_views.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 19 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 20 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 654
656 // Views implementation of WebIntentPicker. 655 // Views implementation of WebIntentPicker.
657 class WebIntentPickerViews : public views::ButtonListener, 656 class WebIntentPickerViews : public views::ButtonListener,
658 public views::DialogDelegate, 657 public views::DialogDelegate,
659 public views::LinkListener, 658 public views::LinkListener,
660 public WebIntentPicker, 659 public WebIntentPicker,
661 public WebIntentPickerModelObserver, 660 public WebIntentPickerModelObserver,
662 public ServiceButtonsView::Delegate, 661 public ServiceButtonsView::Delegate,
663 public SuggestedExtensionsRowView::Delegate { 662 public SuggestedExtensionsRowView::Delegate {
664 public: 663 public:
665 WebIntentPickerViews(Browser* browser, 664 WebIntentPickerViews(TabContentsWrapper* tab_contents,
666 TabContentsWrapper* tab_contents,
667 WebIntentPickerDelegate* delegate, 665 WebIntentPickerDelegate* delegate,
668 WebIntentPickerModel* model); 666 WebIntentPickerModel* model);
669 virtual ~WebIntentPickerViews(); 667 virtual ~WebIntentPickerViews();
670 668
671 // views::ButtonListener implementation. 669 // views::ButtonListener implementation.
672 virtual void ButtonPressed(views::Button* sender, 670 virtual void ButtonPressed(views::Button* sender,
673 const views::Event& event) OVERRIDE; 671 const views::Event& event) OVERRIDE;
674 672
675 // views::DialogDelegate implementation. 673 // views::DialogDelegate implementation.
676 virtual void WindowClosing() OVERRIDE; 674 virtual void WindowClosing() OVERRIDE;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 734
737 // A weak pointer to the header label for the extension suggestions. 735 // A weak pointer to the header label for the extension suggestions.
738 views::Label* suggestions_label_; 736 views::Label* suggestions_label_;
739 737
740 // A weak pointer to the extensions view. 738 // A weak pointer to the extensions view.
741 SuggestedExtensionsView* extensions_; 739 SuggestedExtensionsView* extensions_;
742 740
743 // Delegate for inline disposition tab contents. 741 // Delegate for inline disposition tab contents.
744 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_; 742 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_;
745 743
746 // A weak pointer to the browser this picker is in. 744 // A weak pointer to the wrapper of the WebContents this picker is in.
747 Browser* browser_; 745 TabContentsWrapper* wrapper_;
748 746
749 // A weak pointer to the WebView that hosts the WebContents being displayed. 747 // A weak pointer to the WebView that hosts the WebContents being displayed.
750 views::WebView* webview_; 748 views::WebView* webview_;
751 749
752 // A weak pointer to the view that contains all other views in the picker. 750 // A weak pointer to the view that contains all other views in the picker.
753 views::View* contents_; 751 views::View* contents_;
754 752
755 // A weak pointer to the constrained window. 753 // A weak pointer to the constrained window.
756 ConstrainedWindowViews* window_; 754 ConstrainedWindowViews* window_;
757 755
758 // A weak pointer to the more suggestions link. 756 // A weak pointer to the more suggestions link.
759 views::Link* more_suggestions_link_; 757 views::Link* more_suggestions_link_;
760 758
761 // A weak pointer to the choose another service link. 759 // A weak pointer to the choose another service link.
762 views::Link* choose_another_service_link_; 760 views::Link* choose_another_service_link_;
763 761
764 // Set to true when displaying the inline disposition web contents. Used to 762 // Set to true when displaying the inline disposition web contents. Used to
765 // prevent laying out the inline disposition widgets twice. 763 // prevent laying out the inline disposition widgets twice.
766 bool displaying_web_contents_; 764 bool displaying_web_contents_;
767 765
768 // Ownership of the WebContents we are displaying in the inline disposition. 766 // Ownership of the WebContents we are displaying in the inline disposition.
769 scoped_ptr<WebContents> inline_web_contents_; 767 scoped_ptr<WebContents> inline_web_contents_;
770 768
771 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews); 769 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews);
772 }; 770 };
773 771
774 // static 772 // static
775 WebIntentPicker* WebIntentPicker::Create(Browser* browser, 773 WebIntentPicker* WebIntentPicker::Create(TabContentsWrapper* wrapper,
776 TabContentsWrapper* wrapper,
777 WebIntentPickerDelegate* delegate, 774 WebIntentPickerDelegate* delegate,
778 WebIntentPickerModel* model) { 775 WebIntentPickerModel* model) {
779 WebIntentPickerViews* picker = 776 WebIntentPickerViews* picker =
780 new WebIntentPickerViews(browser, wrapper, delegate, model); 777 new WebIntentPickerViews(wrapper, delegate, model);
781 778
782 return picker; 779 return picker;
783 } 780 }
784 781
785 WebIntentPickerViews::WebIntentPickerViews(Browser* browser, 782 WebIntentPickerViews::WebIntentPickerViews(TabContentsWrapper* wrapper,
786 TabContentsWrapper* wrapper,
787 WebIntentPickerDelegate* delegate, 783 WebIntentPickerDelegate* delegate,
788 WebIntentPickerModel* model) 784 WebIntentPickerModel* model)
789 : delegate_(delegate), 785 : delegate_(delegate),
790 model_(model), 786 model_(model),
791 service_buttons_(NULL), 787 service_buttons_(NULL),
792 action_label_(NULL), 788 action_label_(NULL),
793 suggestions_label_(NULL), 789 suggestions_label_(NULL),
794 extensions_(NULL), 790 extensions_(NULL),
795 browser_(browser), 791 wrapper_(wrapper),
796 webview_(new views::WebView(browser->profile())), 792 webview_(new views::WebView(wrapper->profile())),
797 contents_(NULL), 793 contents_(NULL),
798 window_(NULL), 794 window_(NULL),
799 more_suggestions_link_(NULL), 795 more_suggestions_link_(NULL),
800 choose_another_service_link_(NULL), 796 choose_another_service_link_(NULL),
801 displaying_web_contents_(false) { 797 displaying_web_contents_(false) {
802 model_->set_observer(this); 798 model_->set_observer(this);
803 InitContents(); 799 InitContents();
804 800
805 // Show the dialog. 801 // Show the dialog.
806 window_ = new ConstrainedWindowViews(wrapper, this); 802 window_ = new ConstrainedWindowViews(wrapper, this);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 WebIntentPickerModel* model, 956 WebIntentPickerModel* model,
961 const string16& extension_id) { 957 const string16& extension_id) {
962 extensions_->Update(); 958 extensions_->Update();
963 contents_->Layout(); 959 contents_->Layout();
964 SizeToContents(); 960 SizeToContents();
965 } 961 }
966 962
967 void WebIntentPickerViews::OnInlineDisposition( 963 void WebIntentPickerViews::OnInlineDisposition(
968 WebIntentPickerModel* model, const GURL& url) { 964 WebIntentPickerModel* model, const GURL& url) {
969 inline_web_contents_.reset(WebContents::Create( 965 inline_web_contents_.reset(WebContents::Create(
970 browser_->profile(), 966 wrapper_->profile(),
971 tab_util::GetSiteInstanceForNewTab(browser_->profile(), url), 967 tab_util::GetSiteInstanceForNewTab(wrapper_->profile(), url),
972 MSG_ROUTING_NONE, NULL, NULL)); 968 MSG_ROUTING_NONE, NULL, NULL));
973 // Does not take ownership, so we keep a scoped_ptr 969 // Does not take ownership, so we keep a scoped_ptr
974 // for the WebContents locally. 970 // for the WebContents locally.
975 webview_->SetWebContents(inline_web_contents_.get()); 971 webview_->SetWebContents(inline_web_contents_.get());
976 inline_disposition_delegate_.reset( 972 inline_disposition_delegate_.reset(
977 new WebIntentInlineDispositionDelegate(this)); 973 new WebIntentInlineDispositionDelegate(this));
978 content::WebContents* web_contents = webview_->GetWebContents(); 974 content::WebContents* web_contents = webview_->GetWebContents();
979 web_contents->SetDelegate(inline_disposition_delegate_.get()); 975 web_contents->SetDelegate(inline_disposition_delegate_.get());
980 976
981 const WebIntentPickerModel::InstalledService* service = 977 const WebIntentPickerModel::InstalledService* service =
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 views::ImageButton* close_button = new views::ImageButton(this); 1112 views::ImageButton* close_button = new views::ImageButton(this);
1117 close_button->SetImage(views::CustomButton::BS_NORMAL, 1113 close_button->SetImage(views::CustomButton::BS_NORMAL,
1118 rb.GetBitmapNamed(IDR_CLOSE_BAR)); 1114 rb.GetBitmapNamed(IDR_CLOSE_BAR));
1119 close_button->SetImage(views::CustomButton::BS_HOT, 1115 close_button->SetImage(views::CustomButton::BS_HOT,
1120 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); 1116 rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
1121 close_button->SetImage(views::CustomButton::BS_PUSHED, 1117 close_button->SetImage(views::CustomButton::BS_PUSHED,
1122 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); 1118 rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
1123 return close_button; 1119 return close_button;
1124 } 1120 }
1125 #endif 1121 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698