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

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

Issue 11414286: Remove unneeded TabContents::FromWebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years 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 | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | 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/timer.h" 10 #include "base/timer.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/download/download_util.h" 12 #include "chrome/browser/download/download_util.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 13 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_navigator.h" 15 #include "chrome/browser/ui/browser_navigator.h"
16 #include "chrome/browser/ui/constrained_window_constants.h" 16 #include "chrome/browser/ui/constrained_window_constants.h"
17 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" 17 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
18 #include "chrome/browser/ui/intents/web_intent_picker.h" 18 #include "chrome/browser/ui/intents/web_intent_picker.h"
19 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 19 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
20 #include "chrome/browser/ui/intents/web_intent_picker_model.h" 20 #include "chrome/browser/ui/intents/web_intent_picker_model.h"
21 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" 21 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
23 #include "chrome/browser/ui/views/constrained_window_views.h" 22 #include "chrome/browser/ui/views/constrained_window_views.h"
24 #include "chrome/browser/ui/views/frame/browser_view.h" 23 #include "chrome/browser/ui/views/frame/browser_view.h"
25 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 24 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
26 #include "chrome/browser/ui/views/toolbar_view.h" 25 #include "chrome/browser/ui/views/toolbar_view.h"
27 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
28 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_contents_view.h" 28 #include "content/public/browser/web_contents_view.h"
30 #include "grit/chromium_strings.h" 29 #include "grit/chromium_strings.h"
31 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
32 #include "grit/google_chrome_strings.h" 31 #include "grit/google_chrome_strings.h"
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // WebIntentPickerViews -------------------------------------------------------- 892 // WebIntentPickerViews --------------------------------------------------------
894 893
895 // Views implementation of WebIntentPicker. 894 // Views implementation of WebIntentPicker.
896 class WebIntentPickerViews : public views::ButtonListener, 895 class WebIntentPickerViews : public views::ButtonListener,
897 public views::WidgetDelegate, 896 public views::WidgetDelegate,
898 public views::LinkListener, 897 public views::LinkListener,
899 public WebIntentPicker, 898 public WebIntentPicker,
900 public WebIntentPickerModelObserver, 899 public WebIntentPickerModelObserver,
901 public IntentRowView::Delegate { 900 public IntentRowView::Delegate {
902 public: 901 public:
903 WebIntentPickerViews(TabContents* tab_contents, 902 WebIntentPickerViews(WebContents* web_contents,
904 WebIntentPickerDelegate* delegate, 903 WebIntentPickerDelegate* delegate,
905 WebIntentPickerModel* model); 904 WebIntentPickerModel* model);
906 virtual ~WebIntentPickerViews(); 905 virtual ~WebIntentPickerViews();
907 906
908 // views::ButtonListener implementation. 907 // views::ButtonListener implementation.
909 // This method is called when the user cancels the picker dialog. 908 // This method is called when the user cancels the picker dialog.
910 virtual void ButtonPressed(views::Button* sender, 909 virtual void ButtonPressed(views::Button* sender,
911 const ui::Event& event) OVERRIDE; 910 const ui::Event& event) OVERRIDE;
912 911
913 // views::WidgetDelegate implementation. 912 // views::WidgetDelegate implementation.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // Created locally, owned by Views. 1005 // Created locally, owned by Views.
1007 views::Label* action_label_; 1006 views::Label* action_label_;
1008 1007
1009 // A weak pointer to the intents view. 1008 // A weak pointer to the intents view.
1010 // Created locally, owned by Views view hierarchy. 1009 // Created locally, owned by Views view hierarchy.
1011 IntentsView* extensions_; 1010 IntentsView* extensions_;
1012 1011
1013 // Delegate for inline disposition tab contents. 1012 // Delegate for inline disposition tab contents.
1014 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_; 1013 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_;
1015 1014
1016 // A weak pointer to the TabContents this picker is in. 1015 // A weak pointer to the WebContents this picker is in.
1017 TabContents* tab_contents_; 1016 WebContents* web_contents_;
1018 1017
1019 // A weak pointer to the WebView that hosts the WebContents being displayed. 1018 // A weak pointer to the WebView that hosts the WebContents being displayed.
1020 // Created locally, owned by Views. 1019 // Created locally, owned by Views.
1021 views::WebView* webview_; 1020 views::WebView* webview_;
1022 1021
1023 // A weak pointer to the view that contains all other views in the picker. 1022 // A weak pointer to the view that contains all other views in the picker.
1024 // Created locally, owned by Views. 1023 // Created locally, owned by Views.
1025 views::View* contents_; 1024 views::View* contents_;
1026 1025
1027 // A weak pointer to the constrained window. 1026 // A weak pointer to the constrained window.
(...skipping 28 matching lines...) Expand all
1056 // Signals if the picker can be closed. False during extension install. 1055 // Signals if the picker can be closed. False during extension install.
1057 bool can_close_; 1056 bool can_close_;
1058 1057
1059 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews); 1058 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews);
1060 }; 1059 };
1061 1060
1062 // static 1061 // static
1063 WebIntentPicker* WebIntentPicker::Create(content::WebContents* web_contents, 1062 WebIntentPicker* WebIntentPicker::Create(content::WebContents* web_contents,
1064 WebIntentPickerDelegate* delegate, 1063 WebIntentPickerDelegate* delegate,
1065 WebIntentPickerModel* model) { 1064 WebIntentPickerModel* model) {
1066 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 1065 return new WebIntentPickerViews(web_contents, delegate, model);
1067 return new WebIntentPickerViews(tab_contents, delegate, model);
1068 } 1066 }
1069 1067
1070 WebIntentPickerViews::WebIntentPickerViews(TabContents* tab_contents, 1068 WebIntentPickerViews::WebIntentPickerViews(WebContents* web_contents,
1071 WebIntentPickerDelegate* delegate, 1069 WebIntentPickerDelegate* delegate,
1072 WebIntentPickerModel* model) 1070 WebIntentPickerModel* model)
1073 : state_(INITIAL), 1071 : state_(INITIAL),
1074 delegate_(delegate), 1072 delegate_(delegate),
1075 model_(model), 1073 model_(model),
1076 action_label_(NULL), 1074 action_label_(NULL),
1077 extensions_(NULL), 1075 extensions_(NULL),
1078 tab_contents_(tab_contents), 1076 web_contents_(web_contents),
1079 webview_(new views::WebView(tab_contents->profile())), 1077 webview_(new views::WebView(
1078 Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
1080 window_(NULL), 1079 window_(NULL),
1081 more_suggestions_link_(NULL), 1080 more_suggestions_link_(NULL),
1082 inline_service_icon_(NULL), 1081 inline_service_icon_(NULL),
1083 choose_another_service_link_(NULL), 1082 choose_another_service_link_(NULL),
1084 waiting_view_(NULL), 1083 waiting_view_(NULL),
1085 can_close_(true) { 1084 can_close_(true) {
1086 bool enable_chrome_style = true; 1085 bool enable_chrome_style = true;
1087 use_close_button_ = enable_chrome_style; 1086 use_close_button_ = enable_chrome_style;
1088 1087
1089 model_->set_observer(this); 1088 model_->set_observer(this);
1090 contents_ = new views::View(); 1089 contents_ = new views::View();
1091 contents_->set_background(views::Background::CreateSolidBackground( 1090 contents_->set_background(views::Background::CreateSolidBackground(
1092 ConstrainedWindow::GetBackgroundColor())); 1091 ConstrainedWindow::GetBackgroundColor()));
1093 1092
1094 // Show the dialog. 1093 // Show the dialog.
1095 window_ = new ConstrainedWindowViews(tab_contents->web_contents(), this, 1094 window_ = new ConstrainedWindowViews(web_contents, this,
1096 enable_chrome_style, 1095 enable_chrome_style,
1097 ConstrainedWindowViews::NO_INSETS); 1096 ConstrainedWindowViews::NO_INSETS);
1098 if (model_->IsInlineDisposition()) 1097 if (model_->IsInlineDisposition())
1099 OnInlineDisposition(string16(), model_->inline_disposition_url()); 1098 OnInlineDisposition(string16(), model_->inline_disposition_url());
1100 else 1099 else
1101 UpdateContents(); 1100 UpdateContents();
1102 } 1101 }
1103 1102
1104 WebIntentPickerViews::~WebIntentPickerViews() { 1103 WebIntentPickerViews::~WebIntentPickerViews() {
1105 model_->set_observer(NULL); 1104 model_->set_observer(NULL);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1366
1368 void WebIntentPickerViews::OnExtensionIconChanged( 1367 void WebIntentPickerViews::OnExtensionIconChanged(
1369 WebIntentPickerModel* model, 1368 WebIntentPickerModel* model,
1370 const std::string& extension_id) { 1369 const std::string& extension_id) {
1371 OnFaviconChanged(model, -1); 1370 OnFaviconChanged(model, -1);
1372 } 1371 }
1373 1372
1374 void WebIntentPickerViews::OnInlineDisposition( 1373 void WebIntentPickerViews::OnInlineDisposition(
1375 const string16&, const GURL& url) { 1374 const string16&, const GURL& url) {
1376 DCHECK(delegate_); 1375 DCHECK(delegate_);
1376 Profile* profile =
1377 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
1377 if (!webview_) 1378 if (!webview_)
1378 webview_ = new views::WebView(tab_contents_->profile()); 1379 webview_ = new views::WebView(profile);
1379 1380
1380 inline_web_contents_.reset(delegate_->CreateWebContentsForInlineDisposition( 1381 inline_web_contents_.reset(
1381 tab_contents_->profile(), url)); 1382 delegate_->CreateWebContentsForInlineDisposition(profile, url));
1382 1383
1383 // Does not take ownership, so we keep a scoped_ptr 1384 // Does not take ownership, so we keep a scoped_ptr
1384 // for the WebContents locally. 1385 // for the WebContents locally.
1385 webview_->SetWebContents(inline_web_contents_.get()); 1386 webview_->SetWebContents(inline_web_contents_.get());
1386 Browser* browser = chrome::FindBrowserWithWebContents( 1387 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
1387 tab_contents_->web_contents());
1388 inline_disposition_delegate_.reset( 1388 inline_disposition_delegate_.reset(
1389 new WebIntentInlineDispositionDelegate(this, inline_web_contents_.get(), 1389 new WebIntentInlineDispositionDelegate(this, inline_web_contents_.get(),
1390 browser)); 1390 browser));
1391 1391
1392 inline_web_contents_->GetController().LoadURL( 1392 inline_web_contents_->GetController().LoadURL(
1393 url, 1393 url,
1394 content::Referrer(), 1394 content::Referrer(),
1395 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 1395 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1396 std::string()); 1396 std::string());
1397 1397
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 if (inline_service) 1595 if (inline_service)
1596 inline_service_icon_->SetImage(inline_service->favicon.ToImageSkia()); 1596 inline_service_icon_->SetImage(inline_service->favicon.ToImageSkia());
1597 } 1597 }
1598 1598
1599 void WebIntentPickerViews::RefreshExtensions() { 1599 void WebIntentPickerViews::RefreshExtensions() {
1600 DCHECK(extensions_); 1600 DCHECK(extensions_);
1601 extensions_->Update(); 1601 extensions_->Update();
1602 contents_->Layout(); 1602 contents_->Layout();
1603 SizeToContents(); 1603 SizeToContents();
1604 } 1604 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698