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/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" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 141 |
142 bool TabHelper::CanCreateApplicationShortcuts() const { | 142 bool TabHelper::CanCreateApplicationShortcuts() const { |
143 #if defined(OS_MACOSX) | 143 #if defined(OS_MACOSX) |
144 return false; | 144 return false; |
145 #else | 145 #else |
146 return web_app::IsValidUrl(web_contents()->GetURL()); | 146 return web_app::IsValidUrl(web_contents()->GetURL()); |
147 #endif | 147 #endif |
148 } | 148 } |
149 | 149 |
150 bool TabHelper::CanCreateBookmarkApp() const { | 150 bool TabHelper::CanCreateBookmarkApp() const { |
151 #if defined(OS_MACOSX) | |
152 return false; | |
153 #else | |
154 return IsValidBookmarkAppUrl(web_contents()->GetURL()); | 151 return IsValidBookmarkAppUrl(web_contents()->GetURL()); |
155 #endif | |
156 } | 152 } |
157 | 153 |
158 void TabHelper::AddScriptExecutionObserver(ScriptExecutionObserver* observer) { | 154 void TabHelper::AddScriptExecutionObserver(ScriptExecutionObserver* observer) { |
159 script_execution_observers_.AddObserver(observer); | 155 script_execution_observers_.AddObserver(observer); |
160 } | 156 } |
161 | 157 |
162 void TabHelper::RemoveScriptExecutionObserver( | 158 void TabHelper::RemoveScriptExecutionObserver( |
163 ScriptExecutionObserver* observer) { | 159 ScriptExecutionObserver* observer) { |
164 script_execution_observers_.RemoveObserver(observer); | 160 script_execution_observers_.RemoveObserver(observer); |
165 } | 161 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 // When the WebContents that this is attached to is cloned, give the new clone | 284 // When the WebContents that this is attached to is cloned, give the new clone |
289 // a TabHelper and copy state over. | 285 // a TabHelper and copy state over. |
290 CreateForWebContents(new_web_contents); | 286 CreateForWebContents(new_web_contents); |
291 TabHelper* new_helper = FromWebContents(new_web_contents); | 287 TabHelper* new_helper = FromWebContents(new_web_contents); |
292 | 288 |
293 new_helper->SetExtensionApp(extension_app()); | 289 new_helper->SetExtensionApp(extension_app()); |
294 new_helper->extension_app_icon_ = extension_app_icon_; | 290 new_helper->extension_app_icon_ = extension_app_icon_; |
295 } | 291 } |
296 | 292 |
297 void TabHelper::OnDidGetWebApplicationInfo(const WebApplicationInfo& info) { | 293 void TabHelper::OnDidGetWebApplicationInfo(const WebApplicationInfo& info) { |
298 #if !defined(OS_MACOSX) | |
299 web_app_info_ = info; | 294 web_app_info_ = info; |
300 | 295 |
301 NavigationEntry* entry = | 296 NavigationEntry* entry = |
302 web_contents()->GetController().GetLastCommittedEntry(); | 297 web_contents()->GetController().GetLastCommittedEntry(); |
303 if (!entry || last_committed_page_id_ != entry->GetPageID()) | 298 if (!entry || last_committed_page_id_ != entry->GetPageID()) |
304 return; | 299 return; |
305 last_committed_page_id_ = -1; | 300 last_committed_page_id_ = -1; |
306 | 301 |
307 switch (pending_web_app_action_) { | 302 switch (pending_web_app_action_) { |
308 case CREATE_SHORTCUT: { | 303 case CREATE_SHORTCUT: { |
jackhou1
2014/11/27 05:51:52
It looks like we never show the IDC_CREATE_SHORTCU
mitchellj
2014/11/27 23:29:44
Done.
| |
309 chrome::ShowCreateWebAppShortcutsDialog( | 304 chrome::ShowCreateWebAppShortcutsDialog( |
310 web_contents()->GetTopLevelNativeWindow(), | 305 web_contents()->GetTopLevelNativeWindow(), |
311 web_contents()); | 306 web_contents()); |
312 break; | 307 break; |
313 } | 308 } |
314 case CREATE_HOSTED_APP: { | 309 case CREATE_HOSTED_APP: { |
315 if (web_app_info_.app_url.is_empty()) | 310 if (web_app_info_.app_url.is_empty()) |
316 web_app_info_.app_url = web_contents()->GetURL(); | 311 web_app_info_.app_url = web_contents()->GetURL(); |
317 | 312 |
318 if (web_app_info_.title.empty()) | 313 if (web_app_info_.title.empty()) |
(...skipping 14 matching lines...) Expand all Loading... | |
333 } | 328 } |
334 default: | 329 default: |
335 NOTREACHED(); | 330 NOTREACHED(); |
336 break; | 331 break; |
337 } | 332 } |
338 | 333 |
339 // The hosted app action will be cleared once the installation completes or | 334 // The hosted app action will be cleared once the installation completes or |
340 // fails. | 335 // fails. |
341 if (pending_web_app_action_ != CREATE_HOSTED_APP) | 336 if (pending_web_app_action_ != CREATE_HOSTED_APP) |
342 pending_web_app_action_ = NONE; | 337 pending_web_app_action_ = NONE; |
343 #endif | |
344 } | 338 } |
345 | 339 |
346 void TabHelper::OnInlineWebstoreInstall(int install_id, | 340 void TabHelper::OnInlineWebstoreInstall(int install_id, |
347 int return_route_id, | 341 int return_route_id, |
348 const std::string& webstore_item_id, | 342 const std::string& webstore_item_id, |
349 const GURL& requestor_url, | 343 const GURL& requestor_url, |
350 int listeners_mask) { | 344 int listeners_mask) { |
351 // Check that the listener is reasonable. We should never get anything other | 345 // Check that the listener is reasonable. We should never get anything other |
352 // than an install stage listener, a download listener, or both. | 346 // than an install stage listener, a download listener, or both. |
353 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER | | 347 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER | |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 } | 591 } |
598 } | 592 } |
599 | 593 |
600 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 594 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
601 render_view_host->Send( | 595 render_view_host->Send( |
602 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 596 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
603 SessionTabHelper::IdForTab(web_contents()))); | 597 SessionTabHelper::IdForTab(web_contents()))); |
604 } | 598 } |
605 | 599 |
606 } // namespace extensions | 600 } // namespace extensions |
OLD | NEW |