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

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

Issue 899443002: Create bookmark apps at the end of the process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 5 years, 10 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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/active_script_controller.h" 11 #include "chrome/browser/extensions/active_script_controller.h"
12 #include "chrome/browser/extensions/activity_log/activity_log.h" 12 #include "chrome/browser/extensions/activity_log/activity_log.h"
13 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules _registry.h" 13 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules _registry.h"
14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
15 #include "chrome/browser/extensions/api/webstore/webstore_api.h" 15 #include "chrome/browser/extensions/api/webstore/webstore_api.h"
16 #include "chrome/browser/extensions/bookmark_app_helper.h" 16 #include "chrome/browser/extensions/bookmark_app_helper.h"
17 #include "chrome/browser/extensions/error_console/error_console.h" 17 #include "chrome/browser/extensions/error_console/error_console.h"
18 #include "chrome/browser/extensions/extension_tab_util.h" 18 #include "chrome/browser/extensions/extension_tab_util.h"
19 #include "chrome/browser/extensions/extension_util.h" 19 #include "chrome/browser/extensions/extension_util.h"
20 #include "chrome/browser/extensions/location_bar_controller.h" 20 #include "chrome/browser/extensions/location_bar_controller.h"
21 #include "chrome/browser/extensions/webstore_inline_installer.h" 21 #include "chrome/browser/extensions/webstore_inline_installer.h"
22 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" 22 #include "chrome/browser/extensions/webstore_inline_installer_factory.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sessions/session_tab_helper.h" 24 #include "chrome/browser/sessions/session_tab_helper.h"
25 #include "chrome/browser/shell_integration.h" 25 #include "chrome/browser/shell_integration.h"
26 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_dialogs.h" 27 #include "chrome/browser/ui/browser_dialogs.h"
28 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_window.h"
30 #include "chrome/browser/ui/host_desktop.h" 29 #include "chrome/browser/ui/host_desktop.h"
31 #include "chrome/browser/web_applications/web_app.h" 30 #include "chrome/browser/web_applications/web_app.h"
32 #include "chrome/common/extensions/chrome_extension_messages.h" 31 #include "chrome/common/extensions/chrome_extension_messages.h"
33 #include "chrome/common/extensions/extension_constants.h" 32 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 33 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
35 #include "chrome/common/render_messages.h" 34 #include "chrome/common/render_messages.h"
36 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
37 #include "content/public/browser/invalidate_type.h" 36 #include "content/public/browser/invalidate_type.h"
38 #include "content/public/browser/navigation_controller.h" 37 #include "content/public/browser/navigation_controller.h"
39 #include "content/public/browser/navigation_details.h" 38 #include "content/public/browser/navigation_details.h"
(...skipping 13 matching lines...) Expand all
53 #include "extensions/browser/image_loader.h" 52 #include "extensions/browser/image_loader.h"
54 #include "extensions/common/constants.h" 53 #include "extensions/common/constants.h"
55 #include "extensions/common/extension.h" 54 #include "extensions/common/extension.h"
56 #include "extensions/common/extension_icon_set.h" 55 #include "extensions/common/extension_icon_set.h"
57 #include "extensions/common/extension_messages.h" 56 #include "extensions/common/extension_messages.h"
58 #include "extensions/common/extension_resource.h" 57 #include "extensions/common/extension_resource.h"
59 #include "extensions/common/extension_urls.h" 58 #include "extensions/common/extension_urls.h"
60 #include "extensions/common/feature_switch.h" 59 #include "extensions/common/feature_switch.h"
61 #include "extensions/common/manifest_handlers/icons_handler.h" 60 #include "extensions/common/manifest_handlers/icons_handler.h"
62 61
63 #if defined(OS_CHROMEOS)
64 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
65 #endif
66
67 #if defined(OS_WIN) 62 #if defined(OS_WIN)
68 #include "chrome/browser/web_applications/web_app_win.h" 63 #include "chrome/browser/web_applications/web_app_win.h"
69 #endif 64 #endif
70 65
71 using content::NavigationController; 66 using content::NavigationController;
72 using content::NavigationEntry; 67 using content::NavigationEntry;
73 using content::RenderViewHost; 68 using content::RenderViewHost;
74 using content::WebContents; 69 using content::WebContents;
75 70
76 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper); 71 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (extension_app_icon_.empty()) 186 if (extension_app_icon_.empty())
192 return NULL; 187 return NULL;
193 188
194 return &extension_app_icon_; 189 return &extension_app_icon_;
195 } 190 }
196 191
197 void TabHelper::FinishCreateBookmarkApp( 192 void TabHelper::FinishCreateBookmarkApp(
198 const Extension* extension, 193 const Extension* extension,
199 const WebApplicationInfo& web_app_info) { 194 const WebApplicationInfo& web_app_info) {
200 pending_web_app_action_ = NONE; 195 pending_web_app_action_ = NONE;
201
202 // There was an error with downloading the icons or installing the app.
203 if (!extension)
204 return;
205
206 #if defined(OS_CHROMEOS)
207 ChromeLauncherController::instance()->PinAppWithID(extension->id());
208 #endif
209
210 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
211 if (browser) {
212 browser->window()->ShowBookmarkAppBubble(web_app_info, extension->id());
213 }
214 } 196 }
215 197
216 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { 198 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) {
217 SetTabId(render_view_host); 199 SetTabId(render_view_host);
218 } 200 }
219 201
220 void TabHelper::DidNavigateMainFrame( 202 void TabHelper::DidNavigateMainFrame(
221 const content::LoadCommittedDetails& details, 203 const content::LoadCommittedDetails& details,
222 const content::FrameNavigateParams& params) { 204 const content::FrameNavigateParams& params) {
223 if (ExtensionSystem::Get(profile_)->extension_service() && 205 if (ExtensionSystem::Get(profile_)->extension_service() &&
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 #endif 294 #endif
313 case CREATE_HOSTED_APP: { 295 case CREATE_HOSTED_APP: {
314 if (web_app_info_.app_url.is_empty()) 296 if (web_app_info_.app_url.is_empty())
315 web_app_info_.app_url = web_contents()->GetURL(); 297 web_app_info_.app_url = web_contents()->GetURL();
316 298
317 if (web_app_info_.title.empty()) 299 if (web_app_info_.title.empty())
318 web_app_info_.title = web_contents()->GetTitle(); 300 web_app_info_.title = web_contents()->GetTitle();
319 if (web_app_info_.title.empty()) 301 if (web_app_info_.title.empty())
320 web_app_info_.title = base::UTF8ToUTF16(web_app_info_.app_url.spec()); 302 web_app_info_.title = base::UTF8ToUTF16(web_app_info_.app_url.spec());
321 303
322 bookmark_app_helper_.reset(new BookmarkAppHelper( 304 bookmark_app_helper_.reset(
323 ExtensionSystem::Get(profile_)->extension_service(), 305 new BookmarkAppHelper(profile_, web_app_info_, web_contents()));
324 web_app_info_, web_contents()));
325 bookmark_app_helper_->Create(base::Bind( 306 bookmark_app_helper_->Create(base::Bind(
326 &TabHelper::FinishCreateBookmarkApp, weak_ptr_factory_.GetWeakPtr())); 307 &TabHelper::FinishCreateBookmarkApp, weak_ptr_factory_.GetWeakPtr()));
327 break; 308 break;
328 } 309 }
329 case UPDATE_SHORTCUT: { 310 case UPDATE_SHORTCUT: {
330 web_app::UpdateShortcutForTabContents(web_contents()); 311 web_app::UpdateShortcutForTabContents(web_contents());
331 break; 312 break;
332 } 313 }
333 default: 314 default:
334 NOTREACHED(); 315 NOTREACHED();
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 576 }
596 } 577 }
597 578
598 void TabHelper::SetTabId(RenderViewHost* render_view_host) { 579 void TabHelper::SetTabId(RenderViewHost* render_view_host) {
599 render_view_host->Send( 580 render_view_host->Send(
600 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), 581 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(),
601 SessionTabHelper::IdForTab(web_contents()))); 582 SessionTabHelper::IdForTab(web_contents())));
602 } 583 }
603 584
604 } // namespace extensions 585 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698