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

Side by Side Diff: chrome/browser/extensions/tab_helper.cc

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: Created 3 years, 8 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 "chrome/browser/extensions/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/extensions/webstore_inline_installer.h" 26 #include "chrome/browser/extensions/webstore_inline_installer.h"
27 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" 27 #include "chrome/browser/extensions/webstore_inline_installer_factory.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/sessions/session_tab_helper.h" 29 #include "chrome/browser/sessions/session_tab_helper.h"
30 #include "chrome/browser/shell_integration.h" 30 #include "chrome/browser/shell_integration.h"
31 #include "chrome/browser/ui/browser_commands.h" 31 #include "chrome/browser/ui/browser_commands.h"
32 #include "chrome/browser/ui/browser_dialogs.h" 32 #include "chrome/browser/ui/browser_dialogs.h"
33 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
34 #include "chrome/browser/web_applications/web_app.h" 34 #include "chrome/browser/web_applications/web_app.h"
35 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h" 35 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
36 #include "chrome/common/extensions/chrome_extension_messages.h"
37 #include "chrome/common/extensions/extension_constants.h" 36 #include "chrome/common/extensions/extension_constants.h"
38 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 37 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
39 #include "chrome/common/render_messages.h" 38 #include "chrome/common/render_messages.h"
40 #include "chrome/common/url_constants.h" 39 #include "chrome/common/url_constants.h"
41 #include "content/public/browser/invalidate_type.h" 40 #include "content/public/browser/invalidate_type.h"
42 #include "content/public/browser/navigation_controller.h" 41 #include "content/public/browser/navigation_controller.h"
43 #include "content/public/browser/navigation_entry.h" 42 #include "content/public/browser/navigation_entry.h"
44 #include "content/public/browser/navigation_handle.h" 43 #include "content/public/browser/navigation_handle.h"
45 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/notification_source.h" 45 #include "content/public/browser/notification_source.h"
(...skipping 10 matching lines...) Expand all
57 #include "extensions/browser/extension_web_contents_observer.h" 56 #include "extensions/browser/extension_web_contents_observer.h"
58 #include "extensions/browser/image_loader.h" 57 #include "extensions/browser/image_loader.h"
59 #include "extensions/common/constants.h" 58 #include "extensions/common/constants.h"
60 #include "extensions/common/extension.h" 59 #include "extensions/common/extension.h"
61 #include "extensions/common/extension_icon_set.h" 60 #include "extensions/common/extension_icon_set.h"
62 #include "extensions/common/extension_messages.h" 61 #include "extensions/common/extension_messages.h"
63 #include "extensions/common/extension_resource.h" 62 #include "extensions/common/extension_resource.h"
64 #include "extensions/common/extension_urls.h" 63 #include "extensions/common/extension_urls.h"
65 #include "extensions/common/feature_switch.h" 64 #include "extensions/common/feature_switch.h"
66 #include "extensions/common/manifest_handlers/icons_handler.h" 65 #include "extensions/common/manifest_handlers/icons_handler.h"
66 #include "mojo/public/cpp/bindings/strong_binding.h"
67 #include "services/service_manager/public/cpp/interface_provider.h"
68 #include "services/service_manager/public/cpp/interface_registry.h"
67 #include "url/url_constants.h" 69 #include "url/url_constants.h"
68 70
69 #if defined(OS_WIN) 71 #if defined(OS_WIN)
70 #include "chrome/browser/web_applications/web_app_win.h" 72 #include "chrome/browser/web_applications/web_app_win.h"
71 #endif 73 #endif
72 74
73 using content::NavigationController; 75 using content::NavigationController;
74 using content::NavigationEntry; 76 using content::NavigationEntry;
75 using content::WebContents; 77 using content::WebContents;
76 78
77 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper); 79 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper);
78 80
79 namespace extensions { 81 namespace extensions {
80 82
81 // A helper class to watch the progress of inline installation and update the 83 // A helper class to watch the progress of inline installation and update the
82 // renderer. Owned by the TabHelper. 84 // renderer. Owned by the TabHelper.
83 class TabHelper::InlineInstallObserver : public InstallObserver { 85 class TabHelper::InlineInstallObserver : public InstallObserver {
84 public: 86 public:
85 InlineInstallObserver(TabHelper* tab_helper, 87 InlineInstallObserver(TabHelper* tab_helper,
86 content::BrowserContext* browser_context, 88 content::BrowserContext* browser_context,
87 int routing_id, 89 int routing_id,
88 const ExtensionId& extension_id, 90 const ExtensionId& extension_id,
89 bool observe_download_progress, 91 bool observe_download_progress,
90 bool observe_install_stage) 92 bool observe_install_stage)
91 : tab_helper_(tab_helper), 93 : tab_helper_(tab_helper),
92 routing_id_(routing_id),
93 extension_id_(extension_id), 94 extension_id_(extension_id),
94 observe_download_progress_(observe_download_progress), 95 observe_download_progress_(observe_download_progress),
95 observe_install_stage_(observe_install_stage), 96 observe_install_stage_(observe_install_stage),
96 install_observer_(this) { 97 install_observer_(this) {
97 DCHECK(tab_helper); 98 DCHECK(tab_helper);
98 DCHECK(observe_download_progress || observe_install_stage); 99 DCHECK(observe_download_progress || observe_install_stage);
99 InstallTracker* install_tracker = 100 InstallTracker* install_tracker =
100 InstallTrackerFactory::GetForBrowserContext(browser_context); 101 InstallTrackerFactory::GetForBrowserContext(browser_context);
101 if (install_tracker) 102 if (install_tracker)
102 install_observer_.Add(install_tracker); 103 install_observer_.Add(install_tracker);
103 } 104 }
104 ~InlineInstallObserver() override {} 105 ~InlineInstallObserver() override {}
105 106
106 private: 107 private:
107 // InstallObserver: 108 // InstallObserver:
108 void OnBeginExtensionDownload(const ExtensionId& extension_id) override { 109 void OnBeginExtensionDownload(const ExtensionId& extension_id) override {
109 SendInstallStageChangedMessage(extension_id, 110 SendInstallStageChangedMessage(extension_id,
110 api::webstore::INSTALL_STAGE_DOWNLOADING); 111 api::webstore::INSTALL_STAGE_DOWNLOADING);
111 } 112 }
112 void OnDownloadProgress(const ExtensionId& extension_id, 113 void OnDownloadProgress(const ExtensionId& extension_id,
113 int percent_downloaded) override { 114 int percent_downloaded) override {
114 if (observe_download_progress_ && extension_id == extension_id_) { 115 if (observe_download_progress_ && extension_id == extension_id_) {
115 tab_helper_->Send(new ExtensionMsg_InlineInstallDownloadProgress( 116 tab_helper_->inline_install_status_->InlineInstallDownloadProgress(
116 routing_id_, percent_downloaded)); 117 percent_downloaded);
117 } 118 }
118 } 119 }
119 void OnBeginCrxInstall(const ExtensionId& extension_id) override { 120 void OnBeginCrxInstall(const ExtensionId& extension_id) override {
120 SendInstallStageChangedMessage(extension_id, 121 SendInstallStageChangedMessage(extension_id,
121 api::webstore::INSTALL_STAGE_INSTALLING); 122 api::webstore::INSTALL_STAGE_INSTALLING);
122 } 123 }
123 void OnShutdown() override { install_observer_.RemoveAll(); } 124 void OnShutdown() override { install_observer_.RemoveAll(); }
124 125
125 void SendInstallStageChangedMessage(const ExtensionId& extension_id, 126 void SendInstallStageChangedMessage(const ExtensionId& extension_id,
126 api::webstore::InstallStage stage) { 127 api::webstore::InstallStage stage) {
127 if (observe_install_stage_ && extension_id == extension_id_) { 128 if (observe_install_stage_ && extension_id == extension_id_)
128 tab_helper_->Send( 129 tab_helper_->inline_install_status_->InlineInstallStageChanged(stage);
129 new ExtensionMsg_InlineInstallStageChanged(routing_id_, stage));
130 }
131 } 130 }
132 131
133 // The owning TabHelper (guaranteed to be valid). 132 // The owning TabHelper (guaranteed to be valid).
134 TabHelper* const tab_helper_; 133 TabHelper* const tab_helper_;
135 134
136 // The routing id to use in sending IPC updates.
137 int routing_id_;
138
139 // The id of the extension to observe. 135 // The id of the extension to observe.
140 ExtensionId extension_id_; 136 ExtensionId extension_id_;
141 137
142 // Whether or not to observe download/install progress. 138 // Whether or not to observe download/install progress.
143 const bool observe_download_progress_; 139 const bool observe_download_progress_;
144 const bool observe_install_stage_; 140 const bool observe_install_stage_;
145 141
146 ScopedObserver<InstallTracker, InstallObserver> install_observer_; 142 ScopedObserver<InstallTracker, InstallObserver> install_observer_;
147 143
148 DISALLOW_COPY_AND_ASSIGN(InlineInstallObserver); 144 DISALLOW_COPY_AND_ASSIGN(InlineInstallObserver);
149 }; 145 };
150 146
147 TabHelper::~TabHelper() {
148 RemoveScriptExecutionObserver(ActivityLog::GetInstance(profile_));
149 }
150
151 // static
152 void BindInlineInstallRequest(content::WebContents* web_contents,
153 mojom::InlineInstallRequest request) {
154 mojo::MakeStrongBinding(base::MakeUnique<TabHelper>(web_contents),
155 std::move(request));
Devlin 2017/03/31 14:18:39 This won't be quite right, I think. A TabHelper i
catmullings 2017/04/06 20:50:15 Done.
catmullings 2017/04/26 20:33:46 Just an FYI, the WebContentsFrameBindingSet is mea
156 }
157
151 TabHelper::TabHelper(content::WebContents* web_contents) 158 TabHelper::TabHelper(content::WebContents* web_contents)
152 : content::WebContentsObserver(web_contents), 159 : content::WebContentsObserver(web_contents),
153 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 160 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
154 extension_app_(NULL), 161 extension_app_(NULL),
155 pending_web_app_action_(NONE), 162 pending_web_app_action_(NONE),
156 last_committed_nav_entry_unique_id_(0), 163 last_committed_nav_entry_unique_id_(0),
157 update_shortcut_on_load_complete_(false), 164 update_shortcut_on_load_complete_(false),
158 script_executor_( 165 script_executor_(
159 new ScriptExecutor(web_contents, &script_execution_observers_)), 166 new ScriptExecutor(web_contents, &script_execution_observers_)),
160 location_bar_controller_(new LocationBarController(web_contents)), 167 location_bar_controller_(new LocationBarController(web_contents)),
(...skipping 24 matching lines...) Expand all
185 ChromeExtensionWebContentsObserver::CreateForWebContents(web_contents); 192 ChromeExtensionWebContentsObserver::CreateForWebContents(web_contents);
186 ExtensionWebContentsObserver::GetForWebContents(web_contents)->dispatcher()-> 193 ExtensionWebContentsObserver::GetForWebContents(web_contents)->dispatcher()->
187 set_delegate(this); 194 set_delegate(this);
188 195
189 BookmarkManagerPrivateDragEventRouter::CreateForWebContents(web_contents); 196 BookmarkManagerPrivateDragEventRouter::CreateForWebContents(web_contents);
190 197
191 registrar_.Add(this, 198 registrar_.Add(this,
192 content::NOTIFICATION_LOAD_STOP, 199 content::NOTIFICATION_LOAD_STOP,
193 content::Source<NavigationController>( 200 content::Source<NavigationController>(
194 &web_contents->GetController())); 201 &web_contents->GetController()));
195 }
196 202
197 TabHelper::~TabHelper() { 203 content::RenderFrameHost* host = web_contents->GetMainFrame();
198 RemoveScriptExecutionObserver(ActivityLog::GetInstance(profile_)); 204 if (host) {
205 host->GetRemoteInterfaces()->GetInterface(&inline_install_status_);
206
207 host->GetInterfaceRegistry()->AddInterface(
208 base::Bind(&TabHelper::BindInlineInstallRequest, web_contents));
catmullings 2017/03/31 00:08:21 This line is causing a linker error: error: undef
Devlin 2017/03/31 14:18:39 This error is because BindInlineInstallRequest is
catmullings 2017/04/06 20:50:15 That makes sense. Thanks! I assume that WebConten
209 }
199 } 210 }
200 211
201 void TabHelper::CreateApplicationShortcuts() { 212 void TabHelper::CreateApplicationShortcuts() {
202 DCHECK(CanCreateApplicationShortcuts()); 213 DCHECK(CanCreateApplicationShortcuts());
203 if (pending_web_app_action_ != NONE) 214 if (pending_web_app_action_ != NONE)
204 return; 215 return;
205 216
206 // Start fetching web app info for CreateApplicationShortcut dialog and show 217 // Start fetching web app info for CreateApplicationShortcut dialog and show
207 // the dialog when the data is available in OnDidGetApplicationInfo. 218 // the dialog when the data is available in OnDidGetApplicationInfo.
208 GetApplicationInfo(CREATE_SHORTCUT); 219 GetApplicationInfo(CREATE_SHORTCUT);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 OnDidGetWebApplicationInfo) 370 OnDidGetWebApplicationInfo)
360 IPC_MESSAGE_UNHANDLED(handled = false) 371 IPC_MESSAGE_UNHANDLED(handled = false)
361 IPC_END_MESSAGE_MAP() 372 IPC_END_MESSAGE_MAP()
362 return handled; 373 return handled;
363 } 374 }
364 375
365 bool TabHelper::OnMessageReceived(const IPC::Message& message, 376 bool TabHelper::OnMessageReceived(const IPC::Message& message,
366 content::RenderFrameHost* render_frame_host) { 377 content::RenderFrameHost* render_frame_host) {
367 bool handled = true; 378 bool handled = true;
368 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(TabHelper, message, render_frame_host) 379 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(TabHelper, message, render_frame_host)
369 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall,
370 OnInlineWebstoreInstall)
371 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, 380 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState,
372 OnGetAppInstallState) 381 OnGetAppInstallState)
373 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting, 382 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting,
374 OnContentScriptsExecuting) 383 OnContentScriptsExecuting)
375 IPC_MESSAGE_UNHANDLED(handled = false) 384 IPC_MESSAGE_UNHANDLED(handled = false)
376 IPC_END_MESSAGE_MAP() 385 IPC_END_MESSAGE_MAP()
377 return handled; 386 return handled;
378 } 387 }
379 388
380 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents, 389 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents,
381 WebContents* new_web_contents) { 390 WebContents* new_web_contents) {
382 // When the WebContents that this is attached to is cloned, give the new clone 391 // When the WebContents that this is attached to is cloned, give the new clone
383 // a TabHelper and copy state over. 392 // a TabHelper and copy state over.
384 CreateForWebContents(new_web_contents); 393 CreateForWebContents(new_web_contents);
385 TabHelper* new_helper = FromWebContents(new_web_contents); 394 TabHelper* new_helper = FromWebContents(new_web_contents);
386 395
387 new_helper->SetExtensionApp(extension_app()); 396 new_helper->SetExtensionApp(extension_app());
388 new_helper->extension_app_icon_ = extension_app_icon_; 397 new_helper->extension_app_icon_ = extension_app_icon_;
389 } 398 }
390 399
391 void TabHelper::OnDidGetWebApplicationInfo(const WebApplicationInfo& info) { 400 void TabHelper::InlineWebstoreInstall(int install_id,
392 web_app_info_ = info; 401 int return_route_id,
393 402 const std::string& webstore_item_id,
394 NavigationEntry* entry = 403 int listeners_mask) {
395 web_contents()->GetController().GetLastCommittedEntry(); 404 content::RenderFrameHost* host = web_contents()->GetMainFrame();
396 if (!entry || last_committed_nav_entry_unique_id_ != entry->GetUniqueID())
397 return;
398 last_committed_nav_entry_unique_id_ = 0;
399
400 switch (pending_web_app_action_) {
401 #if !defined(OS_MACOSX)
402 case CREATE_SHORTCUT: {
403 chrome::ShowCreateWebAppShortcutsDialog(
404 web_contents()->GetTopLevelNativeWindow(),
405 web_contents());
406 break;
407 }
408 #endif
409 case CREATE_HOSTED_APP: {
410 if (web_app_info_.app_url.is_empty())
411 web_app_info_.app_url = web_contents()->GetURL();
412
413 if (web_app_info_.title.empty())
414 web_app_info_.title = web_contents()->GetTitle();
415 if (web_app_info_.title.empty())
416 web_app_info_.title = base::UTF8ToUTF16(web_app_info_.app_url.spec());
417
418 bookmark_app_helper_.reset(
419 new BookmarkAppHelper(profile_, web_app_info_, web_contents()));
420 bookmark_app_helper_->Create(base::Bind(
421 &TabHelper::FinishCreateBookmarkApp, weak_ptr_factory_.GetWeakPtr()));
422 break;
423 }
424 case UPDATE_SHORTCUT: {
425 web_app::UpdateShortcutForTabContents(web_contents());
426 break;
427 }
428 default:
429 NOTREACHED();
430 break;
431 }
432
433 // The hosted app action will be cleared once the installation completes or
434 // fails.
435 if (pending_web_app_action_ != CREATE_HOSTED_APP)
436 pending_web_app_action_ = NONE;
437 }
438
439 void TabHelper::OnInlineWebstoreInstall(content::RenderFrameHost* host,
catmullings 2017/03/31 00:08:21 Note that the original definition of OnInlineWebst
440 int install_id,
441 int return_route_id,
442 const std::string& webstore_item_id,
443 int listeners_mask) {
444 GURL requestor_url(host->GetLastCommittedURL()); 405 GURL requestor_url(host->GetLastCommittedURL());
445 // Check that the listener is reasonable. We should never get anything other 406 // Check that the listener is reasonable. We should never get anything other
446 // than an install stage listener, a download listener, or both. 407 // than an install stage listener, a download listener, or both.
447 // The requestor_url should also be valid, and the renderer should disallow 408 // The requestor_url should also be valid, and the renderer should disallow
448 // child frames from sending the IPC. 409 // child frames from sending the IPC.
449 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER | 410 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER |
450 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0 || 411 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0 ||
451 !requestor_url.is_valid() || requestor_url == url::kAboutBlankURL || 412 !requestor_url.is_valid() || requestor_url == url::kAboutBlankURL ||
452 host->GetParent()) { 413 host->GetParent()) {
453 NOTREACHED(); 414 NOTREACHED();
454 return; 415 return;
455 } 416 }
456 417
457 if (pending_inline_installations_.count(webstore_item_id) != 0) { 418 if (pending_inline_installations_.count(webstore_item_id) != 0) {
458 Send(new ExtensionMsg_InlineWebstoreInstallResponse( 419 inline_install_status_->InlineWebstoreInstallResponse(
Devlin 2017/03/31 14:18:39 note: see also comment in mojom file.
catmullings 2017/04/06 20:50:15 Done.
459 return_route_id, install_id, false, 420 install_id, false, webstore_install::kInstallInProgressError,
460 webstore_install::kInstallInProgressError, 421 webstore_install::INSTALL_IN_PROGRESS);
461 webstore_install::INSTALL_IN_PROGRESS));
462 return; 422 return;
463 } 423 }
464 424
465 pending_inline_installations_.insert(webstore_item_id); 425 pending_inline_installations_.insert(webstore_item_id);
466 // Inform the Webstore API that an inline install is happening, in case the 426 // Inform the Webstore API that an inline install is happening, in case the
467 // page requested status updates. 427 // page requested status updates.
468 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); 428 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
469 if (registry->disabled_extensions().Contains(webstore_item_id) && 429 if (registry->disabled_extensions().Contains(webstore_item_id) &&
470 (ExtensionPrefs::Get(profile_)->GetDisableReasons(webstore_item_id) & 430 (ExtensionPrefs::Get(profile_)->GetDisableReasons(webstore_item_id) &
471 Extension::DISABLE_PERMISSIONS_INCREASE) != 0) { 431 Extension::DISABLE_PERMISSIONS_INCREASE) != 0) {
(...skipping 28 matching lines...) Expand all
500 WebstoreStandaloneInstaller::Callback callback = base::Bind( 460 WebstoreStandaloneInstaller::Callback callback = base::Bind(
501 &TabHelper::OnInlineInstallComplete, weak_ptr_factory_.GetWeakPtr(), 461 &TabHelper::OnInlineInstallComplete, weak_ptr_factory_.GetWeakPtr(),
502 install_id, return_route_id, webstore_item_id); 462 install_id, return_route_id, webstore_item_id);
503 scoped_refptr<WebstoreInlineInstaller> installer( 463 scoped_refptr<WebstoreInlineInstaller> installer(
504 webstore_inline_installer_factory_->CreateInstaller( 464 webstore_inline_installer_factory_->CreateInstaller(
505 web_contents(), host, webstore_item_id, requestor_url, callback)); 465 web_contents(), host, webstore_item_id, requestor_url, callback));
506 installer->BeginInstall(); 466 installer->BeginInstall();
507 } 467 }
508 } 468 }
509 469
470 void TabHelper::OnDidGetWebApplicationInfo(const WebApplicationInfo& info) {
Devlin 2017/03/31 14:18:39 Is there a reason to move this method? If not, we
catmullings 2017/04/06 20:50:15 Done.
471 web_app_info_ = info;
472
473 NavigationEntry* entry =
474 web_contents()->GetController().GetLastCommittedEntry();
475 if (!entry || last_committed_nav_entry_unique_id_ != entry->GetUniqueID())
476 return;
477 last_committed_nav_entry_unique_id_ = 0;
478
479 switch (pending_web_app_action_) {
480 #if !defined(OS_MACOSX)
481 case CREATE_SHORTCUT: {
482 chrome::ShowCreateWebAppShortcutsDialog(
483 web_contents()->GetTopLevelNativeWindow(), web_contents());
484 break;
485 }
486 #endif
487 case CREATE_HOSTED_APP: {
488 if (web_app_info_.app_url.is_empty())
489 web_app_info_.app_url = web_contents()->GetURL();
490
491 if (web_app_info_.title.empty())
492 web_app_info_.title = web_contents()->GetTitle();
493 if (web_app_info_.title.empty())
494 web_app_info_.title = base::UTF8ToUTF16(web_app_info_.app_url.spec());
495
496 bookmark_app_helper_.reset(
497 new BookmarkAppHelper(profile_, web_app_info_, web_contents()));
498 bookmark_app_helper_->Create(base::Bind(
499 &TabHelper::FinishCreateBookmarkApp, weak_ptr_factory_.GetWeakPtr()));
500 break;
501 }
502 case UPDATE_SHORTCUT: {
503 web_app::UpdateShortcutForTabContents(web_contents());
504 break;
505 }
506 default:
507 NOTREACHED();
508 break;
509 }
510
511 // The hosted app action will be cleared once the installation completes or
512 // fails.
513 if (pending_web_app_action_ != CREATE_HOSTED_APP)
514 pending_web_app_action_ = NONE;
515 }
516
510 void TabHelper::OnGetAppInstallState(content::RenderFrameHost* host, 517 void TabHelper::OnGetAppInstallState(content::RenderFrameHost* host,
511 const GURL& requestor_url, 518 const GURL& requestor_url,
512 int return_route_id, 519 int return_route_id,
513 int callback_id) { 520 int callback_id) {
514 ExtensionRegistry* registry = 521 ExtensionRegistry* registry =
515 ExtensionRegistry::Get(web_contents()->GetBrowserContext()); 522 ExtensionRegistry::Get(web_contents()->GetBrowserContext());
516 const ExtensionSet& extensions = registry->enabled_extensions(); 523 const ExtensionSet& extensions = registry->enabled_extensions();
517 const ExtensionSet& disabled_extensions = registry->disabled_extensions(); 524 const ExtensionSet& disabled_extensions = registry->disabled_extensions();
518 525
519 std::string state; 526 std::string state;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 630
624 void TabHelper::OnInlineInstallComplete(int install_id, 631 void TabHelper::OnInlineInstallComplete(int install_id,
625 int return_route_id, 632 int return_route_id,
626 const ExtensionId& extension_id, 633 const ExtensionId& extension_id,
627 bool success, 634 bool success,
628 const std::string& error, 635 const std::string& error,
629 webstore_install::Result result) { 636 webstore_install::Result result) {
630 DCHECK_EQ(1u, pending_inline_installations_.count(extension_id)); 637 DCHECK_EQ(1u, pending_inline_installations_.count(extension_id));
631 pending_inline_installations_.erase(extension_id); 638 pending_inline_installations_.erase(extension_id);
632 install_observers_.erase(extension_id); 639 install_observers_.erase(extension_id);
633 Send(new ExtensionMsg_InlineWebstoreInstallResponse( 640 inline_install_status_->InlineWebstoreInstallResponse(
634 return_route_id, 641 install_id, success, success ? std::string() : error, result);
635 install_id,
636 success,
637 success ? std::string() : error,
638 result));
639 } 642 }
640 643
641 WebContents* TabHelper::GetAssociatedWebContents() const { 644 WebContents* TabHelper::GetAssociatedWebContents() const {
642 return web_contents(); 645 return web_contents();
643 } 646 }
644 647
645 void TabHelper::OnExtensionUnloaded( 648 void TabHelper::OnExtensionUnloaded(
646 content::BrowserContext* browser_context, 649 content::BrowserContext* browser_context,
647 const Extension* extension, 650 const Extension* extension,
648 UnloadedExtensionInfo::Reason reason) { 651 UnloadedExtensionInfo::Reason reason) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 685 }
683 } 686 }
684 687
685 void TabHelper::SetTabId(content::RenderFrameHost* render_frame_host) { 688 void TabHelper::SetTabId(content::RenderFrameHost* render_frame_host) {
686 render_frame_host->Send( 689 render_frame_host->Send(
687 new ExtensionMsg_SetTabId(render_frame_host->GetRoutingID(), 690 new ExtensionMsg_SetTabId(render_frame_host->GetRoutingID(),
688 SessionTabHelper::IdForTab(web_contents()))); 691 SessionTabHelper::IdForTab(web_contents())));
689 } 692 }
690 693
691 } // namespace extensions 694 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698