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

Side by Side Diff: chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm

Issue 9649020: [Web Intents] WebIntentPickerModel uses URL instead of index to reference registered services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac fix Created 8 years, 9 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/cocoa/web_intent_picker_cocoa.h" 5 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // We don't handle individual icon changes - just redo the whole model. 145 // We don't handle individual icon changes - just redo the whole model.
146 PerformLayout(); 146 PerformLayout();
147 } 147 }
148 148
149 void WebIntentPickerCocoa::OnExtensionIconChanged( 149 void WebIntentPickerCocoa::OnExtensionIconChanged(
150 WebIntentPickerModel* model, 150 WebIntentPickerModel* model,
151 const string16& extension_id) { 151 const string16& extension_id) {
152 // TODO(binji): implement. 152 // TODO(binji): implement.
153 } 153 }
154 154
155 void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model) { 155 void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model,
156 const GURL& url) {
156 DCHECK(browser_); 157 DCHECK(browser_);
157 const WebIntentPickerModel::InstalledService& installed_service =
158 model->GetInstalledServiceAt(model->inline_disposition_index());
159
160 content::WebContents* web_contents = content::WebContents::Create( 158 content::WebContents* web_contents = content::WebContents::Create(
161 browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); 159 browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
162 inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents)); 160 inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents));
163 inline_disposition_delegate_.reset(new WebIntentInlineDispositionDelegate); 161 inline_disposition_delegate_.reset(new WebIntentInlineDispositionDelegate);
164 web_contents->SetDelegate(inline_disposition_delegate_.get()); 162 web_contents->SetDelegate(inline_disposition_delegate_.get());
165 163
166 // Must call this immediately after WebContents creation to avoid race 164 // Must call this immediately after WebContents creation to avoid race
167 // with load. 165 // with load.
168 delegate_->OnInlineDispositionWebContentsCreated(web_contents); 166 delegate_->OnInlineDispositionWebContentsCreated(web_contents);
169 167
170 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL( 168 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL(
171 installed_service.url, 169 url,
172 content::Referrer(), 170 content::Referrer(),
173 content::PAGE_TRANSITION_START_PAGE, 171 content::PAGE_TRANSITION_START_PAGE,
174 std::string()); 172 std::string());
175 173
176 [sheet_controller_ setInlineDispositionTabContents: 174 [sheet_controller_ setInlineDispositionTabContents:
177 inline_disposition_tab_contents_.get()]; 175 inline_disposition_tab_contents_.get()];
178 PerformLayout(); 176 PerformLayout();
179 } 177 }
180 178
181 void WebIntentPickerCocoa::OnCancelled() { 179 void WebIntentPickerCocoa::OnCancelled() {
182 DCHECK(delegate_); 180 DCHECK(delegate_);
183 if (!service_invoked) 181 if (!service_invoked)
184 delegate_->OnCancelled(); 182 delegate_->OnCancelled();
185 delegate_->OnClosing(); 183 delegate_->OnClosing();
186 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 184 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
187 } 185 }
188 186
189 void WebIntentPickerCocoa::OnServiceChosen(size_t index) { 187 void WebIntentPickerCocoa::OnServiceChosen(size_t index) {
190 DCHECK(delegate_); 188 DCHECK(delegate_);
191 const WebIntentPickerModel::InstalledService& installed_service = 189 const WebIntentPickerModel::InstalledService& installed_service =
192 model_->GetInstalledServiceAt(index); 190 model_->GetInstalledServiceAt(index);
193 service_invoked = true; 191 service_invoked = true;
194 delegate_->OnServiceChosen(index, installed_service.disposition); 192 delegate_->OnServiceChosen(installed_service.url,
193 installed_service.disposition);
195 } 194 }
196 195
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_picker_cocoa.h ('k') | chrome/browser/ui/cocoa/web_intent_sheet_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698