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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller.cc

Issue 10796116: [Web Intents] Basic location bar UI for window disposition picker affordance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor content settings to PageTool base class. Add stubs for mac/win. 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
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/intents/web_intent_picker_controller.h" 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } // namespace 140 } // namespace
141 141
142 WebIntentPickerController::WebIntentPickerController( 142 WebIntentPickerController::WebIntentPickerController(
143 TabContents* tab_contents) 143 TabContents* tab_contents)
144 : tab_contents_(tab_contents), 144 : tab_contents_(tab_contents),
145 picker_(NULL), 145 picker_(NULL),
146 picker_model_(new WebIntentPickerModel()), 146 picker_model_(new WebIntentPickerModel()),
147 pending_async_count_(0), 147 pending_async_count_(0),
148 pending_registry_calls_count_(0), 148 pending_registry_calls_count_(0),
149 picker_shown_(false), 149 picker_shown_(false),
150 window_disposition_target_(false),
150 intents_dispatcher_(NULL), 151 intents_dispatcher_(NULL),
151 service_tab_(NULL), 152 service_tab_(NULL),
152 weak_ptr_factory_(this) { 153 weak_ptr_factory_(this) {
153 content::NavigationController* controller = 154 content::NavigationController* controller =
154 &tab_contents->web_contents()->GetController(); 155 &tab_contents->web_contents()->GetController();
155 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 156 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
156 content::Source<content::NavigationController>(controller)); 157 content::Source<content::NavigationController>(controller));
157 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, 158 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
158 content::Source<content::NavigationController>(controller)); 159 content::Source<content::NavigationController>(controller));
159 } 160 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 GetWebIntentsRegistry(tab_contents_)->GetDefaultIntentService( 241 GetWebIntentsRegistry(tab_contents_)->GetDefaultIntentService(
241 action, type, invoking_url, 242 action, type, invoking_url,
242 base::Bind(&WebIntentPickerController::OnWebIntentDefaultsAvailable, 243 base::Bind(&WebIntentPickerController::OnWebIntentDefaultsAvailable,
243 weak_ptr_factory_.GetWeakPtr())); 244 weak_ptr_factory_.GetWeakPtr()));
244 } 245 }
245 246
246 GetCWSIntentsRegistry(tab_contents_)->GetIntentServices( 247 GetCWSIntentsRegistry(tab_contents_)->GetIntentServices(
247 action, type, 248 action, type,
248 base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable, 249 base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable,
249 weak_ptr_factory_.GetWeakPtr())); 250 weak_ptr_factory_.GetWeakPtr()));
250 } 251 }
251 252
252 void WebIntentPickerController::Observe( 253 void WebIntentPickerController::Observe(
253 int type, 254 int type,
254 const content::NotificationSource& source, 255 const content::NotificationSource& source,
255 const content::NotificationDetails& details) { 256 const content::NotificationDetails& details) {
256 DCHECK(type == content::NOTIFICATION_LOAD_START || 257 DCHECK(type == content::NOTIFICATION_LOAD_START ||
257 type == chrome::NOTIFICATION_TAB_CLOSING); 258 type == chrome::NOTIFICATION_TAB_CLOSING);
258 ClosePicker(); 259 ClosePicker();
259 } 260 }
260 261
(...skipping 23 matching lines...) Expand all
284 285
285 case WebIntentPickerModel::DISPOSITION_WINDOW: { 286 case WebIntentPickerModel::DISPOSITION_WINDOW: {
286 Browser* browser = browser::FindBrowserWithWebContents( 287 Browser* browser = browser::FindBrowserWithWebContents(
287 tab_contents_->web_contents()); 288 tab_contents_->web_contents());
288 TabContents* contents = chrome::TabContentsFactory( 289 TabContents* contents = chrome::TabContentsFactory(
289 tab_contents_->profile(), 290 tab_contents_->profile(),
290 tab_util::GetSiteInstanceForNewTab( 291 tab_util::GetSiteInstanceForNewTab(
291 tab_contents_->profile(), url), 292 tab_contents_->profile(), url),
292 MSG_ROUTING_NONE, NULL, NULL); 293 MSG_ROUTING_NONE, NULL, NULL);
293 294
295 // Let the controller for the target TabContents know that it is hosting a
296 // web intents service.
297 contents->web_intent_picker_controller()->set_window_disposition_target(
298 true);
299
294 intents_dispatcher_->DispatchIntent(contents->web_contents()); 300 intents_dispatcher_->DispatchIntent(contents->web_contents());
295 service_tab_ = contents->web_contents(); 301 service_tab_ = contents->web_contents();
296 302
297 // This call performs all the tab strip manipulation, notifications, etc. 303 // This call performs all the tab strip manipulation, notifications, etc.
298 // Since we're passing in a target_contents, it assumes that we will 304 // Since we're passing in a target_contents, it assumes that we will
299 // navigate the page ourselves, though. 305 // navigate the page ourselves, though.
300 chrome::NavigateParams params(browser, url, 306 chrome::NavigateParams params(browser, url,
301 content::PAGE_TRANSITION_AUTO_BOOKMARK); 307 content::PAGE_TRANSITION_AUTO_BOOKMARK);
302 params.target_contents = contents; 308 params.target_contents = contents;
303 params.disposition = NEW_FOREGROUND_TAB; 309 params.disposition = NEW_FOREGROUND_TAB;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 const gfx::Image& icon_image) { 680 const gfx::Image& icon_image) {
675 picker_model_->SetSuggestedExtensionIconWithId(extension_id, icon_image); 681 picker_model_->SetSuggestedExtensionIconWithId(extension_id, icon_image);
676 AsyncOperationFinished(); 682 AsyncOperationFinished();
677 } 683 }
678 684
679 void WebIntentPickerController::OnExtensionIconUnavailable( 685 void WebIntentPickerController::OnExtensionIconUnavailable(
680 const string16& extension_id) { 686 const string16& extension_id) {
681 AsyncOperationFinished(); 687 AsyncOperationFinished();
682 } 688 }
683 689
690 bool WebIntentPickerController::ShowLocationBarPickerTool() {
691 return window_disposition_target_;
692 }
693
684 void WebIntentPickerController::OnExtensionInstallServiceAvailable( 694 void WebIntentPickerController::OnExtensionInstallServiceAvailable(
685 const std::vector<webkit_glue::WebIntentServiceData>& services) { 695 const std::vector<webkit_glue::WebIntentServiceData>& services) {
686 DCHECK(services.size() > 0); 696 DCHECK(services.size() > 0);
687 697
688 // TODO(binji): We're going to need to disambiguate if there are multiple 698 // TODO(binji): We're going to need to disambiguate if there are multiple
689 // services. For now, just choose the first. 699 // services. For now, just choose the first.
690 const webkit_glue::WebIntentServiceData& service_data = services[0]; 700 const webkit_glue::WebIntentServiceData& service_data = services[0];
691 picker_model_->AddInstalledService( 701 picker_model_->AddInstalledService(
692 service_data.title, service_data.service_url, 702 service_data.title, service_data.service_url,
693 ConvertDisposition(service_data.disposition)); 703 ConvertDisposition(service_data.disposition));
(...skipping 15 matching lines...) Expand all
709 // If picker is non-NULL, it was set by a test. 719 // If picker is non-NULL, it was set by a test.
710 if (picker_ == NULL) 720 if (picker_ == NULL)
711 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); 721 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get());
712 picker_shown_ = true; 722 picker_shown_ = true;
713 } 723 }
714 724
715 void WebIntentPickerController::ClosePicker() { 725 void WebIntentPickerController::ClosePicker() {
716 if (picker_) 726 if (picker_)
717 picker_->Close(); 727 picker_->Close();
718 } 728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698