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

Side by Side Diff: chrome/browser/ui/web_applications/web_app_ui.cc

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/web_applications/web_app_ui.h" 5 #include "chrome/browser/ui/web_applications/web_app_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
25 25
26 #if defined(OS_POSIX) && !defined(OS_MACOSX) 26 #if defined(OS_POSIX) && !defined(OS_MACOSX)
27 #include "base/environment.h" 27 #include "base/environment.h"
28 #endif 28 #endif
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using content::NavigationController;
31 32
32 namespace { 33 namespace {
33 34
34 #if defined(OS_WIN) 35 #if defined(OS_WIN)
35 // UpdateShortcutWorker holds all context data needed for update shortcut. 36 // UpdateShortcutWorker holds all context data needed for update shortcut.
36 // It schedules a pre-update check to find all shortcuts that needs to be 37 // It schedules a pre-update check to find all shortcuts that needs to be
37 // updated. If there are such shortcuts, it schedules icon download and 38 // updated. If there are such shortcuts, it schedules icon download and
38 // update them when icons are downloaded. It observes TAB_CLOSING notification 39 // update them when icons are downloaded. It observes TAB_CLOSING notification
39 // and cancels all the work when the underlying tab is closing. 40 // and cancels all the work when the underlying tab is closing.
40 class UpdateShortcutWorker : public content::NotificationObserver { 41 class UpdateShortcutWorker : public content::NotificationObserver {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 : tab_contents_(tab_contents), 97 : tab_contents_(tab_contents),
97 profile_path_(tab_contents->profile()->GetPath()) { 98 profile_path_(tab_contents->profile()->GetPath()) {
98 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); 99 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_);
99 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), 100 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(),
100 &unprocessed_icons_); 101 &unprocessed_icons_);
101 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); 102 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title);
102 103
103 registrar_.Add( 104 registrar_.Add(
104 this, 105 this,
105 content::NOTIFICATION_TAB_CLOSING, 106 content::NOTIFICATION_TAB_CLOSING,
106 content::Source<content::NavigationController>( 107 content::Source<NavigationController>(
107 &tab_contents_->web_contents()->GetController())); 108 &tab_contents_->web_contents()->GetController()));
108 } 109 }
109 110
110 void UpdateShortcutWorker::Run() { 111 void UpdateShortcutWorker::Run() {
111 // Starting by downloading app icon. 112 // Starting by downloading app icon.
112 DownloadIcon(); 113 DownloadIcon();
113 } 114 }
114 115
115 void UpdateShortcutWorker::Observe( 116 void UpdateShortcutWorker::Observe(
116 int type, 117 int type,
117 const content::NotificationSource& source, 118 const content::NotificationSource& source,
118 const content::NotificationDetails& details) { 119 const content::NotificationDetails& details) {
119 if (type == content::NOTIFICATION_TAB_CLOSING && 120 if (type == content::NOTIFICATION_TAB_CLOSING &&
120 content::Source<content::NavigationController>(source).ptr() == 121 content::Source<NavigationController>(source).ptr() ==
121 &tab_contents_->web_contents()->GetController()) { 122 &tab_contents_->web_contents()->GetController()) {
122 // Underlying tab is closing. 123 // Underlying tab is closing.
123 tab_contents_ = NULL; 124 tab_contents_ = NULL;
124 } 125 }
125 } 126 }
126 127
127 void UpdateShortcutWorker::DownloadIcon() { 128 void UpdateShortcutWorker::DownloadIcon() {
128 // FetchIcon must run on UI thread because it relies on TabContents 129 // FetchIcon must run on UI thread because it relies on TabContents
129 // to download the icon. 130 // to download the icon.
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 313
313 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { 314 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) {
314 #if defined(OS_WIN) 315 #if defined(OS_WIN)
315 // UpdateShortcutWorker will delete itself when it's done. 316 // UpdateShortcutWorker will delete itself when it's done.
316 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); 317 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents);
317 worker->Run(); 318 worker->Run();
318 #endif // defined(OS_WIN) 319 #endif // defined(OS_WIN)
319 } 320 }
320 321
321 } // namespace web_app 322 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_container.cc ('k') | chrome/browser/ui/webui/cloud_print_signin_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698