Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 22 matching lines...) Expand all Loading... | |
| 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" | 36 #include "chrome/common/extensions/chrome_extension_messages.h" |
| 37 #include "chrome/common/extensions/extension_constants.h" | 37 #include "chrome/common/extensions/extension_constants.h" |
| 38 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 38 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 39 #include "chrome/common/render_messages.h" | 39 #include "chrome/common/render_messages.h" |
| 40 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 41 #include "content/public/browser/invalidate_type.h" | 41 #include "content/public/browser/invalidate_type.h" |
| 42 #include "content/public/browser/navigation_controller.h" | 42 #include "content/public/browser/navigation_controller.h" |
| 43 #include "content/public/browser/navigation_details.h" | |
| 44 #include "content/public/browser/navigation_entry.h" | 43 #include "content/public/browser/navigation_entry.h" |
| 44 #include "content/public/browser/navigation_handle.h" | |
| 45 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/notification_source.h" | 46 #include "content/public/browser/notification_source.h" |
| 47 #include "content/public/browser/notification_types.h" | 47 #include "content/public/browser/notification_types.h" |
| 48 #include "content/public/browser/render_frame_host.h" | 48 #include "content/public/browser/render_frame_host.h" |
| 49 #include "content/public/browser/render_process_host.h" | 49 #include "content/public/browser/render_process_host.h" |
| 50 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 51 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/common/frame_navigate_params.h" | 52 #include "content/public/common/frame_navigate_params.h" |
| 53 #include "extensions/browser/api/declarative/rules_registry_service.h" | 53 #include "extensions/browser/api/declarative/rules_registry_service.h" |
| 54 #include "extensions/browser/extension_prefs.h" | 54 #include "extensions/browser/extension_prefs.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 void TabHelper::FinishCreateBookmarkApp( | 309 void TabHelper::FinishCreateBookmarkApp( |
| 310 const Extension* extension, | 310 const Extension* extension, |
| 311 const WebApplicationInfo& web_app_info) { | 311 const WebApplicationInfo& web_app_info) { |
| 312 pending_web_app_action_ = NONE; | 312 pending_web_app_action_ = NONE; |
| 313 } | 313 } |
| 314 | 314 |
| 315 void TabHelper::RenderFrameCreated(content::RenderFrameHost* host) { | 315 void TabHelper::RenderFrameCreated(content::RenderFrameHost* host) { |
| 316 SetTabId(host); | 316 SetTabId(host); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void TabHelper::DidNavigateMainFrame( | 319 void TabHelper::DidFinishNavigation( |
| 320 const content::LoadCommittedDetails& details, | 320 content::NavigationHandle* navigation_handle) { |
| 321 const content::FrameNavigateParams& params) { | 321 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 322 return; | |
| 323 | |
| 322 InvokeForContentRulesRegistries( | 324 InvokeForContentRulesRegistries( |
| 323 [this, &details, ¶ms](ContentRulesRegistry* registry) { | 325 [this, &navigation_handle](ContentRulesRegistry* registry) { |
|
Devlin
2017/02/01 23:18:22
nit: any reason to capture navigation_handle by re
jam
2017/02/01 23:48:49
no, you're right this was an oversight. thanks, fi
| |
| 324 registry->DidNavigateMainFrame(web_contents(), details, params); | 326 registry->DidFinishNavigation(web_contents(), navigation_handle); |
| 325 }); | 327 }); |
| 326 | 328 |
| 327 content::BrowserContext* context = web_contents()->GetBrowserContext(); | 329 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
| 328 ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 330 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
| 329 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); | 331 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); |
| 330 | 332 |
| 331 if (util::IsNewBookmarkAppsEnabled()) { | 333 if (util::IsNewBookmarkAppsEnabled()) { |
| 332 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 334 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 333 if (browser && browser->is_app()) { | 335 if (browser && browser->is_app()) { |
| 334 const Extension* extension = registry->GetExtensionById( | 336 const Extension* extension = registry->GetExtensionById( |
| 335 web_app::GetExtensionIdFromApplicationName(browser->app_name()), | 337 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
| 336 ExtensionRegistry::EVERYTHING); | 338 ExtensionRegistry::EVERYTHING); |
| 337 if (extension && AppLaunchInfo::GetFullLaunchURL(extension).is_valid()) | 339 if (extension && AppLaunchInfo::GetFullLaunchURL(extension).is_valid()) |
| 338 SetExtensionApp(extension); | 340 SetExtensionApp(extension); |
| 339 } else { | 341 } else { |
| 340 UpdateExtensionAppIcon( | 342 UpdateExtensionAppIcon( |
| 341 enabled_extensions.GetExtensionOrAppByURL(params.url)); | 343 enabled_extensions.GetExtensionOrAppByURL( |
| 344 navigation_handle->GetURL())); | |
| 342 } | 345 } |
| 343 } else { | 346 } else { |
| 344 UpdateExtensionAppIcon( | 347 UpdateExtensionAppIcon( |
| 345 enabled_extensions.GetExtensionOrAppByURL(params.url)); | 348 enabled_extensions.GetExtensionOrAppByURL(navigation_handle->GetURL())); |
| 346 } | 349 } |
| 347 | 350 |
| 348 if (!details.is_in_page) | 351 if (!navigation_handle->IsSamePage()) |
| 349 ExtensionActionAPI::Get(context)->ClearAllValuesForTab(web_contents()); | 352 ExtensionActionAPI::Get(context)->ClearAllValuesForTab(web_contents()); |
| 350 } | 353 } |
| 351 | 354 |
| 352 bool TabHelper::OnMessageReceived(const IPC::Message& message) { | 355 bool TabHelper::OnMessageReceived(const IPC::Message& message) { |
| 353 bool handled = true; | 356 bool handled = true; |
| 354 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) | 357 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) |
| 355 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, | 358 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, |
| 356 OnDidGetWebApplicationInfo) | 359 OnDidGetWebApplicationInfo) |
| 357 IPC_MESSAGE_UNHANDLED(handled = false) | 360 IPC_MESSAGE_UNHANDLED(handled = false) |
| 358 IPC_END_MESSAGE_MAP() | 361 IPC_END_MESSAGE_MAP() |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 } | 682 } |
| 680 } | 683 } |
| 681 | 684 |
| 682 void TabHelper::SetTabId(content::RenderFrameHost* render_frame_host) { | 685 void TabHelper::SetTabId(content::RenderFrameHost* render_frame_host) { |
| 683 render_frame_host->Send( | 686 render_frame_host->Send( |
| 684 new ExtensionMsg_SetTabId(render_frame_host->GetRoutingID(), | 687 new ExtensionMsg_SetTabId(render_frame_host->GetRoutingID(), |
| 685 SessionTabHelper::IdForTab(web_contents()))); | 688 SessionTabHelper::IdForTab(web_contents()))); |
| 686 } | 689 } |
| 687 | 690 |
| 688 } // namespace extensions | 691 } // namespace extensions |
| OLD | NEW |